Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print warning when deletion of kubeconfig fails #174

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion delete/vcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
infrastructure "github.com/ninech/apis/infrastructure/v1alpha1"
"github.com/ninech/nctl/api"
"github.com/ninech/nctl/api/config"
"github.com/ninech/nctl/internal/format"
"k8s.io/apimachinery/pkg/types"
)

Expand All @@ -30,7 +31,10 @@ func (vc *vclusterCmd) Run(ctx context.Context, client *api.Client) error {

d := newDeleter(cluster, "vcluster", cleanup(
func(client *api.Client) error {
return config.RemoveClusterFromKubeConfig(client.KubeconfigPath, config.ContextName(cluster))
if err := config.RemoveClusterFromKubeConfig(client.KubeconfigPath, config.ContextName(cluster)); err != nil {
format.PrintWarningf("unable to remove cluster from kubeconfig: %s\n", err)
}
return nil
}))

if err := d.deleteResource(ctx, client, vc.WaitTimeout, vc.Wait, vc.Force); err != nil {
Expand Down