Skip to content

Commit

Permalink
Revert "changed config parameter platform to platforms"
Browse files Browse the repository at this point in the history
This reverts commit ccb7711.
  • Loading branch information
marciogoda committed Mar 12, 2024
1 parent ccb7711 commit 5dcd174
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Use buildx for image creation with multi architecture support instead of the cla
Boolean parameter.
Defaults to `false`.

#### platforms
#### platform

Comma-separated list of platforms for the build, when buildx is enabled.
E.g.: `linux/arm64,linux/386,linux/s390x`.
Expand All @@ -84,7 +84,7 @@ Defaults to empty string.
image: mergermarket/cdflow2-build-docker-ecr:latest
params:
buildx: true
platforms: linux/arm64,linux/386
platform: linux/arm64,linux/386
cache-from: type=gha
cache-to: type=gha,mode=max
```
Expand All @@ -102,7 +102,7 @@ Defaults to empty string.
image: mergermarket/cdflow2-build-docker-ecr:latest
params:
buildx: true
platforms: linux/arm64,linux/386
platform: linux/arm64,linux/386
cache-from: type=gha
cache-to: type=gha,mode=max
```
Expand Down
18 changes: 9 additions & 9 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type config struct {
dockerfile string
context string
buildx bool
platforms string
platform string
cacheFrom string
cacheTo string
}
Expand Down Expand Up @@ -60,9 +60,9 @@ func Run(ecrClient ecriface.ECRAPI, runner CommandRunner, params map[string]inte
}

data, err := json.Marshal(map[string]string{
"image": image,
"buildx": strconv.FormatBool(config.buildx),
"platforms": config.platforms})
"image": image,
"buildx": strconv.FormatBool(config.buildx),
"platform": config.platform})
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -96,8 +96,8 @@ func buildWithBuildx(config *config, image string, runner CommandRunner) error {
runner.Run("docker", builderCreateArgs...)

buildArgs := []string{"buildx", "build", "--push"}
if config.platforms != "" {
buildArgs = append(buildArgs, "--platform", config.platforms)
if config.platform != "" {
buildArgs = append(buildArgs, "--platform", config.platform)
}

if config.cacheFrom != "" {
Expand Down Expand Up @@ -171,11 +171,11 @@ func getConfig(buildID string, params map[string]interface{}) (*config, error) {
}
}

platformsI, ok := params["platforms"]
platformI, ok := params["platform"]
if ok {
result.platforms, ok = platformsI.(string)
result.platform, ok = platformI.(string)
if !ok {
return nil, fmt.Errorf("unexpected type for build.%v.params.platforms: %T (should be string)", buildID, platformsI)
return nil, fmt.Errorf("unexpected type for build.%v.params.platform: %T (should be string)", buildID, platformI)
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func TestBuildxRun(t *testing.T) {
commandRunner := &mockCommandRunner{}

params := map[string]interface{}{
"buildx": true,
"platforms": "linux/arm64,linux/386,linux/s390x",
"buildx": true,
"platform": "linux/arm64,linux/386,linux/s390x",
}

// When
Expand Down

0 comments on commit 5dcd174

Please sign in to comment.