Skip to content

Commit

Permalink
Merge pull request #10583 from guangxuli/openshift_cmd
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Aug 24, 2016
2 parents 914e576 + d52ba0c commit 14a1ed8
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions pkg/cmd/cli/secrets/unlink_secret_from_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,33 +82,18 @@ func (o UnlinkSecretOptions) unlinkSecretsFromServiceAccount(serviceaccount *kap
newPullSecrets := []kapi.LocalObjectReference{}

// Check the mount secrets
for i := len(serviceaccount.Secrets) - 1; i >= 0; i-- {
found := false
for _, secretname := range rmSecretNames.List() {
if secretname == serviceaccount.Secrets[i].Name {
found = true
// Skip adding this to the updated list
}
}

if !found {
for _, secret := range serviceaccount.Secrets {
if !rmSecretNames.Has(secret.Name) {
// Copy this back in, since it doesn't match the ones we're removing
newMountSecrets = append(newMountSecrets, serviceaccount.Secrets[i])
newMountSecrets = append(newMountSecrets, secret)
}
}

// Check the image pull secrets
for i := len(serviceaccount.ImagePullSecrets) - 1; i >= 0; i-- {
found := false
for _, secretname := range rmSecretNames.List() {
if secretname == serviceaccount.ImagePullSecrets[i].Name {
found = true
// Skip adding this to the updated list
}
}
if !found {
for _, imagePullSecret := range serviceaccount.ImagePullSecrets {
if !rmSecretNames.Has(imagePullSecret.Name) {
// Copy this back in, since it doesn't match the one we're removing
newPullSecrets = append(newPullSecrets, serviceaccount.ImagePullSecrets[i])
newPullSecrets = append(newPullSecrets, imagePullSecret)
}
}

Expand Down

0 comments on commit 14a1ed8

Please sign in to comment.