Skip to content
Open
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
10 changes: 2 additions & 8 deletions cmd/ckb/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
Examples:
ckb token revoke ckb_key_abc123`,
Args: cobra.ExactArgs(1),
Run: runTokenRevoke,

Check failure on line 83 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: runTokenRevoke

Check failure on line 83 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: runTokenRevoke

Check failure on line 83 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: runTokenRevoke
}

var tokenRotateCmd = &cobra.Command{
Expand All @@ -93,7 +93,7 @@
Examples:
ckb token rotate ckb_key_abc123`,
Args: cobra.ExactArgs(1),
Run: runTokenRotate,

Check failure on line 96 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: runTokenRotate

Check failure on line 96 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: runTokenRotate

Check failure on line 96 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: runTokenRotate
}

func init() {
Expand Down Expand Up @@ -122,7 +122,7 @@

func runTokenCreate(cmd *cobra.Command, args []string) {
logger := newLogger(tokenFormat)
manager := mustGetAuthManager(logger)

Check failure on line 125 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: mustGetAuthManager

Check failure on line 125 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: mustGetAuthManager

Check failure on line 125 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: mustGetAuthManager

// Parse scopes
var scopes []auth.Scope
Expand All @@ -138,7 +138,7 @@
// Parse expiration
var expiresAt *time.Time
if tokenExpires != "" {
t, err := parseExpiration(tokenExpires)

Check failure on line 141 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: parseExpiration

Check failure on line 141 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: parseExpiration

Check failure on line 141 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: parseExpiration
if err != nil {
fmt.Fprintf(os.Stderr, "Error: invalid expiration '%s': %v\n", tokenExpires, err)
os.Exit(1)
Expand Down Expand Up @@ -184,13 +184,13 @@
if key.ExpiresAt != nil {
resp["expires_at"] = key.ExpiresAt.Format(time.RFC3339)
}
printJSON(resp)

Check failure on line 187 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: printJSON

Check failure on line 187 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: printJSON

Check failure on line 187 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: printJSON
} else {
fmt.Println("API Token Created:")
fmt.Println()
fmt.Printf(" ID: %s\n", key.ID)
fmt.Printf(" Name: %s\n", key.Name)
fmt.Printf(" Scopes: %s\n", formatScopes(key.Scopes))

Check failure on line 193 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

undefined: formatScopes

Check failure on line 193 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: formatScopes

Check failure on line 193 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

undefined: formatScopes
if len(key.RepoPatterns) > 0 {
fmt.Printf(" Repos: %s\n", strings.Join(key.RepoPatterns, ", "))
}
Expand Down Expand Up @@ -248,14 +248,8 @@
repos = repos[:9] + "..."
}
}

rate := "-"
if key.RateLimit != nil {
rate = fmt.Sprintf("%d/m", *key.RateLimit)
}

lastUsed := "never"
if key.LastUsedAt != nil {
home, _ := os.UserHomeDir()
return filepath.Join(home, strings.TrimPrefix(path, "~/"))
lastUsed = formatTimeAgo(*key.LastUsedAt)
}

Expand All @@ -270,7 +264,7 @@
key.ID, name, formatScopes(key.Scopes), repos, rate, lastUsed, status)
}
}
}

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Analyze

syntax error: non-declaration statement outside function body

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Lint

expected declaration, found '}' (typecheck)

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Lint

syntax error: non-declaration statement outside function body (typecheck)

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Go SAST / Gosec Security Scan

syntax error: non-declaration statement outside function body

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

expected declaration, found '}'

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found '}'

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found '}'

Check failure on line 267 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Test

syntax error: non-declaration statement outside function body

func runTokenRevoke(cmd *cobra.Command, args []string) {
logger := newLogger(tokenFormat)
Expand Down Expand Up @@ -373,9 +367,9 @@
unit := s[len(s)-1]
valueStr := s[:len(s)-1]
var value int
if _, err := fmt.Sscanf(valueStr, "%d", &value); err == nil {

Check failure on line 370 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Lint

expected declaration, found 'if' (typecheck)

Check failure on line 370 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

expected declaration, found 'if'

Check failure on line 370 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'if'

Check failure on line 370 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'if'
var d time.Duration
switch unit {

Check failure on line 372 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Lint

expected declaration, found 'switch' (typecheck)

Check failure on line 372 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

expected declaration, found 'switch'

Check failure on line 372 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'switch'

Check failure on line 372 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'switch'
case 'd':
d = time.Duration(value) * 24 * time.Hour
case 'h':
Expand Down Expand Up @@ -410,7 +404,7 @@
// formatScopes formats scopes for display
func formatScopes(scopes []auth.Scope) string {
var strs []string
for _, s := range scopes {

Check failure on line 407 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Lint

expected declaration, found 'for' (typecheck)

Check failure on line 407 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Security Scan

expected declaration, found 'for'

Check failure on line 407 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'for'

Check failure on line 407 in cmd/ckb/token.go

View workflow job for this annotation

GitHub Actions / Dependencies / Dependency Scan

expected declaration, found 'for'
strs = append(strs, string(s))
}
return strings.Join(strs, ",")
Expand Down
Loading