@@ -127,9 +127,8 @@ func verifyDeploymentImage(yamlFile []byte, imageName string) string {
127
127
}
128
128
129
129
const (
130
- build = "./tmp/build/build.sh"
131
- dockerBuild = "./tmp/build/docker_build.sh"
132
- configYaml = "./config/config.yaml"
130
+ build = "./tmp/build/build.sh"
131
+ configYaml = "./config/config.yaml"
133
132
)
134
133
135
134
func buildFunc (cmd * cobra.Command , args []string ) {
@@ -149,6 +148,7 @@ func buildFunc(cmd *cobra.Command, args []string) {
149
148
namespacedRolesBytes := make ([]byte , 0 )
150
149
genWarning := ""
151
150
image := args [0 ]
151
+ intermediateImageName := image
152
152
if enableTests {
153
153
if namespacedManBuild == "" {
154
154
os .Mkdir ("deploy/test" , os .FileMode (int (0775 )))
@@ -191,20 +191,24 @@ func buildFunc(cmd *cobra.Command, args []string) {
191
191
if err = generator .RenderTestYaml (c , string (global ), string (namespacedRolesBytes ), image ); err != nil {
192
192
cmdError .ExitWithError (cmdError .ExitError , fmt .Errorf ("failed to generate deploy/test-gen.yaml: (%v)" , err ))
193
193
}
194
- os .Link ("tmp/build/dockerfiles/Dockerfile_Tests" , "tmp/build/Dockerfile" )
195
- } else {
196
- os .Link ("tmp/build/dockerfiles/Dockerfile_Standard" , "tmp/build/Dockerfile" )
194
+ intermediateImageName += "-intermediate"
197
195
}
198
- defer os .Remove ("tmp/build/Dockerfile" )
199
- dbcmd := exec .Command (dockerBuild )
200
- dbcmd .Env = append (os .Environ (), fmt .Sprintf ("IMAGE=%v" , image ))
201
- dbcmd .Env = append (dbcmd .Env , fmt .Sprintf ("NAMESPACEDMAN=%v" , namespacedManBuild ))
196
+ dbcmd := exec .Command ("docker" , "build" , "." , "-f" , "tmp/build/Dockerfile" , "-t" , intermediateImageName )
202
197
o , err = dbcmd .CombinedOutput ()
203
198
if err != nil {
204
- cmdError .ExitWithError (cmdError .ExitError , fmt .Errorf ("failed to output build image %v: (%v)" , image , string (o )))
199
+ cmdError .ExitWithError (cmdError .ExitError , fmt .Errorf ("failed to output build image %v: (%v)" , intermediateImageName , string (o )))
205
200
}
206
201
fmt .Fprintln (os .Stdout , string (o ))
207
- if genWarning != "" {
208
- fmt .Printf ("%s\n " , genWarning )
202
+
203
+ if enableTests {
204
+ testDbcmd := exec .Command ("docker" , "build" , "." , "-f" , "tmp/build/test-framework/Dockerfile" , "-t" , image , "--build-arg" , "NAMESPACEDMAN=" + namespacedManBuild , "--build-arg" , "BASEIMAGE=" + intermediateImageName )
205
+ o , err = testDbcmd .CombinedOutput ()
206
+ if err != nil {
207
+ cmdError .ExitWithError (cmdError .ExitError , fmt .Errorf ("failed to output build image %v: (%v)" , image , string (o )))
208
+ }
209
+ fmt .Fprintln (os .Stdout , string (o ))
210
+ if genWarning != "" {
211
+ fmt .Printf ("%s\n " , genWarning )
212
+ }
209
213
}
210
214
}
0 commit comments