Skip to content

Commit

Permalink
fix: nil pointer if empty config section
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Aug 26, 2022
1 parent 5479854 commit 3a483cb
Showing 1 changed file with 62 additions and 14 deletions.
76 changes: 62 additions & 14 deletions pkg/devspace/config/versions/adjust.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,74 @@ import (
)

func adjustConfig(config *latest.Config) error {
for name, v := range config.Vars {
v.Name = name
if config.Vars != nil {
newObjs := map[string]*latest.Variable{}
for name, v := range config.Vars {
if v == nil {
continue
}
v.Name = name
newObjs[name] = v
}
config.Vars = newObjs
}
for name, command := range config.Commands {
command.Name = name
if config.Commands != nil {
newObjs := map[string]*latest.CommandConfig{}
for name, command := range config.Commands {
if command == nil {
continue
}
command.Name = name
newObjs[name] = command
}
config.Commands = newObjs
}
for name, pullSecret := range config.PullSecrets {
pullSecret.Name = name
if config.PullSecrets != nil {
newObjs := map[string]*latest.PullSecretConfig{}
for name, pullSecret := range config.PullSecrets {
if pullSecret == nil {
continue
}
pullSecret.Name = name
newObjs[name] = pullSecret
}
config.PullSecrets = newObjs
}
for name, devPod := range config.Dev {
devPod.Name = name
for c, v := range devPod.Containers {
v.Container = c
if config.Dev != nil {
newObjs := map[string]*latest.DevPod{}
for name, devPod := range config.Dev {
if devPod == nil {
continue
}
devPod.Name = name
for c, v := range devPod.Containers {
v.Container = c
}
newObjs[name] = devPod
}
config.Dev = newObjs
}
for name, pipeline := range config.Pipelines {
pipeline.Name = name
if config.Pipelines != nil {
newObjs := map[string]*latest.Pipeline{}
for name, pipeline := range config.Pipelines {
if pipeline == nil {
continue
}
pipeline.Name = name
newObjs[name] = pipeline
}
config.Pipelines = newObjs
}
for name, dep := range config.Dependencies {
dep.Name = name
if config.Dependencies != nil {
newObjs := map[string]*latest.DependencyConfig{}
for name, dep := range config.Dependencies {
if dep == nil {
continue
}
dep.Name = name
newObjs[name] = dep
}
config.Dependencies = newObjs
}
if config.Images != nil {
newObjs := map[string]*latest.Image{}
Expand Down

0 comments on commit 3a483cb

Please sign in to comment.