in action/k8s/uninstall.go [64:86]
func UnDeploymentController() error {
client, err := utils.GetClient()
if err != nil {
return err
}
// Assume client has already been defined
err = client.AppsV1().Deployments(Namespace).Delete(context.TODO(), DeployName, metav1.DeleteOptions{})
if err != nil {
// Check if the error is a "not found" error
if errors.IsNotFound(err) {
// The deployment does not exist, output a message instead of returning an error
tool.Logger.Errorf("Deployment '%s' does not exist in namespace '%s', no action taken.\n", DeployName, Namespace)
} else {
// For other errors, log the error and exit the program
tool.Logger.Errorf("Error deleting deployment: %s", err.Error())
}
} else {
// Successfully deleted the deployment
tool.Logger.Infof("deleted Controller %s successfully ", DeployName)
}
return nil
}