This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from secrethub/release/v0.28.0
Release v0.28.0
- Loading branch information
Showing
16 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
branches: | ||
- release/v* | ||
|
||
jobs: | ||
bump-version: | ||
name: Bump secrethub.ClientVersion | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Bump version | ||
uses: florisvdg/[email protected] | ||
with: | ||
sed: 's/^\(const ClientVersion = "v\).*\("\)$/\1$VERSION\2/g' | ||
file: pkg/secrethub/client_version.go | ||
author_email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package secrethub | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/secrethub/secrethub-go/internals/assert" | ||
) | ||
|
||
func TestClient_userAgent(t *testing.T) { | ||
cases := map[string]struct { | ||
appInfo []*AppInfo | ||
envAppName string | ||
envAppVersion string | ||
expected string | ||
err error | ||
}{ | ||
"default": {}, | ||
"multiple app info layers": { | ||
appInfo: []*AppInfo{ | ||
{Name: "secrethub-xgo", Version: "0.1.0"}, | ||
{Name: "secrethub-java", Version: "0.2.0"}, | ||
}, | ||
expected: "secrethub-xgo/0.1.0 secrethub-java/0.2.0", | ||
}, | ||
"no version number": { | ||
appInfo: []*AppInfo{ | ||
{Name: "terraform-provider-secrethub"}, | ||
}, | ||
expected: "terraform-provider-secrethub", | ||
}, | ||
"top level app info from environment": { | ||
appInfo: []*AppInfo{ | ||
{Name: "secrethub-cli", Version: "0.37.0"}, | ||
}, | ||
envAppName: "secrethub-circleci-orb", | ||
envAppVersion: "1.0.0", | ||
expected: "secrethub-cli/0.37.0 secrethub-circleci-orb/1.0.0", | ||
}, | ||
"invalid app name": { | ||
appInfo: []*AppInfo{ | ||
{Name: "illegal-name*%!@", Version: "0.1.0"}, | ||
}, | ||
err: ErrInvalidAppInfoName, | ||
}, | ||
"ignore faulty environment variable": { | ||
appInfo: []*AppInfo{ | ||
{Name: "secrethub-cli", Version: "0.37.0"}, | ||
}, | ||
envAppName: "illegal-name*%!@", | ||
expected: "secrethub-cli/0.37.0", | ||
}, | ||
} | ||
|
||
for name, tc := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
os.Setenv("SECRETHUB_APP_INFO_NAME", tc.envAppName) | ||
os.Setenv("SECRETHUB_APP_INFO_VERSION", tc.envAppVersion) | ||
|
||
var opts []ClientOption | ||
for _, info := range tc.appInfo { | ||
opts = append(opts, WithAppInfo(info)) | ||
} | ||
client, err := NewClient(opts...) | ||
assert.Equal(t, err, tc.err) | ||
if err != nil { | ||
return | ||
} | ||
|
||
userAgent := client.userAgent() | ||
pattern := tc.expected + " \\(.*\\)" | ||
matched, err := regexp.MatchString(pattern, userAgent) | ||
assert.OK(t, err) | ||
if !matched { | ||
t.Errorf("user agent '%s' doesn't match pattern '%s'", userAgent, pattern) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.