parent
f281e82499
commit
2369c1d5c9
|
@ -50,8 +50,7 @@ type HatsConfig struct {
|
|||
|
||||
ConfigDir string `config:"CONFIG_DIR" default:"/config"`
|
||||
|
||||
infisicalClient *infisical.InfisicalClient
|
||||
infisicalRetrievalOpts *infisical.RetrieveSecretOptions
|
||||
infisicalClient *infisical.InfisicalClient
|
||||
}
|
||||
|
||||
func New() (*HatsConfig, error) {
|
||||
|
@ -67,9 +66,7 @@ func New() (*HatsConfig, error) {
|
|||
return cfg, fmt.Errorf("error logging in to Infisical: %w", err)
|
||||
}
|
||||
|
||||
secrets, err := cfg.infisicalClient.ListSecrets(
|
||||
infisical.WithWorkspaceID(cfg.InfisicalProjectID),
|
||||
infisical.WithEnvironment(cfg.InfisicalEnvironment))
|
||||
secrets, err := cfg.infisicalClient.ListSecrets(cfg.InfisicalProjectID, cfg.InfisicalEnvironment)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("error getting Infisical secrets: %w", err)
|
||||
}
|
||||
|
@ -145,7 +142,7 @@ func (c *HatsConfig) GetCustomSetting(name string, defaultValue string) string {
|
|||
}
|
||||
|
||||
if c.InfisicalConfigured() {
|
||||
secret, _ := c.infisicalClient.GetSecret(name, c.infisicalRetrievalOpts)
|
||||
secret, _ := c.infisicalClient.GetSecret(name, c.InfisicalProjectID, c.InfisicalEnvironment)
|
||||
if secret.SecretValue != "" {
|
||||
returnValue = secret.SecretValue
|
||||
}
|
||||
|
|
|
@ -70,8 +70,9 @@ func (c *InfisicalClient) CheckToken() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *InfisicalClient) ListSecrets(optFuncs ...RetrieveSecretOptionFunc) ([]Secret, error) {
|
||||
func (c *InfisicalClient) ListSecrets(workspaceId string, environment string, optFuncs ...RetrieveSecretOptionFunc) ([]Secret, error) {
|
||||
opts := DefaultRetrieveSecretOptions()
|
||||
optFuncs = append(optFuncs, WithWorkspaceID(workspaceId), WithEnvironment(environment))
|
||||
for _, f := range optFuncs {
|
||||
f(opts)
|
||||
}
|
||||
|
@ -96,7 +97,13 @@ func (c *InfisicalClient) ListSecrets(optFuncs ...RetrieveSecretOptionFunc) ([]S
|
|||
return result.Secrets, nil
|
||||
}
|
||||
|
||||
func (c *InfisicalClient) GetSecret(name string, opts *RetrieveSecretOptions) (Secret, error) {
|
||||
func (c *InfisicalClient) GetSecret(name string, workspaceId string, environment string, optFuncs ...RetrieveSecretOptionFunc) (Secret, error) {
|
||||
opts := DefaultRetrieveSecretOptions()
|
||||
optFuncs = append(optFuncs, WithWorkspaceID(workspaceId), WithEnvironment(environment))
|
||||
for _, f := range optFuncs {
|
||||
f(opts)
|
||||
}
|
||||
|
||||
err := c.CheckToken()
|
||||
if err != nil {
|
||||
return Secret{}, err
|
||||
|
|
Loading…
Reference in New Issue