-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prune unneeded resources post
plural up
(#523)
We use helm_releases and set up a largely unnecessary `apps` stack as part of `plural up`. We can just eliminate them to save complexity once the management cluster is up, and it will also make it easier to move the management cluster into a sack seamlessly.
- Loading branch information
1 parent
70f9395
commit 16cf84c
Showing
4 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package up | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/pluralsh/plural-cli/pkg/utils" | ||
"github.com/pluralsh/plural-cli/pkg/utils/git" | ||
) | ||
|
||
func (ctx *Context) Prune() error { | ||
utils.Highlight("\nCleaning up unneeded resources...\n\n") | ||
repoRoot, err := git.Root() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
toRemove := []string{ | ||
"null_resource.console", | ||
"helm_release.certmanager", | ||
"helm_release.flux", | ||
"helm_release.runtime", | ||
"helm_release.console", | ||
} | ||
|
||
for _, field := range toRemove { | ||
if err := stateRm("./terraform/mgmt", field); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if err := os.Remove("./terraform/mgmt/console.tf"); err != nil { | ||
return err | ||
} | ||
|
||
_ = os.RemoveAll("./terraform/apps") | ||
ctx.Cleanup() | ||
|
||
return git.Sync(repoRoot, "Post-setup resource cleanup", true) | ||
} | ||
|
||
func stateRm(dir, field string) error { | ||
cmd := exec.Command("terraform", "state", "rm", field) | ||
cmd.Dir = dir | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
return cmd.Run() | ||
} |