Skip to content

Commit d0fb1d5

Browse files
committed
chore: add debug flag and pass it to the go sdk
1 parent dde85c6 commit d0fb1d5

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ func init() {
6868
rootCmd.PersistentFlags().String("client-id", "", "Client ID. Sent to the Token Issuer during the Client Credentials flow") //nolint:lll
6969
rootCmd.PersistentFlags().String("client-secret", "", "Client Secret. Sent to the Token Issuer during the Client Credentials flow") //nolint:lll
7070
rootCmd.PersistentFlags().StringArray("api-scopes", []string{}, "API Scopes (repeat option for multiple values). Used in the Client Credentials flow") //nolint:lll
71+
rootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode - can print more detailed information for debugging")
7172

73+
_ = rootCmd.Flags().MarkHidden("debug")
7274
rootCmd.MarkFlagsRequiredTogether(
7375
"api-token-issuer",
7476
"client-id",

internal/cmdutils/get-client-config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func GetClientConfig(cmd *cobra.Command) fga.ClientConfig {
4444
clientCredentialsClientID, _ := cmd.Flags().GetString("client-id")
4545
clientCredentialsClientSecret, _ := cmd.Flags().GetString("client-secret")
4646
clientCredentialsScopes, _ := cmd.Flags().GetStringArray("api-scopes")
47+
debug, _ := cmd.Flags().GetBool("debug")
4748

4849
return fga.ClientConfig{
4950
ApiUrl: apiURL,
@@ -55,5 +56,6 @@ func GetClientConfig(cmd *cobra.Command) fga.ClientConfig {
5556
ClientID: clientCredentialsClientID,
5657
ClientSecret: clientCredentialsClientSecret,
5758
APIScopes: clientCredentialsScopes,
59+
Debug: debug,
5860
}
5961
}

internal/fga/fga.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type ClientConfig struct {
4444
APIScopes []string `json:"api_scopes,omitempty"`
4545
ClientID string `json:"client_id,omitempty"`
4646
ClientSecret string `json:"client_secret,omitempty"`
47+
Debug bool `json:"debug,omitempty"`
4748
}
4849

4950
func (c ClientConfig) getCredentials() *credentials.Credentials {
@@ -85,6 +86,7 @@ func (c ClientConfig) getClientConfig() *client.ClientConfiguration {
8586
MaxRetry: MaxSdkRetry,
8687
MinWaitInMs: MinSdkWaitInMs,
8788
},
89+
Debug: c.Debug,
8890
}
8991
}
9092

0 commit comments

Comments
 (0)