Skip to content

Commit

Permalink
Merge pull request #111 from ninech/print-access-token
Browse files Browse the repository at this point in the history
feat: add auth print-access-token command
  • Loading branch information
ctrox committed Jun 5, 2024
2 parents 542610b + 4c84e4b commit fcd8077
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 8 additions & 7 deletions auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package auth

type Cmd struct {
Login LoginCmd `cmd:"" help:"Login to nineapis.ch."`
Logout LogoutCmd `cmd:"" help:"Logout from nineapis.ch."`
Cluster ClusterCmd `cmd:"" help:"Authenticate with Kubernetes Cluster."`
OIDC OIDCCmd `cmd:"" help:"Perform interactive OIDC login." hidden:""`
SetProject SetProjectCmd `cmd:"" help:"Set the default project to be used."`
SetOrg SetOrgCmd `cmd:"" help:"Set the organization to be used."`
Whoami WhoAmICmd `cmd:"" help:"Show who you are logged in as, your active organization and all your available organizations."`
Login LoginCmd `cmd:"" help:"Login to nineapis.ch."`
Logout LogoutCmd `cmd:"" help:"Logout from nineapis.ch."`
Cluster ClusterCmd `cmd:"" help:"Authenticate with Kubernetes Cluster."`
OIDC OIDCCmd `cmd:"" help:"Perform interactive OIDC login." hidden:""`
SetProject SetProjectCmd `cmd:"" help:"Set the default project to be used."`
SetOrg SetOrgCmd `cmd:"" help:"Set the organization to be used."`
Whoami WhoAmICmd `cmd:"" help:"Show who you are logged in as, your active organization and all your available organizations."`
PrintAccessToken PrintAccessTokenCmd `cmd:"" help:"Print short-lived access token to authenticate against the API to stdout and exit."`
}
15 changes: 15 additions & 0 deletions auth/print_access_token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package auth

import (
"context"
"fmt"

"github.com/ninech/nctl/api"
)

type PrintAccessTokenCmd struct{}

func (o *PrintAccessTokenCmd) Run(ctx context.Context, client *api.Client) error {
fmt.Println(client.Token)
return nil
}

0 comments on commit fcd8077

Please sign in to comment.