@@ -42,7 +42,12 @@ type InstallationConfig struct {
4242func  InstallGatewayAPI (apiVersion  string ) ([]byte , error ) {
4343	apiPath  :=  fmt .Sprintf ("%s/v%s/standard-install.yaml" , gwInstallBasePath , apiVersion )
4444
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  {
4651		return  output , err 
4752	}
4853
@@ -53,7 +58,7 @@ func InstallGatewayAPI(apiVersion string) ([]byte, error) {
5358func  UninstallGatewayAPI (apiVersion  string ) ([]byte , error ) {
5459	apiPath  :=  fmt .Sprintf ("%s/v%s/standard-install.yaml" , gwInstallBasePath , apiVersion )
5560
56- 	output , err  :=  exec .Command ( "kubectl" , "delete" , "-f" , apiPath ).CombinedOutput ()
61+ 	output , err  :=  exec .CommandContext ( context . Background (),  "kubectl" , "delete" , "-f" , apiPath ).CombinedOutput ()
5762	if  err  !=  nil  &&  ! strings .Contains (string (output ), "not found" ) {
5863		return  output , err 
5964	}
@@ -84,7 +89,7 @@ func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
8489
8590	GinkgoWriter .Printf ("Installing NGF with command: helm %v\n " , strings .Join (fullArgs , " " ))
8691
87- 	return  exec .Command ( "helm" , fullArgs ... ).CombinedOutput ()
92+ 	return  exec .CommandContext ( context . Background (),  "helm" , fullArgs ... ).CombinedOutput ()
8893}
8994
9095// CreateLicenseSecret creates the NGINX Plus JWT secret. 
@@ -127,7 +132,12 @@ func CreateLicenseSecret(k8sClient client.Client, namespace, filename string) er
127132// UpgradeNGF upgrades NGF. CRD upgrades assume the chart is local. 
128133func  UpgradeNGF (cfg  InstallationConfig , extraArgs  ... string ) ([]byte , error ) {
129134	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  {
131141		return  output , err 
132142	}
133143
@@ -152,7 +162,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
152162
153163	GinkgoWriter .Printf ("Upgrading NGF with command: helm %v\n " , strings .Join (fullArgs , " " ))
154164
155- 	return  exec .Command ( "helm" , fullArgs ... ).CombinedOutput ()
165+ 	return  exec .CommandContext ( context . Background (),  "helm" , fullArgs ... ).CombinedOutput ()
156166}
157167
158168// UninstallNGF uninstalls NGF. 
@@ -161,7 +171,7 @@ func UninstallNGF(cfg InstallationConfig, k8sClient client.Client) ([]byte, erro
161171		"uninstall" , cfg .ReleaseName , "--namespace" , cfg .Namespace ,
162172	}
163173
164- 	output , err  :=  exec .Command ( "helm" , args ... ).CombinedOutput ()
174+ 	output , err  :=  exec .CommandContext ( context . Background (),  "helm" , args ... ).CombinedOutput ()
165175	if  err  !=  nil  &&  ! strings .Contains (string (output ), "release: not found" ) {
166176		return  output , err 
167177	}
0 commit comments