@@ -99,7 +99,7 @@ func (p *Item) UnInstall() error {
9999 return nil
100100 }
101101 pluginName := fmt .Sprintf ("qc-plugin-%s" , p .Type )
102- _ , err := p .Client .GetSecret (context .TODO (), common .DefaultSystem , pluginName , metav1.GetOptions {})
102+ _ , err := p .Client .GetSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , pluginName , metav1.GetOptions {})
103103 if err != nil {
104104 if errors .IsNotFound (err ) {
105105 p .log .Warnf ("plugin %s is already uninstalled" , p .Type )
@@ -110,27 +110,27 @@ func (p *Item) UnInstall() error {
110110 }
111111 // #nosec
112112 if p .Tool == "helm" {
113- applycmd := qcexec .Command (os .Args [0 ], "experimental" , "helm" , "delete" , p .Type , "-n" , common .DefaultSystem )
113+ applycmd := qcexec .Command (os .Args [0 ], "experimental" , "helm" , "delete" , p .Type , "-n" , common .GetDefaultSystemNamespace ( true ) )
114114 if output , err := applycmd .CombinedOutput (); err != nil {
115115 p .log .Errorf ("helm uninstall %s plugin %s failed: %s" , p .Type , p .Name , string (output ))
116116 return err
117117 }
118118 } else {
119119 // #nosec
120- applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "delete" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .DefaultSystem )
120+ applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "delete" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .GetDefaultSystemNamespace ( true ) )
121121 if output , err := applycmd .CombinedOutput (); err != nil {
122122 p .log .Errorf ("kubectl uninstall %s plugin %s failed: %s" , p .Type , p .Name , string (output ))
123123 return err
124124 }
125125 }
126126 p .log .Donef ("uninstall %s plugin success." , p .Type )
127- p .Client .DeleteSecret (context .TODO (), common .DefaultSystem , pluginName , metav1.DeleteOptions {})
127+ p .Client .DeleteSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , pluginName , metav1.DeleteOptions {})
128128 return nil
129129}
130130
131131func (p * Item ) Install () error {
132132 pluginName := fmt .Sprintf ("qc-plugin-%s" , p .Type )
133- oldSecret , err := p .Client .GetSecret (context .TODO (), common .DefaultSystem , pluginName , metav1.GetOptions {})
133+ oldSecret , err := p .Client .GetSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , pluginName , metav1.GetOptions {})
134134 updatestatus := false
135135 if err == nil {
136136 nowversion := gv .MustParse (strings .TrimPrefix (p .Version , "v" ))
@@ -149,7 +149,7 @@ func (p *Item) Install() error {
149149 }
150150 }
151151 if p .Tool == "helm" {
152- args := []string {"experimental" , "helm" , "upgrade" , "--name" , p .Type , "--repo" , common .DefaultHelmRepoName , "--chart" , p .Path , "--namespace" , common .DefaultSystem }
152+ args := []string {"experimental" , "helm" , "upgrade" , "--name" , p .Type , "--repo" , common .DefaultHelmRepoName , "--chart" , p .Path , "--namespace" , common .GetDefaultSystemNamespace ( true ) }
153153 if len (p .InstallVersion ) > 0 {
154154 args = append (args , "--version" , p .InstallVersion )
155155 }
@@ -160,7 +160,7 @@ func (p *Item) Install() error {
160160 }
161161 } else {
162162 // #nosec
163- applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "apply" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .DefaultSystem )
163+ applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "apply" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .GetDefaultSystemNamespace ( true ) )
164164 if output , err := applycmd .CombinedOutput (); err != nil {
165165 p .log .Errorf ("kubectl install %s plugin %s failed: %s" , p .Type , p .Name , string (output ))
166166 return err
@@ -175,14 +175,14 @@ func (p *Item) Install() error {
175175 "cliversion" : common .Version ,
176176 }
177177 if updatestatus {
178- _ , err = p .Client .UpdateSecret (context .TODO (), common .DefaultSystem , & corev1.Secret {
178+ _ , err = p .Client .UpdateSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , & corev1.Secret {
179179 ObjectMeta : metav1.ObjectMeta {
180180 Name : pluginName ,
181181 },
182182 StringData : plugindata ,
183183 }, metav1.UpdateOptions {})
184184 } else {
185- _ , err = p .Client .CreateSecret (context .TODO (), common .DefaultSystem , & corev1.Secret {
185+ _ , err = p .Client .CreateSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , & corev1.Secret {
186186 ObjectMeta : metav1.ObjectMeta {
187187 Name : pluginName ,
188188 },
@@ -195,21 +195,21 @@ func (p *Item) Install() error {
195195
196196func (p * Item ) Upgrade () (err error ) {
197197 pluginName := fmt .Sprintf ("qc-plugin-%s" , p .Type )
198- oldSecret , _ := p .Client .GetSecret (context .TODO (), common .DefaultSystem , pluginName , metav1.GetOptions {})
198+ oldSecret , _ := p .Client .GetSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , pluginName , metav1.GetOptions {})
199199 updatestatus := true
200200 if oldSecret == nil {
201201 updatestatus = false
202202 }
203203
204204 if p .Tool == "helm" {
205- applycmd := qcexec .Command (os .Args [0 ], "experimental" , "helm" , "upgrade" , "--name" , p .Type , "--repo" , common .DefaultHelmRepoName , "--chart" , p .Path , "--namespace" , common .DefaultSystem )
205+ applycmd := qcexec .Command (os .Args [0 ], "experimental" , "helm" , "upgrade" , "--name" , p .Type , "--repo" , common .DefaultHelmRepoName , "--chart" , p .Path , "--namespace" , common .GetDefaultSystemNamespace ( true ) )
206206 if output , err := applycmd .CombinedOutput (); err != nil {
207207 p .log .Errorf ("helm upgrade %s plugin %s failed: %s" , p .Type , p .Name , string (output ))
208208 return err
209209 }
210210 } else {
211211 // #nosec
212- applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "apply" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .DefaultSystem )
212+ applycmd := qcexec .Command (os .Args [0 ], "experimental" , "kubectl" , "apply" , "-f" , fmt .Sprintf ("%s/%s" , common .GetDefaultDataDir (), p .Path ), "-n" , common .GetDefaultSystemNamespace ( true ) )
213213 if output , err := applycmd .CombinedOutput (); err != nil {
214214 p .log .Errorf ("kubectl upgrade %s plugin %s failed: %s" , p .Type , p .Name , string (output ))
215215 return err
@@ -224,9 +224,9 @@ func (p *Item) Upgrade() (err error) {
224224 }
225225 if updatestatus {
226226 oldSecret .StringData = plugindata
227- _ , err = p .Client .UpdateSecret (context .TODO (), common .DefaultSystem , oldSecret , metav1.UpdateOptions {})
227+ _ , err = p .Client .UpdateSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , oldSecret , metav1.UpdateOptions {})
228228 } else {
229- _ , err = p .Client .CreateSecret (context .TODO (), common .DefaultSystem , & corev1.Secret {
229+ _ , err = p .Client .CreateSecret (context .TODO (), common .GetDefaultSystemNamespace ( true ) , & corev1.Secret {
230230 ObjectMeta : metav1.ObjectMeta {
231231 Name : pluginName ,
232232 },
0 commit comments