Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Oct 27, 2023
1 parent 9d179e6 commit 86d17e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const (
BitBucketOAuthConfigMountPath = "/che-conf/oauth/bitbucket"
BitBucketOAuthConfigPrivateKeyFileName = "private.key"
BitBucketOAuthConfigConsumerKeyFileName = "consumer.key"
GitHubOAuth = "github"
GitHubOAuthConfigMountPath = "/che-conf/oauth/github"
GitHubOAuthConfigClientIdFileName = "id"
GitHubOAuthConfigClientSecretFileName = "secret"
Expand Down
8 changes: 7 additions & 1 deletion pkg/deploy/server/server_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,13 @@ func MountBitBucketOAuthConfig(ctx *chetypes.DeployContext, deployment *appsv1.D
}

func MountGitHubOAuthConfig(ctx *chetypes.DeployContext, deployment *appsv1.Deployment) error {
secrets, err := getAllGitProviderOAuthConfigs(ctx, "github")
secrets, err := deploy.GetSecrets(ctx, map[string]string{
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: constants.OAuthScmConfiguration,
}, map[string]string{
constants.CheEclipseOrgOAuthScmServer: constants.GitHubOAuth,
})

if err != nil {
return err
}
Expand Down
22 changes: 10 additions & 12 deletions pkg/deploy/server/server_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@ func getComponentName(ctx *chetypes.DeployContext) string {
}

func getOAuthConfig(ctx *chetypes.DeployContext, oauthProvider string) (*corev1.Secret, error) {
if secrets, err := getAllGitProviderOAuthConfigs(ctx, oauthProvider); err != nil {
secrets, err := deploy.GetSecrets(ctx, map[string]string{
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: constants.OAuthScmConfiguration,
}, map[string]string{
constants.CheEclipseOrgOAuthScmServer: oauthProvider,
})

if err != nil {
return nil, err
} else if len(secrets) == 0 {
return nil, nil
} else if len(secrets) == 1 {
return &secrets[0], nil
} else {
} else if len(secrets) > 1 {
return nil, fmt.Errorf("More than 1 OAuth %s configuration secrets found", oauthProvider)
}
}

func getAllGitProviderOAuthConfigs(ctx *chetypes.DeployContext, oauthProvider string) ([]corev1.Secret, error) {
return deploy.GetSecrets(ctx, map[string]string{
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: constants.OAuthScmConfiguration,
}, map[string]string{
constants.CheEclipseOrgOAuthScmServer: oauthProvider,
})
return &secrets[0], nil
}

0 comments on commit 86d17e0

Please sign in to comment.