Update doc and example.
This commit is contained in:
parent
f0e1b719d8
commit
fab42a061e
|
@ -24,8 +24,6 @@ import (
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultStorageEndpoint = "storage.yandexcloud.net"
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
common.PackerConfig `mapstructure:",squash"`
|
common.PackerConfig `mapstructure:",squash"`
|
||||||
|
|
||||||
|
@ -38,7 +36,7 @@ type Config struct {
|
||||||
// Alternatively you may set value by environment variable YC_FOLDER_ID.
|
// Alternatively you may set value by environment variable YC_FOLDER_ID.
|
||||||
FolderID string `mapstructure:"folder_id" required:"true"`
|
FolderID string `mapstructure:"folder_id" required:"true"`
|
||||||
// Service Account ID with proper permission to modify an instance, create and attach disk and
|
// Service Account ID with proper permission to modify an instance, create and attach disk and
|
||||||
// make upload to specific Yandex Object Storage paths.
|
// make upload to specific Yandex Object Storage paths
|
||||||
ServiceAccountID string `mapstructure:"service_account_id" required:"true"`
|
ServiceAccountID string `mapstructure:"service_account_id" required:"true"`
|
||||||
// The size of the disk in GB. This defaults to `100`, which is 100GB.
|
// The size of the disk in GB. This defaults to `100`, which is 100GB.
|
||||||
DiskSizeGb int `mapstructure:"disk_size" required:"false"`
|
DiskSizeGb int `mapstructure:"disk_size" required:"false"`
|
||||||
|
@ -236,7 +234,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
||||||
steps := []multistep.Step{
|
steps := []multistep.Step{
|
||||||
&yandex.StepCreateSSHKey{
|
&yandex.StepCreateSSHKey{
|
||||||
Debug: p.config.PackerDebug,
|
Debug: p.config.PackerDebug,
|
||||||
DebugKeyPath: fmt.Sprintf("yc_export_pp_%s.pem", p.config.PackerBuildName),
|
DebugKeyPath: fmt.Sprintf("yc_pp_%s.pem", p.config.PackerBuildName),
|
||||||
},
|
},
|
||||||
&yandex.StepCreateInstance{
|
&yandex.StepCreateInstance{
|
||||||
Debug: p.config.PackerDebug,
|
Debug: p.config.PackerDebug,
|
||||||
|
@ -250,10 +248,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
|
||||||
p.runner = common.NewRunner(steps, p.config.PackerConfig, ui)
|
p.runner = common.NewRunner(steps, p.config.PackerConfig, ui)
|
||||||
p.runner.Run(ctx, state)
|
p.runner.Run(ctx, state)
|
||||||
|
|
||||||
result := &Artifact{
|
result := &Artifact{paths: p.config.Paths}
|
||||||
paths: p.config.Paths,
|
|
||||||
urls: formUrls(p.config.Paths),
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, false, false, nil
|
return result, false, false, nil
|
||||||
}
|
}
|
||||||
|
@ -276,12 +271,3 @@ func ycSaneDefaults() yandex.Config {
|
||||||
StateTimeout: 3 * time.Minute,
|
StateTimeout: 3 * time.Minute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func formUrls(paths []string) []string {
|
|
||||||
result := []string{}
|
|
||||||
for _, path := range paths {
|
|
||||||
url := fmt.Sprintf("https://%s/%s", defaultStorageEndpoint, strings.TrimPrefix(path, "s3://"))
|
|
||||||
result = append(result, url)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue