Skip to content

Commit c5b0fc6

Browse files
committed
Openstack Plugin Release Version 1.1.4 and lint fix
1 parent 167485c commit c5b0fc6

20 files changed

Lines changed: 269 additions & 309 deletions

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.21.13
1+
1.25.11
22

.golangci.yml

Lines changed: 30 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
1-
# Copyright (c) HashiCorp, Inc.
1+
# Copyright IBM Corp. 2013, 2026
22
# SPDX-License-Identifier: MPL-2.0
33

4-
issues:
5-
# List of regexps of issue texts to exclude, empty list by default.
6-
# But independently from this option we use default exclude patterns,
7-
# it can be disabled by `exclude-use-default: false`. To list all
8-
# excluded by default patterns execute `golangci-lint run --help`
9-
10-
exclude-rules:
11-
# Exclude gosimple bool check
12-
- linters:
13-
- gosimple
14-
text: "S(1002|1008|1021)"
15-
# Exclude failing staticchecks for now
16-
- linters:
17-
- staticcheck
18-
text: "SA(1006|1019|4006|4010|4017|5007|6005|9004):"
19-
# Exclude lll issues for long lines with go:generate
20-
- linters:
21-
- lll
22-
source: "^//go:generate "
23-
- linters:
24-
- errcheck
25-
path: ".*_test.go"
26-
27-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
28-
max-issues-per-linter: 0
29-
30-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
31-
max-same-issues: 0
4+
version: "2"
325

