@@ -7,26 +7,74 @@ import (
77)
88
99func adjustConfig (config * latest.Config ) error {
10- for name , v := range config .Vars {
11- v .Name = name
10+ if config .Vars != nil {
11+ newObjs := map [string ]* latest.Variable {}
12+ for name , v := range config .Vars {
13+ if v == nil {
14+ continue
15+ }
16+ v .Name = name
17+ newObjs [name ] = v
18+ }
19+ config .Vars = newObjs
1220 }
13- for name , command := range config .Commands {
14- command .Name = name
21+ if config .Commands != nil {
22+ newObjs := map [string ]* latest.CommandConfig {}
23+ for name , command := range config .Commands {
24+ if command == nil {
25+ continue
26+ }
27+ command .Name = name
28+ newObjs [name ] = command
29+ }
30+ config .Commands = newObjs
1531 }
16- for name , pullSecret := range config .PullSecrets {
17- pullSecret .Name = name
32+ if config .PullSecrets != nil {
33+ newObjs := map [string ]* latest.PullSecretConfig {}
34+ for name , pullSecret := range config .PullSecrets {
35+ if pullSecret == nil {
36+ continue
37+ }
38+ pullSecret .Name = name
39+ newObjs [name ] = pullSecret
40+ }
41+ config .PullSecrets = newObjs
1842 }
19- for name , devPod := range config .Dev {
20- devPod .Name = name
21- for c , v := range devPod .Containers {
22- v .Container = c
43+ if config .Dev != nil {
44+ newObjs := map [string ]* latest.DevPod {}
45+ for name , devPod := range config .Dev {
46+ if devPod == nil {
47+ continue
48+ }
49+ devPod .Name = name
50+ for c , v := range devPod .Containers {
51+ v .Container = c
52+ }
53+ newObjs [name ] = devPod
2354 }
55+ config .Dev = newObjs
2456 }
25- for name , pipeline := range config .Pipelines {
26- pipeline .Name = name
57+ if config .Pipelines != nil {
58+ newObjs := map [string ]* latest.Pipeline {}
59+ for name , pipeline := range config .Pipelines {
60+ if pipeline == nil {
61+ continue
62+ }
63+ pipeline .Name = name
64+ newObjs [name ] = pipeline
65+ }
66+ config .Pipelines = newObjs
2767 }
28- for name , dep := range config .Dependencies {
29- dep .Name = name
68+ if config .Dependencies != nil {
69+ newObjs := map [string ]* latest.DependencyConfig {}
70+ for name , dep := range config .Dependencies {
71+ if dep == nil {
72+ continue
73+ }
74+ dep .Name = name
75+ newObjs [name ] = dep
76+ }
77+ config .Dependencies = newObjs
3078 }
3179 if config .Images != nil {
3280 newObjs := map [string ]* latest.Image {}
0 commit comments