From 84316c79e22fe6a16e8ca4b8fcebcf6a8a8e21da Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Fri, 15 Apr 2022 18:00:17 +0800 Subject: [PATCH] Avoid to return the secret text from API (#530) --- pkg/models/devops/devops.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/models/devops/devops.go b/pkg/models/devops/devops.go index d67f1a5c..ea3f3832 100644 --- a/pkg/models/devops/devops.go +++ b/pkg/models/devops/devops.go @@ -318,7 +318,7 @@ func (d devopsOperator) ListPipelineObj(projectName string, query *query.Query) return *resourcesV1alpha3.DefaultList(result, query, resourcesV1alpha3.DefaultCompare(), resourcesV1alpha3.DefaultFilter()), nil } -//credentialobj in crd +// CreateCredentialObj creates a secret func (d devopsOperator) CreateCredentialObj(projectName string, secret *v1.Secret) (*v1.Secret, error) { projectObj, err := d.ksclient.DevopsV1alpha3().DevOpsProjects().Get(d.context, projectName, metav1.GetOptions{}) if err != nil { @@ -342,9 +342,7 @@ func (d devopsOperator) GetCredentialObj(projectName string, secretName string) if secret, err := d.k8sclient.CoreV1().Secrets(projectObj.Status.AdminNamespace).Get(d.context, secretName, metav1.GetOptions{}); err != nil { return nil, err } else { - // TODO Mask the secret if there is no place to use plain secret. - // return secretutil.MaskCredential(secret), nil - return secret, nil + return secretutil.MaskCredential(secret), nil } }