@@ -42,7 +42,12 @@ type InstallationConfig struct {
42
42
func InstallGatewayAPI (apiVersion string ) ([]byte , error ) {
43
43
apiPath := fmt .Sprintf ("%s/v%s/standard-install.yaml" , gwInstallBasePath , apiVersion )
44
44
45
- if output , err := exec .Command ("kubectl" , "apply" , "-f" , apiPath ).CombinedOutput (); err != nil {
45
+ cmd := exec .CommandContext (
46
+ context .Background (),
47
+ "kubectl" , "apply" , "-f" , apiPath ,
48
+ )
49
+ output , err := cmd .CombinedOutput ()
50
+ if err != nil {
46
51
return output , err
47
52
}
48
53
@@ -53,7 +58,7 @@ func InstallGatewayAPI(apiVersion string) ([]byte, error) {
53
58
func UninstallGatewayAPI (apiVersion string ) ([]byte , error ) {
54
59
apiPath := fmt .Sprintf ("%s/v%s/standard-install.yaml" , gwInstallBasePath , apiVersion )
55
60
56
- output , err := exec .Command ( "kubectl" , "delete" , "-f" , apiPath ).CombinedOutput ()
61
+ output , err := exec .CommandContext ( context . Background (), "kubectl" , "delete" , "-f" , apiPath ).CombinedOutput ()
57
62
if err != nil && ! strings .Contains (string (output ), "not found" ) {
58
63
return output , err
59
64
}
@@ -84,7 +89,7 @@ func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
84
89
85
90
GinkgoWriter .Printf ("Installing NGF with command: helm %v\n " , strings .Join (fullArgs , " " ))
86
91
87
- return exec .Command ( "helm" , fullArgs ... ).CombinedOutput ()
92
+ return exec .CommandContext ( context . Background (), "helm" , fullArgs ... ).CombinedOutput ()
88
93
}
89
94
90
95
// CreateLicenseSecret creates the NGINX Plus JWT secret.
@@ -127,7 +132,12 @@ func CreateLicenseSecret(k8sClient client.Client, namespace, filename string) er
127
132
// UpgradeNGF upgrades NGF. CRD upgrades assume the chart is local.
128
133
func UpgradeNGF (cfg InstallationConfig , extraArgs ... string ) ([]byte , error ) {
129
134
crdPath := filepath .Join (cfg .ChartPath , "crds" ) + "/"
130
- if output , err := exec .Command ("kubectl" , "apply" , "-f" , crdPath ).CombinedOutput (); err != nil {
135
+ cmd := exec .CommandContext (
136
+ context .Background (),
137
+ "kubectl" , "apply" , "-f" , crdPath ,
138
+ )
139
+ output , err := cmd .CombinedOutput ()
140
+ if err != nil {
131
141
return output , err
132
142
}
133
143
@@ -152,7 +162,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
152
162
153
163
GinkgoWriter .Printf ("Upgrading NGF with command: helm %v\n " , strings .Join (fullArgs , " " ))
154
164
155
- return exec .Command ( "helm" , fullArgs ... ).CombinedOutput ()
165
+ return exec .CommandContext ( context . Background (), "helm" , fullArgs ... ).CombinedOutput ()
156
166
}
157
167
158
168
// UninstallNGF uninstalls NGF.
@@ -161,7 +171,7 @@ func UninstallNGF(cfg InstallationConfig, k8sClient client.Client) ([]byte, erro
161
171
"uninstall" , cfg .ReleaseName , "--namespace" , cfg .Namespace ,
162
172
}
163
173
164
- output , err := exec .Command ( "helm" , args ... ).CombinedOutput ()
174
+ output , err := exec .CommandContext ( context . Background (), "helm" , args ... ).CombinedOutput ()
165
175
if err != nil && ! strings .Contains (string (output ), "release: not found" ) {
166
176
return output , err
167
177
}
0 commit comments