Skip to content

Commit

Permalink
Add path for cleaning up config when deleting env (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekgogia authored May 17, 2022
1 parent c220260 commit 26ce6d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions substrate/pkg/controller/substrate/cluster/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
)

const (
clusterConfigDir = ".kit/env"
kubeconfigPath = "/etc/kubernetes"
kubeconfigFile = "etc/kubernetes/admin.conf"
certPKIPath = "/etc/kubernetes/pki"
Expand Down Expand Up @@ -129,6 +130,13 @@ func (c *Config) Delete(ctx context.Context, substrate *v1alpha1.Substrate) (rec
} else {
logging.FromContext(ctx).Infof("Deleted S3 bucket %s", aws.StringValue(discovery.Name(substrate)))
}
if c.clusterConfigPath == "" {
home, err := os.UserHomeDir()
if err != nil {
return reconcile.Result{}, fmt.Errorf("finding HOME dir %v", err)
}
c.clusterConfigPath = filepath.Join(home, clusterConfigDir)
}
return reconcile.Result{}, os.RemoveAll(path.Join(c.clusterConfigPath, aws.StringValue(discovery.Name(substrate))))
}

Expand Down Expand Up @@ -335,9 +343,9 @@ func (c *Config) ensureKitEnvDir() error {
if err != nil {
return fmt.Errorf("finding HOME dir %v", err)
}
c.clusterConfigPath = filepath.Join(home, ".kit/env")
c.clusterConfigPath = filepath.Join(home, clusterConfigDir)
if err := os.MkdirAll(c.clusterConfigPath, 0755); err != nil {
return fmt.Errorf("creating .kit/env dir %v", err)
return fmt.Errorf("creating cluster config dir %v", err)
}
return nil
}
Expand Down

0 comments on commit 26ce6d0

Please sign in to comment.