@@ -113,6 +113,7 @@ type (
113
113
RuntimeName string
114
114
Timeout time.Duration
115
115
CloneOpts * git.CloneOptions
116
+ IscCloneOpts * git.CloneOptions
116
117
KubeFactory kube.Factory
117
118
SkipChecks bool
118
119
Force bool
@@ -455,6 +456,12 @@ func runtimeUninstallCommandPreRunHandler(cmd *cobra.Command, args []string, opt
455
456
return err
456
457
}
457
458
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
+
458
465
return nil
459
466
}
460
467
@@ -1509,6 +1516,11 @@ func NewRuntimeUninstallCommand() *cobra.Command {
1509
1516
1510
1517
createAnalyticsReporter (ctx , reporter .UninstallFlow , opts .DisableTelemetry )
1511
1518
1519
+ opts .IscCloneOpts = & git.CloneOptions {
1520
+ FS : fs .Create (memfs .New ()),
1521
+ CreateIfNotExist : false ,
1522
+ }
1523
+
1512
1524
err := runtimeUninstallCommandPreRunHandler (cmd , args , & opts )
1513
1525
handleCliStep (reporter .UninstallPhasePreCheckFinish , "Finished pre run checks" , err , true , false )
1514
1526
if err != nil {
@@ -1532,7 +1544,12 @@ func NewRuntimeUninstallCommand() *cobra.Command {
1532
1544
}
1533
1545
1534
1546
opts .Timeout = store .Get ().WaitTimeout
1547
+
1548
+ inferProviderFromRepo (opts .IscCloneOpts )
1549
+ opts .IscCloneOpts .Auth = opts .CloneOpts .Auth
1550
+ opts .IscCloneOpts .Progress = opts .CloneOpts .Progress
1535
1551
opts .CloneOpts .Parse ()
1552
+ opts .IscCloneOpts .Parse ()
1536
1553
return nil
1537
1554
},
1538
1555
RunE : func (cmd * cobra.Command , _ []string ) error {
@@ -1607,6 +1624,12 @@ func RunRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
1607
1624
return err
1608
1625
}
1609
1626
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
+
1610
1633
err = deleteRuntimeFromPlatform (ctx , opts )
1611
1634
handleCliStep (reporter .UninstallStepDeleteRuntimeFromPlatform , "Deleting runtime from platform" , err , false , true )
1612
1635
if err != nil {
@@ -1732,6 +1755,32 @@ func getApplicationChecklistState(name string, a *argocdv1alpha1.Application, ru
1732
1755
return state , []string {name , status }
1733
1756
}
1734
1757
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
+
1735
1784
func deleteRuntimeFromPlatform (ctx context.Context , opts * RuntimeUninstallOptions ) error {
1736
1785
log .G (ctx ).Infof ("Deleting runtime \" %s\" from the platform" , opts .RuntimeName )
1737
1786
_ , err := cfConfig .NewClient ().V2 ().Runtime ().Delete (ctx , opts .RuntimeName )
0 commit comments