Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify Backstage Token in CMD #126

Merged
merged 2 commits into from
Jun 24, 2024
Merged
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
12 changes: 12 additions & 0 deletions cmd/catalog-importer/cmd/backstage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type BackstageOptions struct {
APIEndpoint string
APIKey string
BackstageEndpoint string
BackstageToken string
BackstageSignJWT bool
}

func (opt *BackstageOptions) Bind(cmd *kingpin.CmdClause) *BackstageOptions {
Expand All @@ -30,6 +32,14 @@ func (opt *BackstageOptions) Bind(cmd *kingpin.CmdClause) *BackstageOptions {
Default("http://localhost:7007/api/catalog/entities").
Envar("BACKSTAGE_ENDPOINT").
StringVar(&opt.BackstageEndpoint)
cmd.Flag("backstage-token", "Token of the Backstage entries API. Optional").
Default("").
Envar("BACKSTAGE_TOKEN").
StringVar(&opt.BackstageToken)
cmd.Flag("backstage-sign-jwt", "Whether to sign the provided Backstage token into a JWT. Defaults to true").
Default("true").
Envar("BACKSTAGE_SIGN_JWT").
BoolVar(&opt.BackstageSignJWT)

return opt
}
Expand All @@ -52,6 +62,8 @@ func (opt *BackstageOptions) Run(ctx context.Context, logger kitlog.Logger) erro
{
Backstage: &source.SourceBackstage{
Endpoint: opt.BackstageEndpoint,
Token: source.Credential(opt.BackstageToken),
SignJWT: &opt.BackstageSignJWT,
},
},
}
Expand Down
Loading