Skip to content

Commit

Permalink
add persist flag to uninstall command
Browse files Browse the repository at this point in the history
  • Loading branch information
colesnodgrass committed Jun 11, 2024
1 parent df87f0a commit 18a5816
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions internal/cmd/local/local/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,20 @@ func (c *Command) Install(ctx context.Context, user, pass string) error {

// Create minio PV and PVC
if _, err := c.k8s.TestClientSet().CoreV1().PersistentVolumes().Create(ctx, pv(airbyteNamespace, "airbyte-minio-pv"), metav1.CreateOptions{}); err != nil {
pterm.Error.Printfln("Failed to create airbyte persistent volume: %s", err.Error())
pterm.Error.Printfln("Failed to create persistent volume: %s", err.Error())
}

if _, err := c.k8s.TestClientSet().CoreV1().PersistentVolumeClaims(airbyteNamespace).Create(ctx, pvc("airbyte-minio-pv-claim-airbyte-minio-0", "airbyte-minio-pv"), metav1.CreateOptions{}); err != nil {
pterm.Error.Printfln("Failed to create airbyte persistent volume claim: %s", err.Error())
pterm.Error.Printfln("Failed to create persistent volume claim: %s", err.Error())
}

// Create database PV and PVC
if _, err := c.k8s.TestClientSet().CoreV1().PersistentVolumes().Create(ctx, pv(airbyteNamespace, "airbyte-volume-db"), metav1.CreateOptions{}); err != nil {
pterm.Error.Printfln("Failed to create airbyte persistent volume: %s", err.Error())
pterm.Error.Printfln("Failed to create persistent volume: %s", err.Error())
}

if _, err := c.k8s.TestClientSet().CoreV1().PersistentVolumeClaims(airbyteNamespace).Create(ctx, pvc("airbyte-volume-db-airbyte-db-0", "airbyte-volume-db"), metav1.CreateOptions{}); err != nil {
pterm.Error.Printfln("Failed to create airbyte persistent volume claim: %s", err.Error())
pterm.Error.Printfln("Failed to create persistent volume claim: %s", err.Error())
}

var telUser string
Expand Down Expand Up @@ -478,7 +478,12 @@ func (c *Command) handleBasicAuthSecret(ctx context.Context, user, pass string)
}

// Uninstall handles the uninstallation of Airbyte.
func (c *Command) Uninstall(ctx context.Context) error {
func (c *Command) Uninstall(ctx context.Context, persist bool) error {
// if not removing persisted data, then this is a no-op
if !persist {
return nil
}

{
c.spinner.UpdateText(fmt.Sprintf("Verifying %s Helm Chart installation status", airbyteChartName))

Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/local/local_uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
func NewCmdUninstall(provider k8s.Provider) *cobra.Command {
spinner := &pterm.DefaultSpinner

var flagPersist bool

cmd := &cobra.Command{
Use: "uninstall",
Short: "Uninstall Airbyte locally",
Expand Down Expand Up @@ -54,7 +56,7 @@ func NewCmdUninstall(provider k8s.Provider) *cobra.Command {
pterm.Warning.Printfln("Failed to initialize 'local' command\nUninstallation attempt will continue")
pterm.Debug.Printfln("Initialization of 'local' failed with %s", err.Error())
} else {
if err := lc.Uninstall(cmd.Context()); err != nil {
if err := lc.Uninstall(cmd.Context(), flagPersist); err != nil {
pterm.Warning.Printfln("could not complete uninstall: %s", err.Error())
pterm.Warning.Println("will still attempt to uninstall the cluster")
}
Expand All @@ -74,5 +76,7 @@ func NewCmdUninstall(provider k8s.Provider) *cobra.Command {
},
}

cmd.Flags().BoolVar(&flagPersist, "persist", false, "remove persisted data")

return cmd
}

0 comments on commit 18a5816

Please sign in to comment.