From d3fdf2476b794849249d41ca102430fad92df681 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Wed, 15 Feb 2023 16:41:16 +0200 Subject: [PATCH] Support Bitbucket-server oAuth2 secret config (#1618) Add an ability to configure bitbucket-server oAuth secret for the factory flow. --- pkg/deploy/server/server_deployment.go | 11 +++++------ pkg/deploy/server/server_deployment_test.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/deploy/server/server_deployment.go b/pkg/deploy/server/server_deployment.go index a2ea32903..28ef539c9 100644 --- a/pkg/deploy/server/server_deployment.go +++ b/pkg/deploy/server/server_deployment.go @@ -314,19 +314,18 @@ func MountBitBucketOAuthConfig(ctx *chetypes.DeployContext, deployment *appsv1.D } mountVolumes(deployment, secret, constants.BitBucketOAuthConfigMountPath) - mountEnv(deployment, "CHE_OAUTH1_BITBUCKET_CONSUMERKEYPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigConsumerKeyFileName) - mountEnv(deployment, "CHE_OAUTH1_BITBUCKET_PRIVATEKEYPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigPrivateKeyFileName) - if secret.Data["id"] != nil { + if secret.Data["id"] != nil && secret.Data["secret"] != nil { mountEnv(deployment, "CHE_OAUTH2_BITBUCKET_CLIENTID__FILEPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigClientIdFileName) - } - if secret.Data["secret"] != nil { mountEnv(deployment, "CHE_OAUTH2_BITBUCKET_CLIENTSECRET__FILEPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigClientSecretFileName) + } else { + mountEnv(deployment, "CHE_OAUTH1_BITBUCKET_CONSUMERKEYPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigConsumerKeyFileName) + mountEnv(deployment, "CHE_OAUTH1_BITBUCKET_PRIVATEKEYPATH", constants.BitBucketOAuthConfigMountPath+"/"+constants.BitBucketOAuthConfigPrivateKeyFileName) } oauthEndpoint := secret.Annotations[constants.CheEclipseOrgScmServerEndpoint] if oauthEndpoint != "" { - mountEnv(deployment, "CHE_OAUTH1_BITBUCKET_ENDPOINT", oauthEndpoint) + mountEnv(deployment, "CHE_OAUTH_BITBUCKET_ENDPOINT", oauthEndpoint) } return nil } diff --git a/pkg/deploy/server/server_deployment_test.go b/pkg/deploy/server/server_deployment_test.go index 4830dd2ba..9a7d02c89 100644 --- a/pkg/deploy/server/server_deployment_test.go +++ b/pkg/deploy/server/server_deployment_test.go @@ -203,7 +203,7 @@ func TestMountBitBucketServerOAuthEnvVar(t *testing.T) { value = utils.GetEnvByName("CHE_OAUTH1_BITBUCKET_PRIVATEKEYPATH", container.Env) assert.Equal(t, testCase.expectedPrivateKeyPath, value) - value = utils.GetEnvByName("CHE_OAUTH1_BITBUCKET_ENDPOINT", container.Env) + value = utils.GetEnvByName("CHE_OAUTH_BITBUCKET_ENDPOINT", container.Env) assert.Equal(t, testCase.expectedOAuthEndpoint, value) volume := test.FindVolume(deployment.Spec.Template.Spec.Volumes, "bitbucket-oauth-config")