Skip to content

Commit

Permalink
Pulling changes upstream into main (#49)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
sendqueery and ncatelli committed Jun 18, 2021
1 parent 9567499 commit 4aa26b6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.useGoProxyToCheckForToolUpdates": false,
"go.gopath": "/go"
},
// Add the IDs of extensions you want installed when the container is created.
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Docker login
- name: Docker login (github packages)
uses: azure/docker-login@v1
with:
login-server: docker.pkg.github.com
username: disneystreaming
password: ${{ secrets.GO_RELEASER }}
- name: Docker login (ghcr)
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: disneystreaming
password: ${{ secrets.GO_RELEASER }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ dockers:
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Tag }}"
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Major }}"
- "docker.pkg.github.com/disneystreaming/ssm-helpers/ssm:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/disneystreaming/ssm:latest"
- "ghcr.io/disneystreaming/ssm:{{ .Tag }}"
- "ghcr.io/disneystreaming/ssm:{{ .Major }}"
- "ghcr.io/disneystreaming/ssm:{{ .Major }}.{{ .Minor }}"

nfpms:
- license: MIT
Expand Down
8 changes: 8 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func validateSessionFlags(cmd *cobra.Command, instanceList []string, filterList
return cmdutil.UsageError(cmd, "The --filter and --instance flags cannot be used simultaneously.")
}

if len(filterList) > 5 {
return cmdutil.UsageError(cmd, "A maximum of 5 tag filters can be specified at a time.")
}

return nil
}

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

if len(filterList) > 5 {
return cmdutil.UsageError(cmd, "A maximum of 5 tag filters can be specified at a time.")
}

if len(instanceList) > 50 {
return cmdutil.UsageError(cmd, "The --instance flag can only be used to specify a maximum of 50 instances.")
}
Expand Down
19 changes: 19 additions & 0 deletions cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ func Test_validateRunFlags(t *testing.T) {
assert.Error(err)
})

t.Run("specify more than 5 filters", func(t *testing.T) {
targetList := make([]*ssm.Target, 6)
err := validateRunFlags(cmd, nil, []string{"hostname"}, targetList)
assert.Error(err)
})

t.Run("no instances or filters specified", func(t *testing.T) {
err := validateRunFlags(cmd, nil, []string{"hostname"}, nil)
assert.Error(err)
Expand Down Expand Up @@ -365,6 +371,19 @@ func Test_validateSessionFlags(t *testing.T) {
assert.Error(err)
})

t.Run("specify more than 5 filters", func(t *testing.T) {
targetList := map[string]string{
"1": "a",
"2": "b",
"3": "c",
"4": "d",
"5": "e",
"6": "f",
}
err := validateSessionFlags(cmd, nil, targetList)
assert.Error(err)
})

t.Run("valid flag combination", func(t *testing.T) {
err := validateSessionFlags(cmd, instanceList, nil)
assert.NoError(err)
Expand Down

0 comments on commit 4aa26b6

Please sign in to comment.