Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

feat: pass docker arch to ecr to lambda #3046

Merged
merged 6 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions builtin/aws/ecr/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions builtin/aws/ecr/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ option go_package = "waypoint/builtin/aws/ecr";
message Image {
string image = 1;
string tag = 2;
string architecture = 3;
}
5 changes: 3 additions & 2 deletions builtin/aws/ecr/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ func (r *Registry) Push(
}

return &Image{
Image: dockerImg.Image,
Tag: dockerImg.Tag,
Image: dockerImg.Image,
Tag: dockerImg.Tag,
Architecture: dockerImg.Architecture,
}, nil
}

Expand Down
19 changes: 19 additions & 0 deletions builtin/aws/lambda/mapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package lambda
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this to utils.go instead? Mappers are a specific argmapper concept that are automatically called and have to be registered. This appears to just be a helper function to convert one string to another.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL! Ok, renamed this mapper.go file utils.go


import (
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/hashicorp/go-hclog"
)

// DockerArchitectureMapper maps a docker image architecture to a valid lambda architecture.
func DockerArchitectureMapper(src string, log hclog.Logger) string {
switch src {
case "amd64", "x86_64":
return lambda.ArchitectureX8664
case "arm64", "aarch64":
return lambda.ArchitectureArm64
default:
log.Warn("unsupported docker architecture", "arch", src, "defaulting to:", lambda.ArchitectureX8664)
return lambda.ArchitectureX8664
}
}
2 changes: 1 addition & 1 deletion builtin/aws/lambda/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (p *Platform) Deploy(

architecture := p.config.Architecture
if architecture == "" {
architecture = DefaultArchitecture
architecture = DockerArchitectureMapper(img.Architecture, log)
}

step.Done()
Expand Down
2 changes: 2 additions & 0 deletions builtin/docker/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ func (b *Builder) Build(
ui.Output("Image built: %s (%s)", result.Name(), inspect.Architecture,
terminal.WithSuccessStyle())

result.Architecture = inspect.Architecture

return result, nil
}

Expand Down
124 changes: 67 additions & 57 deletions builtin/docker/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions builtin/docker/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "google/protobuf/empty.proto";
message Image {
string image = 1;
string tag = 2;
string architecture = 6;

// location is where this image is currently. This can be used to
// determine if the image is pulled or not based on this proto rather
Expand Down
5 changes: 3 additions & 2 deletions builtin/docker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ func (r *Registry) Push(
log hclog.Logger,
) (*Image, error) {
target := &Image{
Image: r.config.Image,
Tag: r.config.Tag,
Image: r.config.Image,
Tag: r.config.Tag,
Architecture: img.Architecture,
}
auth := r.config.Auth
if !r.config.Local {
Expand Down
4 changes: 4 additions & 0 deletions website/content/partials/components/builder-docker-pull.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ WARNING: be very careful to not leak the authentication information by hardcodin

Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy).

#### architecture

- Type: **string**

#### image

- Type: **string**
Expand Down
4 changes: 4 additions & 0 deletions website/content/partials/components/builder-docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ If buildkit is enabled unused stages will be skipped.

Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy).

#### architecture

- Type: **string**

#### image

- Type: **string**
Expand Down
4 changes: 4 additions & 0 deletions website/content/partials/components/registry-aws-ecr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ This defaults to waypoint- then the application name. The repository will be aut

Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy).

#### architecture

- Type: **string**

#### image

- Type: **string**
Expand Down
4 changes: 4 additions & 0 deletions website/content/partials/components/registry-docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ This optional conflicts with encoded_auth and thusly only one can be used at a t

Output attributes can be used in your `waypoint.hcl` as [variables](/docs/waypoint-hcl/variables) via [`artifact`](/docs/waypoint-hcl/variables/artifact) or [`deploy`](/docs/waypoint-hcl/variables/deploy).

#### architecture

- Type: **string**

#### image

- Type: **string**
Expand Down