Skip to content

Commit 26ce6d0

Browse files
authored
Add path for cleaning up config when deleting env (#214)
1 parent c220260 commit 26ce6d0

File tree

1 file changed

+10
-2
lines changed
  • substrate/pkg/controller/substrate/cluster

1 file changed

+10
-2
lines changed

substrate/pkg/controller/substrate/cluster/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
)
4949

5050
const (
51+
clusterConfigDir = ".kit/env"
5152
kubeconfigPath = "/etc/kubernetes"
5253
kubeconfigFile = "etc/kubernetes/admin.conf"
5354
certPKIPath = "/etc/kubernetes/pki"
@@ -129,6 +130,13 @@ func (c *Config) Delete(ctx context.Context, substrate *v1alpha1.Substrate) (rec
129130
} else {
130131
logging.FromContext(ctx).Infof("Deleted S3 bucket %s", aws.StringValue(discovery.Name(substrate)))
131132
}
133+
if c.clusterConfigPath == "" {
134+
home, err := os.UserHomeDir()
135+
if err != nil {
136+
return reconcile.Result{}, fmt.Errorf("finding HOME dir %v", err)
137+
}
138+
c.clusterConfigPath = filepath.Join(home, clusterConfigDir)
139+
}
132140
return reconcile.Result{}, os.RemoveAll(path.Join(c.clusterConfigPath, aws.StringValue(discovery.Name(substrate))))
133141
}
134142

@@ -335,9 +343,9 @@ func (c *Config) ensureKitEnvDir() error {
335343
if err != nil {
336344
return fmt.Errorf("finding HOME dir %v", err)
337345
}
338-
c.clusterConfigPath = filepath.Join(home, ".kit/env")
346+
c.clusterConfigPath = filepath.Join(home, clusterConfigDir)
339347
if err := os.MkdirAll(c.clusterConfigPath, 0755); err != nil {
340-
return fmt.Errorf("creating .kit/env dir %v", err)
348+
return fmt.Errorf("creating cluster config dir %v", err)
341349
}
342350
return nil
343351
}

0 commit comments

Comments
 (0)