Support Bitbucket-server oAuth2 secret config (#1618)

Add an ability to configure bitbucket-server oAuth secret for the factory flow.
pull/1620/head
Igor Vinokur 2023-02-15 16:41:16 +02:00 committed by GitHub
parent 0eb919ed15
commit d3fdf2476b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -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
}

View File

@ -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")