Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhanushkodi committed Nov 30, 2021
1 parent 7802b8d commit 85fcdcf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (c *Command) checkForPreviousPVCs() error {

// checkForPreviousSecrets checks for the bootstrap token and returns an error if found.
func (c *Command) checkForPreviousSecrets() error {
secrets, err := c.kubernetes.CoreV1().Secrets("").List(c.Ctx, metav1.ListOptions{})
secrets, err := c.kubernetes.CoreV1().Secrets("").List(c.Ctx, metav1.ListOptions{LabelSelector: common.CLILabelKey + "=" + common.CLILabelValue})
if err != nil {
return fmt.Errorf("error listing secrets: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ func (c *Command) deletePVCs(foundReleaseName, foundReleaseNamespace string) err

// deleteSecrets deletes any secrets that have the label "managed-by" set to "consul-k8s".
func (c *Command) deleteSecrets(foundReleaseName, foundReleaseNamespace string) error {
var secretNames []string
secrets, err := c.kubernetes.CoreV1().Secrets(foundReleaseNamespace).List(c.Ctx, metav1.ListOptions{
LabelSelector: common.CLILabelKey + "=" + common.CLILabelValue,
})
Expand All @@ -392,6 +391,7 @@ func (c *Command) deleteSecrets(foundReleaseName, foundReleaseNamespace string)
c.UI.Output("No Consul secrets found.", terminal.WithSuccessStyle())
return nil
}
var secretNames []string
for _, secret := range secrets.Items {
err := c.kubernetes.CoreV1().Secrets(foundReleaseNamespace).Delete(c.Ctx, secret.Name, metav1.DeleteOptions{})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion control-plane/subcommand/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
ACLTokenSecretKey = "token"

// CLILabelKey and CLILabelValue are added to each secret on creation so the CLI knows
// which key to delete on an uninstall.
// which secrets to delete on an uninstall.
CLILabelKey = "managed-by"
CLILabelValue = "consul-k8s"
)
Expand Down

0 comments on commit 85fcdcf

Please sign in to comment.