diff --git a/apis/externalsecrets/v1beta1/secretsstore_infisical_types.go b/apis/externalsecrets/v1beta1/secretsstore_infisical_types.go index c1eea0a4d..8e4428f34 100644 --- a/apis/externalsecrets/v1beta1/secretsstore_infisical_types.go +++ b/apis/externalsecrets/v1beta1/secretsstore_infisical_types.go @@ -34,6 +34,9 @@ type MachineIdentityScopeInWorkspace struct { // +kubebuilder:default="/" // +optional SecretsPath string `json:"secretsPath,omitempty"` + // +kubebuilder:default=false + // +optional + Recursive bool `json:"recursive,omitempty"` // +kubebuilder:validation:Required EnvironmentSlug string `json:"environmentSlug"` // +kubebuilder:validation:Required diff --git a/config/crds/bases/external-secrets.io_clustersecretstores.yaml b/config/crds/bases/external-secrets.io_clustersecretstores.yaml index a12ccbc16..3ccc3bb45 100644 --- a/config/crds/bases/external-secrets.io_clustersecretstores.yaml +++ b/config/crds/bases/external-secrets.io_clustersecretstores.yaml @@ -3234,6 +3234,9 @@ spec: type: string projectSlug: type: string + recursive: + default: false + type: boolean secretsPath: default: / type: string diff --git a/config/crds/bases/external-secrets.io_secretstores.yaml b/config/crds/bases/external-secrets.io_secretstores.yaml index 41e2e55d8..1102a07d4 100644 --- a/config/crds/bases/external-secrets.io_secretstores.yaml +++ b/config/crds/bases/external-secrets.io_secretstores.yaml @@ -3234,6 +3234,9 @@ spec: type: string projectSlug: type: string + recursive: + default: false + type: boolean secretsPath: default: / type: string diff --git a/deploy/crds/bundle.yaml b/deploy/crds/bundle.yaml index 65bea24d2..33e153f0b 100644 --- a/deploy/crds/bundle.yaml +++ b/deploy/crds/bundle.yaml @@ -3652,6 +3652,9 @@ spec: type: string projectSlug: type: string + recursive: + default: false + type: boolean secretsPath: default: / type: string @@ -9490,6 +9493,9 @@ spec: type: string projectSlug: type: string + recursive: + default: false + type: boolean secretsPath: default: / type: string diff --git a/docs/api/spec.md b/docs/api/spec.md index 24a1618fe..28dce8462 100644 --- a/docs/api/spec.md +++ b/docs/api/spec.md @@ -5252,6 +5252,17 @@ string
recursive
+
+bool
+
+environmentSlug
string
diff --git a/docs/snippets/infisical-generic-secret-store.yaml b/docs/snippets/infisical-generic-secret-store.yaml
index c3f1e7c3b..b728b87d6 100644
--- a/docs/snippets/infisical-generic-secret-store.yaml
+++ b/docs/snippets/infisical-generic-secret-store.yaml
@@ -21,5 +21,7 @@ spec:
environmentSlug: dev # "dev", "staging", "prod", etc..
# optional
secretsPath: / # Root is "/"
+ # optional
+ recursive: true # Default is false
# optional
hostAPI: https://app.infisical.com
diff --git a/pkg/provider/infisical/api/api.go b/pkg/provider/infisical/api/api.go
index 298463c6d..706fd9a19 100644
--- a/pkg/provider/infisical/api/api.go
+++ b/pkg/provider/infisical/api/api.go
@@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "strconv"
"time"
esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
@@ -170,6 +171,7 @@ func (a *InfisicalClient) GetSecretsV3(data GetSecretsV3Request) (map[string]str
q.Add("secretPath", data.SecretPath)
q.Add("include_imports", "true")
q.Add("expandSecretReferences", "true")
+ q.Add("recursive", strconv.FormatBool(data.Recursive))
req.URL.RawQuery = q.Encode()
rawRes, err := a.do(req)
diff --git a/pkg/provider/infisical/api/api_models.go b/pkg/provider/infisical/api/api_models.go
index f45ca88b3..b1f2be2c0 100644
--- a/pkg/provider/infisical/api/api_models.go
+++ b/pkg/provider/infisical/api/api_models.go
@@ -52,6 +52,7 @@ type GetSecretByKeyV3Response struct {
type GetSecretsV3Request struct {
EnvironmentSlug string `json:"environment"`
ProjectSlug string `json:"workspaceSlug"`
+ Recursive bool `json:"recursive"`
SecretPath string `json:"secretPath"`
}
diff --git a/pkg/provider/infisical/client.go b/pkg/provider/infisical/client.go
index 1df252560..a11891da7 100644
--- a/pkg/provider/infisical/client.go
+++ b/pkg/provider/infisical/client.go
@@ -49,8 +49,8 @@ func (p *Provider) GetSecret(ctx context.Context, ref esv1beta1.ExternalSecretDa
secret, err := p.apiClient.GetSecretByKeyV3(api.GetSecretByKeyV3Request{
EnvironmentSlug: p.apiScope.EnvironmentSlug,
ProjectSlug: p.apiScope.ProjectSlug,
- SecretPath: p.apiScope.SecretPath,
SecretKey: ref.Key,
+ SecretPath: p.apiScope.SecretPath,
})
if err != nil {
@@ -104,6 +104,7 @@ func (p *Provider) GetAllSecrets(ctx context.Context, ref esv1beta1.ExternalSecr
EnvironmentSlug: p.apiScope.EnvironmentSlug,
ProjectSlug: p.apiScope.ProjectSlug,
SecretPath: p.apiScope.SecretPath,
+ Recursive: p.apiScope.Recursive,
})
if err != nil {
return nil, err
@@ -144,11 +145,12 @@ func (p *Provider) Validate() (esv1beta1.ValidationResult, error) {
_, err := p.apiClient.GetSecretsV3(api.GetSecretsV3Request{
EnvironmentSlug: p.apiScope.EnvironmentSlug,
ProjectSlug: p.apiScope.ProjectSlug,
+ Recursive: p.apiScope.Recursive,
SecretPath: p.apiScope.SecretPath,
})
if err != nil {
- return esv1beta1.ValidationResultError, fmt.Errorf("cannot read secrets with provided project scope project:%s environment:%s secret-path:%s, %w", p.apiScope.ProjectSlug, p.apiScope.EnvironmentSlug, p.apiScope.SecretPath, err)
+ return esv1beta1.ValidationResultError, fmt.Errorf("cannot read secrets with provided project scope project:%s environment:%s secret-path:%s recursive:%t, %w", p.apiScope.ProjectSlug, p.apiScope.EnvironmentSlug, p.apiScope.SecretPath, p.apiScope.Recursive, err)
}
return esv1beta1.ValidationResultReady, nil
diff --git a/pkg/provider/infisical/provider.go b/pkg/provider/infisical/provider.go
index 3fd7f90ec..28490284f 100644
--- a/pkg/provider/infisical/provider.go
+++ b/pkg/provider/infisical/provider.go
@@ -41,9 +41,10 @@ type Provider struct {
}
type InfisicalClientScope struct {
- SecretPath string
- ProjectSlug string
EnvironmentSlug string
+ ProjectSlug string
+ Recursive bool
+ SecretPath string
}
// https://github.com/external-secrets/external-secrets/issues/644
@@ -93,9 +94,10 @@ func (p *Provider) NewClient(ctx context.Context, store esv1beta1.GenericStore,
return &Provider{
apiClient: apiClient,
apiScope: &InfisicalClientScope{
- SecretPath: infisicalSpec.SecretsScope.SecretsPath,
- ProjectSlug: infisicalSpec.SecretsScope.ProjectSlug,
EnvironmentSlug: infisicalSpec.SecretsScope.EnvironmentSlug,
+ ProjectSlug: infisicalSpec.SecretsScope.ProjectSlug,
+ Recursive: infisicalSpec.SecretsScope.Recursive,
+ SecretPath: infisicalSpec.SecretsScope.SecretsPath,
},
}, nil
}