336
linters:
34-
disable-all: true
357
enable:
36-
- errcheck
37-
- goimports
38-
- gosimple
8+
- asasalint
9+
- asciicheck
10+
- bidichk
11+
- decorder
12+
- dupword
3913
- govet
4014
- ineffassign
15+
- misspell
16+
- nilerr
17+
- reassign
4118
- staticcheck
4219
- unconvert
4320
- unused
44-
fast: true
21+
settings:
22+
errcheck:
23+
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
24+
# default is false: such cases aren't reported by default.
25+
check-type-assertions: false
26+
27+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
28+
# default is false: such cases aren't reported by default.
29+
check-blank: false
30+
staticcheck:
31+
# SAxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks
32+
# Example (to disable some checks): [ "all", "-SA1000", "-SA1001"]
33+
# Run `GL_DEBUG=staticcheck golangci-lint run --enable=staticcheck` to see all available checks and enabled by config checks.
34+
checks: ["all", "-SA4006", "-ST1000", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1004", "-QF1008", "-QF1012"]
4535

4636
# options for analysis running
4737
run:
@@ -57,71 +47,15 @@ run:
5747
# include test files or not, default is true
5848
tests: true
5949

60-
# list of build tags, all linters use it. Default is empty list.
61-
#build-tags:
62-
# - mytag
63-
64-
# which dirs to skip: issues from them won't be reported;
65-
# can use regexp here: generated.*, regexp is applied on full path;
66-
# default value is empty list, but default dirs are skipped independently
67-
# from this option's value (see skip-dirs-use-default).
68-
#skip-dirs:
69-
# - src/external_libs
70-
# - autogenerated_by_my_lib
71-
72-
# default is true. Enables skipping of directories:
73-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
74-
skip-dirs-use-default: true
75-
7650
# which files to skip: they will be analyzed, but issues from them
7751
# won't be reported. Default value is empty list, but there is
7852
# no need to include all autogenerated files, we confidently recognize
7953
# autogenerated files. If it's not please let us know.
80-
exclude-files:
81-
- ".*\\.hcl2spec\\.go$"
54+
# skip-files:
55+
# - ".*\\.hcl2spec\\.go$"
8256
# - lib/bad.go
8357

84-
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
85-
# If invoked with -mod=readonly, the go command is disallowed from the implicit
86-
# automatic updating of go.mod described above. Instead, it fails when any changes
87-
# to go.mod are needed. This setting is most useful to check that go.mod does
88-
# not need updates, such as in a continuous integration and testing system.
89-
# If invoked with -mod=vendor, the go command assumes that the vendor
90-
# directory holds the correct copies of dependencies and ignores
91-
# the dependency descriptions in go.mod.
92-
modules-download-mode: readonly
93-
94-
# output configuration options
95-
output:
96-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
97-
formats: colored-line-number
98-
99-
# print lines of code with issue, default is true
100-
print-issued-lines: true
101-
102-
# print linter name in the end of issue text, default is true
103-
print-linter-name: true
104-
105-
# make issues output unique by line, default is true
106-
uniq-by-line: true
107-
108-
109-
# all available settings of specific linters
110-
linters-settings:
111-
errcheck:
112-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
113-
# default is false: such cases aren't reported by default.
114-
check-type-assertions: false
115-
116-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
117-
# default is false: such cases aren't reported by default.
118-
check-blank: false
119-
120-
# [deprecated] comma-separated list of pairs of the form pkg:regex
121-
# the regex is used to ignore names within pkg. (default "fmt:.*").
122-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
123-
exclude-functions: fmt:.*,io/ioutil:^Read.*,io:Close
124-
125-
# path to a file containing a list of functions to exclude from checking
126-
# see https://github.com/kisielk/errcheck#excluding-functions for details
127-
#exclude: /path/to/file.txt
58+
formatters:
59+
enable:
60+
- gofmt
61+
- goimports

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.1.4 (June 17, 2026)
2+
3+
* fix: add an optional wait before creating the image to improve reliability in image creation workflows.
4+
* fix: use `openstack` as the HCP metadata provider name (instead of the default prefixed provider value).
5+
* chore: add the HCP Ready flag to web metadata.
6+
* chore: update copyright and license headers across the codebase for compliance.
7+
* chore: bump `github.com/hashicorp/packer-plugin-sdk` from `0.6.4` to `0.6.7`.
8+
19
## 1.0.0 (June 14, 2021)
210

311
* Update packer-plugin-sdk to version 0.2.3. [GH-29]

builder/openstack/access_config.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"crypto/x509"
1212
"fmt"
1313
"io"
14-
"io/ioutil"
1514
"net/http"
1615
"os"
1716

@@ -205,7 +204,7 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
205204
tls_config := &tls.Config{}
206205

207206
if c.CACertFile != "" {
208-
caCert, err := ioutil.ReadFile(c.CACertFile)
207+
caCert, err := os.ReadFile(c.CACertFile)
209208
if err != nil {
210209
return []error{err}
211210
}
@@ -300,7 +299,7 @@ type DebugRoundTripper struct {
300299
func (drt *DebugRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) {
301300
defer func() {
302301
if request.Body != nil {
303-
request.Body.Close()
302+
_ = request.Body.Close()
304303
}
305304
}()
306305

@@ -323,15 +322,15 @@ func (drt *DebugRoundTripper) RoundTrip(request *http.Request) (*http.Response,
323322

324323
if response.StatusCode >= 400 {
325324
buf := bytes.NewBuffer([]byte{})
326-
body, _ := ioutil.ReadAll(io.TeeReader(response.Body, buf))
325+
body, _ := io.ReadAll(io.TeeReader(response.Body, buf))
327326
drt.DebugMessage(fmt.Sprintf("Response Error: %+v\n", string(body)))
328-
bufWithClose := ioutil.NopCloser(buf)
327+
bufWithClose := io.NopCloser(buf)
329328
response.Body = bufWithClose
330329
}
331330

332331
return response, err
333332
}
334333

335334
func (drt *DebugRoundTripper) DebugMessage(message string) {
336-
drt.ui.Message(fmt.Sprintf("[DEBUG] %s", message))
335+
drt.ui.Say(fmt.Sprintf("[DEBUG] %s", message))
337336
}

builder/openstack/builder_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
)
1111

1212
func TestBuilder_ImplementsBuilder(t *testing.T) {
13-
var raw interface{}
14-
raw = &Builder{}
13+
var raw interface{} = &Builder{}
1514
if _, ok := raw.(packersdk.Builder); !ok {
1615
t.Fatalf("Builder should be a builder")
1716
}

builder/openstack/image_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ImageConfig struct {
2626
// shared.
2727
ImageMembers []string `mapstructure:"image_members" required:"false"`
2828
// When true, perform the image accept so the members can see the image in their
29-
// project. This requires a user with priveleges both in the build project and
29+
// project. This requires a user with privileges both in the build project and
3030
// in the members provided. Defaults to false.
3131
ImageAutoAcceptMembers bool `mapstructure:"image_auto_accept_members" required:"false"`
3232
// Disk format of the resulting image. This option works if

builder/openstack/run_config_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ import (
1616
func init() {
1717
// Clear out the openstack env vars so they don't
1818
// affect our tests.
19-
os.Setenv("SDK_USERNAME", "")
20-
os.Setenv("SDK_PASSWORD", "")
21-
os.Setenv("SDK_PROVIDER", "")
19+
if err := os.Setenv("SDK_USERNAME", ""); err != nil {
20+
panic(err)
21+
}
22+
if err := os.Setenv("SDK_PASSWORD", ""); err != nil {
23+
panic(err)
24+
}
25+
if err := os.Setenv("SDK_PROVIDER", ""); err != nil {
26+
panic(err)
27+
}
2228
}
2329

2430
func testRunConfig() *RunConfig {

builder/openstack/step_allocate_ip.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult
3232
state.Put("access_ip", &instanceIP)
3333

3434
if s.FloatingIP == "" && !s.ReuseIPs && s.FloatingIPNetwork == "" {
35-
ui.Message("Floating IP not required")
35+
ui.Say("Floating IP not required")
3636
return multistep.ActionContinue
3737
}
3838

@@ -69,7 +69,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult
6969
}
7070

7171
instanceIP = *freeFloatingIP
72-
ui.Message(fmt.Sprintf("Selected floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
72+
ui.Say(fmt.Sprintf("Selected floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
7373
state.Put("floatingip_istemp", false)
7474
} else if s.ReuseIPs {
7575
// If ReuseIPs is set to true and we have a free floating IP, use it rather
@@ -84,7 +84,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult
8484
}
8585

8686
instanceIP = *freeFloatingIP
87-
ui.Message(fmt.Sprintf("Selected floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
87+
ui.Say(fmt.Sprintf("Selected floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
8888
state.Put("floatingip_istemp", false)
8989
} else if s.FloatingIPNetwork != "" {
9090
// Lastly, if FloatingIPNetwork was provided by the user, we need to use it
@@ -109,7 +109,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult
109109
}
110110

111111
instanceIP = *newIP
112-
ui.Message(fmt.Sprintf("Created floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
112+
ui.Say(fmt.Sprintf("Created floating IP: '%s' (%s)", instanceIP.ID, instanceIP.FloatingIP))
113113
state.Put("floatingip_istemp", true)
114114
}
115115

@@ -138,7 +138,7 @@ func (s *StepAllocateIp) Run(ctx context.Context, state multistep.StateBag) mult
138138
return multistep.ActionHalt
139139
}
140140

141-
ui.Message(fmt.Sprintf(
141+
ui.Say(fmt.Sprintf(
142142
"Added floating IP '%s' (%s) to instance!", instanceIP.ID, instanceIP.FloatingIP))
143143
}
144144

builder/openstack/step_create_image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
100100
}
101101

102102
// Set the Image ID in the state
103-
ui.Message(fmt.Sprintf("Image: %s", imageId))
103+
ui.Say(fmt.Sprintf("Image: %s", imageId))
104104
state.Put("image", imageId)
105105

106106
// Wait for the image to become ready

builder/openstack/step_create_volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
8888
}
8989

9090
// Set the Volume ID in the state.
91-
ui.Message(fmt.Sprintf("Volume ID: %s", volume.ID))
91+
ui.Say(fmt.Sprintf("Volume ID: %s", volume.ID))
9292
state.Put("volume_id", volume.ID)
9393

9494
return multistep.ActionContinue

0 commit comments

Comments
 (0)