Skip to content

Commit

Permalink
Specify Backstage Token in CMD (#126)
Browse files Browse the repository at this point in the history
Issue #69

We provide the ability to specify a Backstage URL and Token via our
Jsonnet configuration ([docs
here](https://github.com/incident-io/catalog-importer/blob/master/docs/sources.md#backstage)),
however not via the command line.

This PR provides parity between the two
  • Loading branch information
louisheath authored Jun 24, 2024
1 parent bae017b commit 104aec3
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit 104aec3

Please sign in to comment.