Skip to content

Commit aa1aa87

Browse files
committed
Fix lint issue
1 parent 426ebcb commit aa1aa87

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

builder/ucloud/uhost/step_check_source_image.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ package uhost
33
import (
44
"context"
55
"fmt"
6-
"github.com/ucloud/ucloud-sdk-go/services/uhost"
76

87
"github.com/hashicorp/packer-plugin-sdk/multistep"
98
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
9+
"github.com/ucloud/ucloud-sdk-go/services/uhost"
10+
1011
ucloudcommon "github.com/ucloud/packer-plugin-ucloud/builder/ucloud/common"
1112
)
1213

1314
type stepCheckSourceImageId struct {
1415
SourceUHostImageId string
1516
}
1617

17-
func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
18+
func (s *stepCheckSourceImageId) Run(
19+
ctx context.Context,
20+
state multistep.StateBag,
21+
) multistep.StepAction {
1822
ui := state.Get("ui").(packersdk.Ui)
1923
client := state.Get("client").(*ucloudcommon.UCloudClient)
2024

@@ -25,10 +29,21 @@ func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateB
2529
if ucloudcommon.IsNotFoundError(err) {
2630
uk8sNodeImage, uk8sErr := client.DescribeUK8sNodeImageById(s.SourceUHostImageId)
2731
if ucloudcommon.IsNotFoundError(uk8sErr) {
28-
return ucloudcommon.Halt(state, fmt.Errorf("fail to find source_image_id %q", s.SourceUHostImageId), "")
32+
return ucloudcommon.Halt(
33+
state,
34+
fmt.Errorf("fail to find source_image_id %q", s.SourceUHostImageId),
35+
"",
36+
)
2937
}
3038
if uk8sErr != nil {
31-
return ucloudcommon.Halt(state, uk8sErr, fmt.Sprintf("Error on querying specified source_image_id %q", s.SourceUHostImageId))
39+
return ucloudcommon.Halt(
40+
state,
41+
uk8sErr,
42+
fmt.Sprintf(
43+
"Error on querying specified source_image_id %q",
44+
s.SourceUHostImageId,
45+
),
46+
)
3247
}
3348
imageSet = &uhost.UHostImageSet{}
3449
imageSet.ImageName = uk8sNodeImage.ImageName
@@ -41,14 +56,29 @@ func (s *stepCheckSourceImageId) Run(ctx context.Context, state multistep.StateB
4156
}
4257

4358
if imageSet.OsType == ucloudcommon.OsTypeWindows {
44-
return ucloudcommon.Halt(state, err, "The ucloud-uhost builder does not support Windows images yet")
59+
return ucloudcommon.Halt(
60+
state,
61+
err,
62+
"The ucloud-uhost builder does not support Windows images yet",
63+
)
4564
}
4665

4766
_, uOK := state.GetOk("user_data")
4867
_, fOK := state.GetOk("user_data_file")
4968
if uOK || fOK {
5069
if !ucloudcommon.IsStringIn("CloudInit", imageSet.Features) {
51-
return ucloudcommon.Halt(state, err, fmt.Sprintf("The image %s must have %q feature when set the %q or %q, got %#v", imageSet.ImageId, "CloudInit", "user_data", "user_data_file", imageSet.Features))
70+
return ucloudcommon.Halt(
71+
state,
72+
err,
73+
fmt.Sprintf(
74+
"The image %s must have %q feature when set the %q or %q, got %#v",
75+
imageSet.ImageId,
76+
"CloudInit",
77+
"user_data",
78+
"user_data_file",
79+
imageSet.Features,
80+
),
81+
)
5282
}
5383
}
5484

0 commit comments

Comments
 (0)