Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54.2
skip-pkg-cache: true # golangci-lint-action caching conflicts with the setup-go cache and `go get` above. See https://github.com/golangci/golangci-lint-action/issues/23
2 changes: 1 addition & 1 deletion cmd/getchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func GetChange(ctx context.Context, ready chan bool) int {
case "json":
b, err := json.MarshalIndent(response.Msg.Change.ToMap(), "", " ")
if err != nil {
log.Errorf("Error rendering bookmark: %v", err)
log.Errorf("Error rendering change: %v", err)
return 1
}

Expand Down
27 changes: 10 additions & 17 deletions cmd/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func InvitesRevoke(ctx context.Context) int {
email := viper.GetString("email")

if email == "" {
log.Error("You must specify an email address to revoke using --email")
log.WithContext(ctx).Error("You must specify an email address to revoke using --email")
return 1
}

Expand All @@ -127,9 +127,8 @@ func InvitesRevoke(ctx context.Context) int {

// Authenticate
ctx, err = ensureToken(ctx, []string{"account:write"})

if err != nil {
log.Error(err)
log.WithContext(ctx).WithError(err).Error("failed to ensure token")
return 1
}

Expand All @@ -141,13 +140,12 @@ func InvitesRevoke(ctx context.Context) int {
Email: email,
},
})

if err != nil {
log.Error(err)
log.WithContext(ctx).WithError(err).Error("failed to revoke invite")
return 1
}

log.WithFields(log.Fields{"email": email}).Info("Invite revoked successfully")
log.WithContext(ctx).WithFields(log.Fields{"email": email}).Info("Invite revoked successfully")

return 0
}
Expand All @@ -156,9 +154,8 @@ func InvitesCreate(ctx context.Context) int {
var err error

emails := viper.GetStringSlice("emails")

if len(emails) == 0 {
log.Error("You must specify at least one email address to invite using --emails")
log.WithContext(ctx).Error("You must specify at least one email address to invite using --emails")
return 1
}

Expand All @@ -169,9 +166,8 @@ func InvitesCreate(ctx context.Context) int {

// Authenticate
ctx, err = ensureToken(ctx, []string{"account:write"})

if err != nil {
log.Error(err)
log.WithContext(ctx).WithError(err).Error("failed to ensure token")
return 1
}

Expand All @@ -183,13 +179,12 @@ func InvitesCreate(ctx context.Context) int {
Emails: emails,
},
})

if err != nil {
log.Error(err)
log.WithContext(ctx).WithError(err).Error("failed to create invite")
return 1
}

log.WithFields(log.Fields{"emails": emails}).Info("Invites created successfully")
log.WithContext(ctx).WithFields(log.Fields{"emails": emails}).Info("Invites created successfully")

return 0
}
Expand All @@ -204,19 +199,17 @@ func InvitesList(ctx context.Context) int {

// Authenticate
ctx, err = ensureToken(ctx, []string{"account:read"})

if err != nil {
log.Error(err)
log.WithError(err).Error("failed to ensure token")
return 1
}

client := AuthenticatedInviteClient(ctx)

// List all invites
resp, err := client.ListInvites(ctx, &connect.Request[sdp.ListInvitesRequest]{})

if err != nil {
log.Error(err)
log.WithContext(ctx).WithError(err).Error("failed to list invites")
return 1
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ func ensureToken(ctx context.Context, requiredScopes []string) (context.Context,
handler := func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

queryParts, _ := url.ParseQuery(r.URL.RawQuery)
queryParts, err := url.ParseQuery(r.URL.RawQuery)
if err != nil {
log.WithContext(ctx).WithError(err).WithFields(log.Fields{
"url": r.URL,
}).Error("Failed to parse url")
}

// Use the authorization code that is pushed to the redirect
// URL.
Expand Down