@@ -113,6 +113,7 @@ type (
113113 RuntimeName string
114114 Timeout time.Duration
115115 CloneOpts * git.CloneOptions
116+ IscCloneOpts * git.CloneOptions
116117 KubeFactory kube.Factory
117118 SkipChecks bool
118119 Force bool
@@ -455,6 +456,12 @@ func runtimeUninstallCommandPreRunHandler(cmd *cobra.Command, args []string, opt
455456 return err
456457 }
457458
459+ opts .IscCloneOpts .Repo , err = getIscRepo (cmd .Context ())
460+ handleCliStep (reporter .UninstallStepPreCheckGetIscRepo , "Getting internal shared config repo" , err , true , false )
461+ if err != nil {
462+ return err
463+ }
464+
458465 return nil
459466}
460467
@@ -1509,6 +1516,11 @@ func NewRuntimeUninstallCommand() *cobra.Command {
15091516
15101517 createAnalyticsReporter (ctx , reporter .UninstallFlow , opts .DisableTelemetry )
15111518
1519+ opts .IscCloneOpts = & git.CloneOptions {
1520+ FS : fs .Create (memfs .New ()),
1521+ CreateIfNotExist : false ,
1522+ }
1523+
15121524 err := runtimeUninstallCommandPreRunHandler (cmd , args , & opts )
15131525 handleCliStep (reporter .UninstallPhasePreCheckFinish , "Finished pre run checks" , err , true , false )
15141526 if err != nil {
@@ -1532,7 +1544,12 @@ func NewRuntimeUninstallCommand() *cobra.Command {
15321544 }
15331545
15341546 opts .Timeout = store .Get ().WaitTimeout
1547+
1548+ inferProviderFromRepo (opts .IscCloneOpts )
1549+ opts .IscCloneOpts .Auth = opts .CloneOpts .Auth
1550+ opts .IscCloneOpts .Progress = opts .CloneOpts .Progress
15351551 opts .CloneOpts .Parse ()
1552+ opts .IscCloneOpts .Parse ()
15361553 return nil
15371554 },
15381555 RunE : func (cmd * cobra.Command , _ []string ) error {
@@ -1607,6 +1624,12 @@ func RunRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
16071624 return err
16081625 }
16091626
1627+ err = removeRuntimeIsc (ctx , opts )
1628+ handleCliStep (reporter .UninstallStepRemoveRuntimeIsc , "Removing runtime ISC" , err , false , true )
1629+ if err != nil {
1630+ return fmt .Errorf ("failed to remove runtime isc: %w" , err )
1631+ }
1632+
16101633 err = deleteRuntimeFromPlatform (ctx , opts )
16111634 handleCliStep (reporter .UninstallStepDeleteRuntimeFromPlatform , "Deleting runtime from platform" , err , false , true )
16121635 if err != nil {
@@ -1732,6 +1755,32 @@ func getApplicationChecklistState(name string, a *argocdv1alpha1.Application, ru
17321755 return state , []string {name , status }
17331756}
17341757
1758+ func removeRuntimeIsc (ctx context.Context , opts * RuntimeUninstallOptions ) error {
1759+ if opts .IscCloneOpts .Repo == "" {
1760+ return nil
1761+ }
1762+
1763+ log .G (ctx ).Info ("removing runtime isc" )
1764+
1765+ r , fs , err := opts .IscCloneOpts .GetRepo (ctx )
1766+ if err != nil {
1767+ return fmt .Errorf ("failed to clone isc repo. error: %w" , err )
1768+ }
1769+
1770+ err = billyUtils .RemoveAll (fs , fs .Join (store .Get ().IscRuntimesDir , opts .RuntimeName ))
1771+ if err != nil {
1772+ return fmt .Errorf ("failed to remove runtime dir '%s' from shared config repo. error: %w" , opts .RuntimeName , err )
1773+ }
1774+
1775+ pushMsg := fmt .Sprintf ("Removing runtime dir '%s'" , opts .RuntimeName )
1776+ err = apu .PushWithMessage (ctx , r , pushMsg )
1777+ if err != nil {
1778+ return fmt .Errorf ("failed to push to git while removing runtime '%s' dir: %w" , opts .RuntimeName , err )
1779+ }
1780+
1781+ return nil
1782+ }
1783+
17351784func deleteRuntimeFromPlatform (ctx context.Context , opts * RuntimeUninstallOptions ) error {
17361785 log .G (ctx ).Infof ("Deleting runtime \" %s\" from the platform" , opts .RuntimeName )
17371786 _ , err := cfConfig .NewClient ().V2 ().Runtime ().Delete (ctx , opts .RuntimeName )
0 commit comments