Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit b13a5c6

Browse files
Merge pull request #169 from secrethub/release/v0.26.0
Release v0.26.0
2 parents ffe2fce + 46749b8 commit b13a5c6

File tree

25 files changed

+345
-84
lines changed

25 files changed

+345
-84
lines changed

.circleci/config.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
jobs:
3-
build:
3+
test:
44
docker:
55
- image: circleci/golang:1.12
66
steps:
@@ -14,3 +14,27 @@ jobs:
1414
paths:
1515
- /go/pkg/mod
1616
- run: make test
17+
verify-version:
18+
docker:
19+
- image: circleci/golang:1.12
20+
steps:
21+
- checkout
22+
- restore_cache:
23+
keys:
24+
- go-modules-{{ checksum "go.mod" }}
25+
- run: go mod download
26+
- save_cache:
27+
key: go-modules-{{ checksum "go.mod" }}
28+
paths:
29+
- /go/pkg/mod
30+
- run: make check-version
31+
workflows:
32+
version: 2
33+
pipeline:
34+
jobs:
35+
- test
36+
- verify-version:
37+
filters:
38+
branches:
39+
only:
40+
- /release/v[0-9]*\.[0-9]*\.[0-9]*/

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ format-tools:
1616

1717
lint-tools:
1818
@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0
19+
20+
check-version:
21+
./scripts/check-version/check-version.sh

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ module github.com/secrethub/secrethub-go
33
require (
44
bitbucket.org/zombiezen/cardcpx v0.0.0-20150417151802-902f68ff43ef
55
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
6-
github.com/aws/aws-sdk-go v1.19.38
6+
github.com/aws/aws-sdk-go v1.25.49
77
github.com/docker/docker v1.13.1
88
github.com/docker/go-units v0.3.3
99
github.com/go-chi/chi v4.0.1+incompatible
10+
github.com/gofrs/uuid v3.2.0+incompatible
1011
github.com/google/go-querystring v1.0.0
11-
github.com/kr/pretty v0.1.0 // indirect
1212
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
1313
github.com/mattn/go-shellwords v1.0.6 // indirect
1414
github.com/mitchellh/go-homedir v1.1.0
1515
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
16-
github.com/satori/go.uuid v1.2.0
1716
github.com/stretchr/testify v1.3.0 // indirect
1817
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
1918
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect
20-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
2119
)
20+
21+
go 1.13

go.sum

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ bitbucket.org/zombiezen/cardcpx v0.0.0-20150417151802-902f68ff43ef h1:Y5Zf3CYdrd
22
bitbucket.org/zombiezen/cardcpx v0.0.0-20150417151802-902f68ff43ef/go.mod h1:ZJR5FpaQx7Bt2bzIV3gBaCInI1+kG949WhNYYlRr8eA=
33
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco=
44
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
5-
github.com/aws/aws-sdk-go v1.19.38 h1:WKjobgPO4Ua1ww2NJJl2/zQNreUZxvqmEzwMlRjjm9g=
6-
github.com/aws/aws-sdk-go v1.19.38/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
5+
github.com/aws/aws-sdk-go v1.25.49 h1:j5R2Ey+g8qaiy2NJ9iH+KWzDWS4SjXRCjhc22EeQVE4=
6+
github.com/aws/aws-sdk-go v1.25.49/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
77
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
88
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
@@ -12,15 +12,12 @@ github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk
1212
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
1313
github.com/go-chi/chi v4.0.1+incompatible h1:RSRC5qmFPtO90t7pTL0DBMNpZFsb/sHF3RXVlDgFisA=
1414
github.com/go-chi/chi v4.0.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
15+
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
16+
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
1517
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
1618
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
1719
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
1820
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
19-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
20-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
21-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
22-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
23-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2421
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
2522
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
2623
github.com/mattn/go-shellwords v1.0.6 h1:9Jok5pILi5S1MnDirGVTufYGtksUs/V2BWUP3ZkeUUI=
@@ -31,8 +28,6 @@ github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0C
3128
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
3229
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3330
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
34-
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
35-
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
3631
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3732
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
3833
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -43,5 +38,3 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR
4338
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
4439
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
4540
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
46-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
47-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internals/api/uuid/uuid.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
package uuid
33

44
import (
5-
gid "github.com/satori/go.uuid"
5+
"bytes"
6+
7+
gid "github.com/gofrs/uuid"
68

79
"github.com/secrethub/secrethub-go/internals/errio"
810
)
@@ -12,14 +14,17 @@ var (
1214
ErrInvalidUUID = errio.Namespace("uuid").Code("invalid").ErrorPref("invalid uuid: %s")
1315
)
1416

15-
// UUID is a wrapper around go.uuid.UUID
17+
// UUID is a wrapper around github.com/gofrs/uuid.UUID.
1618
type UUID struct {
1719
gid.UUID
1820
}
1921

2022
// New generates a new UUID.
2123
func New() UUID {
22-
id := gid.NewV4()
24+
id, err := gid.NewV4()
25+
if err != nil {
26+
panic(err)
27+
}
2328
return UUID{id}
2429
}
2530

