Skip to content

Commit f7db0c4

Browse files
committed
Fix nil pointer & improve kubectl error message
1 parent f383fd1 commit f7db0c4

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pkg/devspace/deploy/kubectl/kubectl.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (d *DeployConfig) Deploy(cache *generated.CacheConfig, forceDeploy bool, bu
166166
for _, manifest := range d.Manifests {
167167
shouldRedeploy, replacedManifest, err := d.getReplacedManifest(manifest, cache, builtImages)
168168
if err != nil {
169-
return false, err
169+
return false, fmt.Errorf("%v\nPlease make sure `kubectl apply` does work locally with manifest `%s`", err, manifest)
170170
}
171171

172172
if shouldRedeploy || forceDeploy {
@@ -186,7 +186,7 @@ func (d *DeployConfig) Deploy(cache *generated.CacheConfig, forceDeploy bool, bu
186186

187187
err = cmd.Run()
188188
if err != nil {
189-
return false, err
189+
return false, fmt.Errorf("%v\nPlease make sure the command `kubectl apply` does work locally with manifest `%s`", err, manifest)
190190
}
191191

192192
wasDeployed = true
@@ -250,13 +250,11 @@ func (d *DeployConfig) getCmdArgs(method string, additionalArgs ...string) []str
250250
}
251251

252252
args = append(args, method)
253-
254253
if additionalArgs != nil {
255254
args = append(args, additionalArgs...)
256255
}
257256

258257
args = append(args, "-f", "-")
259-
260258
return args
261259
}
262260

pkg/devspace/kubectl/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ func loadClientConfig(config *latest.Config, switchContext bool) (clientcmd.Clie
148148
}
149149
}
150150

151+
if _, ok := kubeConfig.Contexts[activeContext]; ok == false {
152+
return nil, fmt.Errorf("Error loading kube config, context '%s' doesn't exist", activeContext)
153+
}
154+
151155
// Change context namespace
152156
if config.Cluster != nil && config.Cluster.Namespace != nil {
153157
kubeConfig.Contexts[activeContext].Namespace = *config.Cluster.Namespace

sync/stub/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ func main() {
6868
}
6969

7070
if *isDownstream {
71-
err := server.StartDownstreamServer(absolutePath, excludePaths, os.Stdin, os.Stdout)
71+
err := server.StartDownstreamServer(absolutePath, excludePaths, os.Stdin, os.Stdout, true)
7272
if err != nil {
7373
fmt.Fprintf(os.Stderr, "%v", err)
7474
os.Exit(1)
7575
}
7676
} else if *isUpstream {
77-
err := server.StartUpstreamServer(absolutePath, os.Stdin, os.Stdout)
77+
err := server.StartUpstreamServer(absolutePath, os.Stdin, os.Stdout, true)
7878
if err != nil {
7979
fmt.Fprintf(os.Stderr, "%v", err)
8080
os.Exit(1)

0 commit comments

Comments
 (0)