Skip to content

Commit 3fc2d78

Browse files
leonardoceLeonardo Cecchi
andauthored
feat: allow using a custom directory for CA certificates (#78)
Instead of using a hardcoded PATH for the custom CA certificates, this patch allows the user to select a different one. This will be useful for plugin-barman-cloud, that will directly inject the certificates in the pod using a projected volume. Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enteprisedb.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enteprisedb.com>
1 parent dbb0268 commit 3fc2d78

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

pkg/credentials/env.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,8 @@ func EnvSetBackupCloudCredentials(
6565
configuration *barmanApi.BarmanObjectStoreConfiguration,
6666
env []string,
6767
) ([]string, error) {
68-
if configuration.EndpointCA != nil && configuration.BarmanCredentials.AWS != nil {
69-
env = append(env, fmt.Sprintf("AWS_CA_BUNDLE=%s", BarmanBackupEndpointCACertificateLocation))
70-
} else if configuration.EndpointCA != nil && configuration.BarmanCredentials.Azure != nil {
71-
env = append(env, fmt.Sprintf("REQUESTS_CA_BUNDLE=%s", BarmanBackupEndpointCACertificateLocation))
72-
}
73-
74-
return envSetCloudCredentials(ctx, c, namespace, configuration, env)
68+
return EnvSetCloudCredentialsAndCertificates(
69+
ctx, c, namespace, configuration, env, BarmanBackupEndpointCACertificateLocation)
7570
}
7671

7772
// EnvSetRestoreCloudCredentials sets the AWS environment variables needed for restores
@@ -82,11 +77,26 @@ func EnvSetRestoreCloudCredentials(
8277
namespace string,
8378
configuration *barmanApi.BarmanObjectStoreConfiguration,
8479
env []string,
80+
) ([]string, error) {
81+
return EnvSetCloudCredentialsAndCertificates(
82+
ctx, c, namespace, configuration, env, BarmanRestoreEndpointCACertificateLocation)
83+
}
84+
85+
// EnvSetCloudCredentialsAndCertificates sets the AWS and Azure
86+
// environment variables needed for restores given the configuration
87+
// inside the cluster
88+
func EnvSetCloudCredentialsAndCertificates(
89+
ctx context.Context,
90+
c client.Client,
91+
namespace string,
92+
configuration *barmanApi.BarmanObjectStoreConfiguration,
93+
env []string,
94+
certificatesLocation string,
8595
) ([]string, error) {
8696
if configuration.EndpointCA != nil && configuration.BarmanCredentials.AWS != nil {
87-
env = append(env, fmt.Sprintf("AWS_CA_BUNDLE=%s", BarmanRestoreEndpointCACertificateLocation))
97+
env = append(env, fmt.Sprintf("AWS_CA_BUNDLE=%s", certificatesLocation))
8898
} else if configuration.EndpointCA != nil && configuration.BarmanCredentials.Azure != nil {
89-
env = append(env, fmt.Sprintf("REQUESTS_CA_BUNDLE=%s", BarmanRestoreEndpointCACertificateLocation))
99+
env = append(env, fmt.Sprintf("REQUESTS_CA_BUNDLE=%s", certificatesLocation))
90100
}
91101
return envSetCloudCredentials(ctx, c, namespace, configuration, env)
92102
}

0 commit comments

Comments
 (0)