@@ -44,7 +49,7 @@ func (u *UUID) IsZero() bool {
4449

4550
// Equal returns true if both argument UUIDs contain the same value.
4651
func Equal(a UUID, b UUID) bool {
47-
return gid.Equal(a.UUID, b.UUID)
52+
return bytes.Equal(a.UUID[:], b.UUID[:])
4853
}
4954

5055
// Validate validates a uuid string is a valid UUID.

pkg/randchar/example_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package randchar_test
2+
3+
import (
4+
"github.com/secrethub/secrethub-go/pkg/randchar"
5+
"log"
6+
)
7+
8+
// Generate a random slice of 30 alphanumeric characters.
9+
func ExampleRand_Generate() {
10+
val, err := randchar.Generate(30)
11+
if err != nil {
12+
log.Fatal(err)
13+
}
14+
print(string(val))
15+
}
16+
17+
// Generate a 15 character alphanumeric string with at least 3 symbols, 1 uppercase letter,
18+
// 1 lowercase letter and 1 digit.
19+
func ExampleRand_Generate_withRules() {
20+
symbolsRule := randchar.Min(3, randchar.Symbols)
21+
uppercaseRule := randchar.Min(1, randchar.Uppercase)
22+
lowercaseRule := randchar.Min(1, randchar.Lowercase)
23+
numberRule := randchar.Min(1, randchar.Numeric)
24+
25+
rand, err := randchar.NewRand(randchar.All, symbolsRule, uppercaseRule, lowercaseRule, numberRule)
26+
if err != nil {
27+
log.Fatal(err)
28+
}
29+
30+
val, err := rand.Generate(15)
31+
if err != nil {
32+
log.Fatal(err)
33+
}
34+
print(string(val))
35+
}
36+
37+
// Generate a 10 character alphanumeric string containing lowercase letters and digits.
38+
func ExampleRand_Generate_combineCharsets() {
39+
customCharset := randchar.Lowercase.Add(randchar.Numeric)
40+
rand, err := randchar.NewRand(customCharset)
41+
if err != nil {
42+
log.Fatal(err)
43+
}
44+
45+
val, err := rand.Generate(10)
46+
if err != nil {
47+
log.Fatal(err)
48+
}
49+
print(string(val))
50+
}
51+
52+
// Generate an 8 character long hexadecimal string.
53+
func ExampleRand_Generate_customCharset() {
54+
hexCharset := randchar.NewCharset("0123456789ABCDEF")
55+
rand, err := randchar.NewRand(hexCharset)
56+
if err != nil {
57+
log.Fatal(err)
58+
}
59+
60+
val, err := rand.Generate(8)
61+
if err != nil {
62+
log.Fatal(err)
63+
}
64+
print(string(val))
65+
}

pkg/randchar/generator.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,30 @@ func NewCharset(characters string) Charset {
244244
}
245245
}
246246

247+
// CharsetByName returns the charset with the specified name.
248+
func CharsetByName(charsetName string) (Charset, bool) {
249+
switch charsetName {
250+
case "numeric", "numbers", "digits":
251+
return Numeric, true
252+
case "lowercase":
253+
return Lowercase, true
254+
case "uppercase":
255+
return Uppercase, true
256+
case "letters":
257+
return Letters, true
258+
case "symbols":
259+
return Symbols, true
260+
case "alphanumeric":
261+
return Alphanumeric, true
262+
case "all":
263+
return All, true
264+
case "similar":
265+
return Similar, true
266+
default:
267+
return Charset{}, false
268+
}
269+
}
270+
247271
// Add merges two character sets into one, removing duplicates.
248272
func (c Charset) Add(set Charset) Charset {
249273
uniques := make(map[byte]struct{})

pkg/secrethub/account_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (s accountKeyService) Create(verifier credentials.Verifier, encrypter crede
4949
// Exists returns whether an account key exists for the client's credential.
5050
func (s accountKeyService) Exists() (bool, error) {
5151
_, err := s.client.getAccountKey()
52-
if err == api.ErrAccountKeyNotFound || err == api.ErrCredentialNotKeyed {
52+
if api.IsErrNotFound(err) {
5353
return false, nil
5454
}
5555
if err != nil {

pkg/secrethub/acl.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import (
88

99
// AccessRuleService handles operations on access rules from SecretHub.
1010
type AccessRuleService interface {
11-
// Delete removes the accessrule for the given directory and account.
12-
Delete(path string, accountName string) error
1311
// Get retrieves the access rule for the given account on the given directory.
1412
Get(path string, accountName string) (*api.AccessRule, error)
13+
// Set sets an access rule with a certain permission level for an account to a path.
14+
Set(path string, permission string, accountName string) (*api.AccessRule, error)
15+
// Delete removes the accessrule for the given directory and account.
16+
Delete(path string, accountName string) error
1517
// List etrieves all access rules that apply to a directory, including
1618
// rules that apply to its children up to a specified depth. When ancestors is set
1719
// to true, it also includes rules for any parent directories. When the depth is
1820
// set to -1, all children are retrieved without limit.
1921
List(path string, depth int, ancestors bool) ([]*api.AccessRule, error)
2022
// ListLevels lists the access levels on the given directory.
2123
ListLevels(path string) ([]*api.AccessLevel, error)
22-
// Set sets an access rule with a certain permission level for an account to a path.
23-
Set(path string, permission string, accountName string) (*api.AccessRule, error)
2424
}
2525

2626
func newAccessRuleService(client *Client) AccessRuleService {
@@ -181,9 +181,9 @@ func (s accessRuleService) Set(path string, permission string, accountName strin
181181
}
182182

183183
_, err = s.Get(path, accountName)
184-
if err != nil && err != api.ErrAccessRuleNotFound {
184+
if err != nil && !api.IsErrNotFound(err) {
185185
return nil, errio.Error(err)
186-
} else if err == api.ErrAccessRuleNotFound {
186+
} else if api.IsErrNotFound(err) {
187187
return s.create(p, perm, an)
188188
}
189189
return s.update(p, perm, an)

pkg/secrethub/client_version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package secrethub
22

33
// ClientVersion is the current version of the client
44
// Do not edit this unless you know what you're doing.
5-
const ClientVersion = "v0.23.0"
5+
const ClientVersion = "v0.26.0"

0 commit comments

Comments
 (0)