Skip to content

Commit ff75b75

Browse files
committed
fix: modify source_image_family
1 parent 5332df3 commit ff75b75

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

builder/tencentcloud/cvm/run_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type TencentCloudRunConfig struct {
3939
// The image family always returns its latest image that is not deprecated.
4040
// Conflict with SourceImageId and SourceImageName. It takes effect when SourceImageId and SourceImageName are empty.
4141
// Example value: business-daily-update.
42-
SourceImageFamily string `mapstructure:"image_family" required:"false"`
42+
SourceImageFamily string `mapstructure:"source_image_family" required:"false"`
4343
// Charge type of cvm, values can be `POSTPAID_BY_HOUR` (default) `SPOTPAID`
4444
InstanceChargeType string `mapstructure:"instance_charge_type" required:"false"`
4545
// The instance type your cvm will be launched by.

builder/tencentcloud/cvm/step_check_source_image.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ type stepCheckSourceImage struct {
1919
}
2020

2121
func (s *stepCheckSourceImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
22-
if s.sourceImageId == "" && s.sourceImageName == "" && s.sourceImageFamily != "" {
23-
return multistep.ActionContinue
24-
}
2522
var (
2623
imageNameRegex *regexp.Regexp
2724
err error

builder/tencentcloud/cvm/step_check_source_image_family.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (s *stepCheckSourceImageFamily) Run(ctx context.Context, state multistep.St
2727
Say(state, config.SourceImageFamily, "Try to check the source image and get the latest valid image of the image family")
2828

2929
req := cvm.NewDescribeImageFromFamilyRequest()
30-
req.ImageFamily = &config.InstanceType
30+
req.ImageFamily = &config.SourceImageFamily
3131

3232
var resp *cvm.DescribeImageFromFamilyResponse
3333
err := Retry(ctx, func(ctx context.Context) error {
@@ -39,15 +39,15 @@ func (s *stepCheckSourceImageFamily) Run(ctx context.Context, state multistep.St
3939
return Halt(state, err, "Failed to get source image info from the image family")
4040
}
4141

42-
image := resp.Response.Image
43-
if image != nil {
42+
if resp != nil && resp.Response != nil && resp.Response.Image != nil {
43+
image := resp.Response.Image
4444
if image.ImageId != nil && !*image.ImageDeprecated {
45-
state.Put("source_image", image.ImageId)
45+
state.Put("source_image", image)
4646
Message(state, fmt.Sprintf("Get the latest image from the image family, id: %v", *image.ImageId), "Image found")
4747
return multistep.ActionContinue
4848
}
4949
} else {
50-
return Halt(state, err, "Failed to get source image info from the image family")
50+
return Halt(state, fmt.Errorf("failed to get source image: %v", resp.ToJsonString()), "No image family found")
5151
}
5252

5353
return Halt(state, fmt.Errorf("No image found under current instance_type(%s) restriction", config.InstanceType), "")

0 commit comments

Comments
 (0)