@@ -78,25 +78,24 @@ func testLocalFunc(cmd *cobra.Command, args []string) {
78
78
saFile := filepath .Join (scaffold .DeployDir , scaffold .ServiceAccountYamlFile )
79
79
sa , err := ioutil .ReadFile (saFile )
80
80
if err != nil {
81
- log .Fatalf ( " could not find the manifest %s: %v" , saFile , err )
81
+ log .Printf ( "WARN: could not find the manifest %s: %v" , saFile , err )
82
82
}
83
83
role , err := ioutil .ReadFile (filepath .Join (scaffold .DeployDir , scaffold .RoleYamlFile ))
84
84
if err != nil {
85
- log .Fatalf ( " could not find role manifest: %v" , err )
85
+ log .Printf ( "WARN: could not find role manifest: %v" , err )
86
86
}
87
87
roleBinding , err := ioutil .ReadFile (filepath .Join (scaffold .DeployDir , scaffold .RoleBindingYamlFile ))
88
88
if err != nil {
89
- log .Fatalf ( " could not find role_binding manifest: %v" , err )
89
+ log .Printf ( "WARN: could not find role_binding manifest: %v" , err )
90
90
}
91
91
operator , err := ioutil .ReadFile (filepath .Join (scaffold .DeployDir , scaffold .OperatorYamlFile ))
92
92
if err != nil {
93
93
log .Fatalf ("could not find operator manifest: %v" , err )
94
94
}
95
- combined := append (sa , []byte ("\n ---\n " )... )
96
- combined = append (combined , role ... )
97
- combined = append (combined , []byte ("\n ---\n " )... )
98
- combined = append (combined , roleBinding ... )
99
- combined = append (combined , []byte ("\n ---\n " )... )
95
+ combined := []byte {}
96
+ combined = combineManifests (combined , sa )
97
+ combined = combineManifests (combined , role )
98
+ combined = combineManifests (combined , roleBinding )
100
99
combined = append (combined , operator ... )
101
100
err = ioutil .WriteFile (tlConfig .namespacedManPath , combined , os .FileMode (fileutil .DefaultFileMode ))
102
101
if err != nil {
@@ -168,3 +167,13 @@ func testLocalFunc(cmd *cobra.Command, args []string) {
168
167
log .Fatalf ("failed to exec `go %s`: %v" , strings .Join (testArgs , " " ), err )
169
168
}
170
169
}
170
+
171
+ // combineManifests combines a given manifest with a base manifest and adds yaml
172
+ // style separation. Nothing is appended if the manifest is empty.
173
+ func combineManifests (base , manifest []byte ) []byte {
174
+ if len (manifest ) > 0 {
175
+ base = append (base , manifest ... )
176
+ return append (base , []byte ("\n ---\n " )... )
177
+ }
178
+ return base
179
+ }
0 commit comments