File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,8 @@ Show fingerprint for a tenancy
42
42
43
43
> oci-api-keygen list [ tenancy]
44
44
45
+ ** Delete**
46
+
47
+ Delete all the artifacts for a tenancy and remove it from the config file.
48
+
49
+ > oci-api-keygen delete [ tenancy]
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ import (
37
37
38
38
// deleteCmd represents the delete command
39
39
var deleteCmd = & cobra.Command {
40
- Use : "delete" ,
40
+ Use : "delete [tenancy]" ,
41
+ Args : cobra .ExactArgs (1 ),
41
42
Short : "Delete a tenancy and associated files" ,
42
43
Long : `Use to delete and remove the files of a tenancy that may no
43
44
longer be necessary.
@@ -47,7 +48,22 @@ longer be necessary.
47
48
there are no backups made, so make sure you want to do this before
48
49
you actually do it.` ,
49
50
Run : func (cmd * cobra.Command , args []string ) {
50
- fmt .Println ("delete called" )
51
+ t := args [0 ]
52
+ idx := - 1
53
+
54
+ for i , a := range cfg .ApiKeys {
55
+ if a .Tenancy == t {
56
+ idx = i
57
+ }
58
+ }
59
+
60
+ if idx < 0 {
61
+ fmt .Printf ("tenancy not found : %s\n " , t )
62
+ } else {
63
+ cfg .ApiKeys = append (cfg .ApiKeys [:idx ], cfg .ApiKeys [idx + 1 :]... )
64
+ cfg .SaveConfig ()
65
+ fmt .Printf ("deleted tenancy : %s\n " , t )
66
+ }
51
67
},
52
68
}
53
69
You can’t perform that action at this time.
0 commit comments