Skip to content

Commit

Permalink
Refactor createBuildCommand and fix CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mkimuram committed Apr 11, 2019
1 parent 2106140 commit 838a7c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Added

- New option for [`operator-sdk build --image-builder`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#build), which can be used to specify which image builder to use. ([#1311](https://github.com/operator-framework/operator-sdk/pull/1311))
- New option for [`operator-sdk build --image-builder`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#build), which can be used to specify which image builder to use. Adds support for [buildah](https://github.com/containers/buildah/). ([#1311](https://github.com/operator-framework/operator-sdk/pull/1311))

### Changed

Expand Down
14 changes: 8 additions & 6 deletions cmd/operator-sdk/build/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func verifyTestManifest(image string) error {
return nil
}

func createBuildCommand(imageBuilder, context, dockerFile, image, imageBuildArgs string) (*exec.Cmd, error) {
func createBuildCommand(imageBuilder, context, dockerFile, image string, imageBuildArgs ...string) (*exec.Cmd, error) {
var args []string
switch imageBuilder {
case "docker":
Expand All @@ -154,9 +154,11 @@ func createBuildCommand(imageBuilder, context, dockerFile, image, imageBuildArgs
return nil, fmt.Errorf("%s is not supported image builder", imageBuilder)
}

if imageBuildArgs != "" {
splitArgs := strings.Fields(imageBuildArgs)
args = append(args, splitArgs...)
for _, bargs := range imageBuildArgs {
if bargs != "" {
splitArgs := strings.Fields(bargs)
args = append(args, splitArgs...)
}
}

args = append(args, context)
Expand Down Expand Up @@ -254,8 +256,8 @@ func buildFunc(cmd *cobra.Command, args []string) error {

log.Infof("Building test OCI image %s", image)

testImageBuildArgs := fmt.Sprintf("%s --build-arg NAMESPACEDMAN=%s --build-arg BASEIMAGE=%s", imageBuildArgs, namespacedManBuild, baseImageName)
testBuildCmd, err := createBuildCommand(imageBuilder, ".", testDockerfile, image, testImageBuildArgs)
testImageBuildArgs := fmt.Sprintf("--build-arg NAMESPACEDMAN=%s --build-arg BASEIMAGE=%s", namespacedManBuild, baseImageName)
testBuildCmd, err := createBuildCommand(imageBuilder, ".", testDockerfile, image, imageBuildArgs, testImageBuildArgs)
if err != nil {
return err
}
Expand Down

0 comments on commit 838a7c8

Please sign in to comment.