Skip to content

Commit 4aa26b6

Browse files
sendqueeryNate Catelli
andauthored
Pulling changes upstream into main (#49)
* Validate number of SSM target filters specified (#47) * Add GHCR as a goreleaser target alongside github packages (#48) * remove deprecated fields in devcontainer * add ghcr.io image target Co-authored-by: Nate Catelli <ncatelli@packetfire.org>
1 parent 9567499 commit 4aa26b6

5 files changed

Lines changed: 38 additions & 3 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
],
1717
// Set *default* container specific settings.json values on container create.
1818
"settings": {
19-
"terminal.integrated.shell.linux": "/bin/bash",
20-
"go.useGoProxyToCheckForToolUpdates": false,
2119
"go.gopath": "/go"
2220
},
2321
// Add the IDs of extensions you want installed when the container is created.

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ jobs:
1515
uses: actions/setup-go@v1
1616
with:
1717
go-version: 1.13.x
18-
- name: Docker login
18+
- name: Docker login (github packages)
1919
uses: azure/docker-login@v1
2020
with:
2121
login-server: docker.pkg.github.com
2222
username: disneystreaming
2323
password: ${{ secrets.GO_RELEASER }}
24+
- name: Docker login (ghcr)
25+
uses: azure/docker-login@v1
26+
with:
27+
login-server: ghcr.io
28+
username: disneystreaming
29+
password: ${{ secrets.GO_RELEASER }}
2430
- name: Run GoReleaser
2531
uses: goreleaser/goreleaser-action@v1
2632
with:

.goreleaser.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ dockers:
5454
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Tag }}"
5555
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Major }}"
5656
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Major }}.{{ .Minor }}"
57+
- "ghcr.io/disneystreaming/ssm:latest"
58+
- "ghcr.io/disneystreaming/ssm:{{ .Tag }}"
59+
- "ghcr.io/disneystreaming/ssm:{{ .Major }}"
60+
- "ghcr.io/disneystreaming/ssm:{{ .Major }}.{{ .Minor }}"
5761

5862
nfpms:
5963
- license: MIT

cmd/flags.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ func validateSessionFlags(cmd *cobra.Command, instanceList []string, filterList
151151
return cmdutil.UsageError(cmd, "The --filter and --instance flags cannot be used simultaneously.")
152152
}
153153

154+
if len(filterList) > 5 {
155+
return cmdutil.UsageError(cmd, "A maximum of 5 tag filters can be specified at a time.")
156+
}
157+
154158
return nil
155159
}
156160

@@ -164,6 +168,10 @@ func validateRunFlags(cmd *cobra.Command, instanceList []string, commandList []s
164168
return cmdutil.UsageError(cmd, "You must supply target arguments using either the --filter or --instance flags.")
165169
}
166170

171+
if len(filterList) > 5 {
172+
return cmdutil.UsageError(cmd, "A maximum of 5 tag filters can be specified at a time.")
173+
}
174+
167175
if len(instanceList) > 50 {
168176
return cmdutil.UsageError(cmd, "The --instance flag can only be used to specify a maximum of 50 instances.")
169177
}

cmd/flags_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ func Test_validateRunFlags(t *testing.T) {
326326
assert.Error(err)
327327
})
328328

329+
t.Run("specify more than 5 filters", func(t *testing.T) {
330+
targetList := make([]*ssm.Target, 6)
331+
err := validateRunFlags(cmd, nil, []string{"hostname"}, targetList)
332+
assert.Error(err)
333+
})
334+
329335
t.Run("no instances or filters specified", func(t *testing.T) {
330336
err := validateRunFlags(cmd, nil, []string{"hostname"}, nil)
331337
assert.Error(err)
@@ -365,6 +371,19 @@ func Test_validateSessionFlags(t *testing.T) {
365371
assert.Error(err)
366372
})
367373

374+
t.Run("specify more than 5 filters", func(t *testing.T) {
375+
targetList := map[string]string{
376+
"1": "a",
377+
"2": "b",
378+
"3": "c",
379+
"4": "d",
380+
"5": "e",
381+
"6": "f",
382+
}
383+
err := validateSessionFlags(cmd, nil, targetList)
384+
assert.Error(err)
385+
})
386+
368387
t.Run("valid flag combination", func(t *testing.T) {
369388
err := validateSessionFlags(cmd, instanceList, nil)
370389
assert.NoError(err)

0 commit comments

Comments
 (0)