{"modulePath":"github.com/HashDataInc/packer","version":"v1.3.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package googlecomputeexport\n\n## Constants\n\n```go\nconst BuilderId = \"packer.post-processor.googlecompute-export\"\n```\n\n## Variables\n\n```go\nvar StartupScript string = `#!/bin/sh\n\nGetMetadata () {\n  echo \"$(curl -f -H \"Metadata-Flavor: Google\" http://metadata/computeMetadata/v1/instance/attributes/$1 2\u003e /dev/null)\"\n}\nIMAGENAME=$(GetMetadata image_name)\nNAME=$(GetMetadata name)\nDISKNAME=${NAME}-toexport\nPATHS=$(GetMetadata paths)\nZONE=$(GetMetadata zone)\n\nExit () {\n  for i in ${PATHS}; do\n    LOGDEST=\"${i}.exporter.log\"\n    echo \"Uploading exporter log to ${LOGDEST}...\"\n    gsutil -h \"Content-Type:text/plain\" cp /var/log/daemon.log ${LOGDEST}\n  done\n  exit $1\n}\n\necho \"####### Export configuration #######\"\necho \"Image name - ${IMAGENAME}\"\necho \"Instance name - ${NAME}\"\necho \"Instance zone - ${ZONE}\"\necho \"Disk name - ${DISKNAME}\"\necho \"Export paths - ${PATHS}\"\necho \"####################################\"\n\necho \"Creating disk from image to be exported...\"\nif ! gcloud compute disks create ${DISKNAME} --image ${IMAGENAME} --zone ${ZONE}; then\n  echo \"Failed to create disk.\"\n  Exit 1\nfi\n\necho \"Attaching disk...\"\nif ! gcloud compute instances attach-disk ${NAME} --disk ${DISKNAME} --device-name toexport --zone ${ZONE}; then\n  echo \"Failed to attach disk.\"\n  Exit 1\nfi\n\necho \"Dumping disk...\"\nif ! dd if=/dev/disk/by-id/google-toexport of=disk.raw bs=4096 conv=sparse; then\n  echo \"Failed to dump disk to image.\"\n  Exit 1\nfi\n\necho \"Compressing and tar'ing disk image...\"\nif ! tar -czf root.tar.gz disk.raw; then\n  echo \"Failed to tar disk image.\"\n  Exit 1\nfi\n\necho \"Detaching disk...\"\nif ! gcloud compute instances detach-disk ${NAME} --disk ${DISKNAME} --zone ${ZONE}; then\n  echo \"Failed to detach disk.\"\nfi\n\nFAIL=0\necho \"Deleting disk...\"\nif ! gcloud compute disks delete ${DISKNAME} --zone ${ZONE}; then\n  echo \"Failed to delete disk.\"\n  FAIL=1\nfi\n\nfor i in ${PATHS}; do\n  echo \"Uploading tar'ed disk image to ${i}...\"\n  if ! gsutil -o GSUtil:parallel_composite_upload_threshold=100M cp root.tar.gz ${i}; then\n    echo \"Failed to upload image to ${i}.\"\n    FAIL=1\n  fi\ndone\n\nExit ${FAIL}\n`\n```\n\n## Types\n\n```go\ntype Artifact struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (*Artifact) BuilderId() string\n```\n\n```go\nfunc (a *Artifact) Destroy() error\n```\n\n```go\nfunc (a *Artifact) Files() []string\n```\n\n```go\nfunc (*Artifact) Id() string\n```\n\n```go\nfunc (*Artifact) State(name string) interface{}\n```\n\n```go\nfunc (a *Artifact) String() string\n```\n\n```go\ntype Config struct {\n\tcommon.PackerConfig `mapstructure:\",squash\"`\n\n\tPaths             []string `mapstructure:\"paths\"`\n\tKeepOriginalImage bool     `mapstructure:\"keep_input_artifact\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype PostProcessor struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (p *PostProcessor) Configure(raws ...interface{}) error\n```\n\n```go\nfunc (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error)\n```\n\n","path":"github.com/HashDataInc/packer/post-processor/googlecompute-export","name":"googlecomputeexport","synopsis":"","isRedistributable":true}
