Skip to content

Commit 8549aad

Browse files
author
Aniruddha Basak
authored
change default outputs directories (#119)
We use default directories two times. One for downloading the existing release assets from github. We were downloading it inside `tmp` directory. This commit changes it to use `.tmp` directory. Another instance we need a default output directory is to write the release assets created by csctl. We were writing to `releases` folder and this commit updates the same to use `.release` folder. This commit also updates the `.gitignore` file accordingly. Signed-off-by: Aniruddha Basak <[email protected]>
1 parent 7496484 commit 8549aad

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/cmd/create.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var createCmd = &cobra.Command{
7979

8080
func init() {
8181
createCmd.Flags().StringVarP(&mode, "mode", "m", "stable", "It defines the mode of the cluster stack manager")
82-
createCmd.Flags().StringVarP(&outputDirectory, "output", "o", "./releases", "It defines the output directory in which the release artifacts will be generated")
82+
createCmd.Flags().StringVarP(&outputDirectory, "output", "o", "./.release", "It defines the output directory in which the release artifacts will be generated")
8383
createCmd.Flags().StringVarP(&nodeImageRegistry, "node-image-registry", "r", "", "It defines the node image registry. For example oci://ghcr.io/foo/bar/node-images/staging/")
8484
}
8585

@@ -133,11 +133,11 @@ func GetCreateOptions(ctx context.Context, clusterStackPath string) (*CreateOpti
133133
createOption.Metadata.Versions.ClusterStack = "v1"
134134
createOption.Metadata.Versions.Components.ClusterAddon = "v1"
135135
} else {
136-
if err := github.DownloadReleaseAssets(ctx, latestRepoRelease, "./tmp/releases/", gc); err != nil {
136+
if err := github.DownloadReleaseAssets(ctx, latestRepoRelease, "./.tmp/release/", gc); err != nil {
137137
return nil, fmt.Errorf("failed to download release asset: %w", err)
138138
}
139139

140-
createOption.Metadata, err = clusterstack.HandleStableMode("./tmp/releases/", createOption.CurrentReleaseHash, createOption.LatestReleaseHash)
140+
createOption.Metadata, err = clusterstack.HandleStableMode("./.tmp/release/", createOption.CurrentReleaseHash, createOption.LatestReleaseHash)
141141
if err != nil {
142142
return nil, fmt.Errorf("failed to handle stable mode: %w", err)
143143
}
@@ -157,6 +157,8 @@ func GetCreateOptions(ctx context.Context, clusterStackPath string) (*CreateOpti
157157
}
158158

159159
func createAction(cmd *cobra.Command, args []string) error {
160+
defer cleanTmpDirectory()
161+
160162
if len(args) != 1 {
161163
return fmt.Errorf("please provide a valid command, create only accept one argument to path to the cluster stacks")
162164
}
@@ -324,3 +326,11 @@ func overwriteVersionInFile(chartYaml, newVersion string) error {
324326
}
325327
return nil
326328
}
329+
330+
func cleanTmpDirectory() error {
331+
if err := os.RemoveAll("./.tmp/"); err != nil {
332+
return fmt.Errorf("failed to remove tmp directory: %w", err)
333+
}
334+
335+
return nil
336+
}

0 commit comments

Comments
 (0)