Skip to content

Commit

Permalink
#29 - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
apanasiuk-el committed Nov 6, 2024
1 parent 1c0ca2f commit c4e02de
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ func (cc *ClusterCommands) deleteKubeConfigItem(itemType, itemName string) error
cc.SpecCMD = cc.kubectl("config", itemType, itemName)
cc.SpecCMD.DisableStdOut = true
if err := releaseRunner(cc).runCMD(); err != nil {
return fmt.Errorf("%s", cc.SpecCMD.StderrBuf.String())
return fmt.Errorf("%s", strings.ReplaceAll(cc.SpecCMD.StderrBuf.String(), "\n", ""))
}

zap.S().Infof("%s", cc.SpecCMD.StdoutBuf.String())
zap.S().Infof("%s", strings.ReplaceAll(cc.SpecCMD.StdoutBuf.String(), "\n", ""))

return nil
}
Expand Down Expand Up @@ -385,6 +385,18 @@ func (cc *ClusterCommands) provisionDestroyTargetCluster() error {
return err
}
}

if err := cc.deleteKubeConfigItem("delete-context", cc.Conf.Name); err != nil {
return err
}

if err := cc.deleteKubeConfigItem("delete-cluster", cc.Conf.Name); err != nil {
return err
}

if err := cc.deleteKubeConfigItem("delete-user", cc.Conf.Name); err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit c4e02de

Please sign in to comment.