Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions internal/pkg/cli/task_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"bytes"
"errors"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"path/filepath"
"testing"

"github.com/aws/aws-sdk-go/aws"

"github.com/aws/aws-sdk-go/aws/session"

"github.com/aws/copilot-cli/internal/pkg/docker/dockerengine"
Expand Down Expand Up @@ -157,7 +158,7 @@ func TestTaskRunOpts_Validate(t *testing.T) {
basicOpts: defaultOpts,
inOS: "OStrich",
inArch: "MAD666",
wantedError: errors.New("platform OSTRICH/MAD666 is invalid; valid platforms are: WINDOWS_SERVER_2019_CORE/X86_64, WINDOWS_SERVER_2019_FULL/X86_64, LINUX/X86_64 and LINUX/ARM64"),
wantedError: errors.New("platform OSTRICH/MAD666 is invalid; valid platforms are: WINDOWS_SERVER_2019_CORE/X86_64, WINDOWS_SERVER_2019_FULL/X86_64, WINDOWS_SERVER_2022_CORE/X86_64, WINDOWS_SERVER_2022_FULL/X86_64, LINUX/X86_64 and LINUX/ARM64"),
},
"uppercase any lowercase before validating": {
basicOpts: basicOpts{
Expand Down
8 changes: 6 additions & 2 deletions internal/pkg/deploy/cloudformation/stack/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,13 @@ func convertPlatform(platform manifest.PlatformArgsOrString) template.RuntimePla
os := template.OSLinux
switch platform.OS() {
case manifest.OSWindows, manifest.OSWindowsServer2019Core:
os = template.OSWindowsServerCore
os = template.OSWindowsServer2019Core
case manifest.OSWindowsServer2019Full:
os = template.OSWindowsServerFull
os = template.OSWindowsServer2019Full
case manifest.OSWindowsServer2022Core:
os = template.OSWindowsServer2022Core
case manifest.OSWindowsServer2022Full:
os = template.OSWindowsServer2022Full
}

arch := template.ArchX86
Expand Down
44 changes: 40 additions & 4 deletions internal/pkg/deploy/cloudformation/stack/transformers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1506,24 +1506,60 @@ func Test_convertPlatform(t *testing.T) {
out template.RuntimePlatformOpts
}{
"should return empty struct if user did not set a platform field in the manifest": {},
"should return windows server 2019 full and x86_64 when advanced config specifies full": {
"should return windows server 2019 full and x86_64 when advanced config specifies 2019 full": {
in: manifest.PlatformArgsOrString{
PlatformArgs: manifest.PlatformArgs{
OSFamily: aws.String(manifest.OSWindowsServer2019Full),
Arch: aws.String(manifest.ArchX86),
},
},
out: template.RuntimePlatformOpts{
OS: template.OSWindowsServerFull,
OS: template.OSWindowsServer2019Full,
Arch: template.ArchX86,
},
},
"should return windows server core and x86_64 when platform is 'windows/x86_64'": {
"should return windows server 2019 core and x86_64 when advanced config specifies 2019 core": {
in: manifest.PlatformArgsOrString{
PlatformArgs: manifest.PlatformArgs{
OSFamily: aws.String(manifest.OSWindowsServer2019Core),
Arch: aws.String(manifest.ArchX86),
},
},
out: template.RuntimePlatformOpts{
OS: template.OSWindowsServer2019Core,
Arch: template.ArchX86,
},
},
"should return windows server 2022 full and x86_64 when advanced config specifies 2022 full": {
in: manifest.PlatformArgsOrString{
PlatformArgs: manifest.PlatformArgs{
OSFamily: aws.String(manifest.OSWindowsServer2022Full),
Arch: aws.String(manifest.ArchX86),
},
},
out: template.RuntimePlatformOpts{
OS: template.OSWindowsServer2022Full,
Arch: template.ArchX86,
},
},
"should return windows server 2022 core and x86_64 when advanced config specifies 2022 core": {
in: manifest.PlatformArgsOrString{
PlatformArgs: manifest.PlatformArgs{
OSFamily: aws.String(manifest.OSWindowsServer2022Core),
Arch: aws.String(manifest.ArchX86),
},
},
out: template.RuntimePlatformOpts{
OS: template.OSWindowsServer2022Core,
Arch: template.ArchX86,
},
},
"should return windows server core 2019 and x86_64 when platform is 'windows/x86_64'": {
in: manifest.PlatformArgsOrString{
PlatformString: (*manifest.PlatformString)(aws.String("windows/amd64")),
},
out: template.RuntimePlatformOpts{
OS: template.OSWindowsServerCore,
OS: template.OSWindowsServer2019Core,
Arch: template.ArchX86,
},
},
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/manifest/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ func TestPlatformArgsOrString_validate(t *testing.T) {
Arch: aws.String("amd64"),
},
},
wanted: fmt.Errorf("platform pair ('foo', 'amd64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"),
wanted: fmt.Errorf("platform pair ('foo', 'amd64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"),
},
"error if arch is invalid": {
in: PlatformArgsOrString{
Expand All @@ -1626,7 +1626,7 @@ func TestPlatformArgsOrString_validate(t *testing.T) {
Arch: aws.String("bar"),
},
},
wanted: fmt.Errorf("platform pair ('linux', 'bar') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"),
wanted: fmt.Errorf("platform pair ('linux', 'bar') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"),
},
"return nil if platform string valid": {
in: PlatformArgsOrString{PlatformString: (*PlatformString)(aws.String("linux/amd64"))},
Expand Down Expand Up @@ -2541,7 +2541,7 @@ func TestAppRunnerInstanceConfig_validate(t *testing.T) {
},
},
},
wantedError: fmt.Errorf("validate \"platform\": platform pair ('linux', 'leg64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64')"),
wantedError: fmt.Errorf("validate \"platform\": platform pair ('linux', 'leg64') is invalid: fields ('osfamily', 'architecture') must be one of ('linux', 'x86_64'), ('linux', 'amd64'), ('linux', 'arm'), ('linux', 'arm64'), ('windows', 'x86_64'), ('windows', 'amd64'), ('windows_server_2019_core', 'x86_64'), ('windows_server_2019_core', 'amd64'), ('windows_server_2019_full', 'x86_64'), ('windows_server_2019_full', 'amd64'), ('windows_server_2022_core', 'x86_64'), ('windows_server_2022_core', 'amd64'), ('windows_server_2022_full', 'x86_64'), ('windows_server_2022_full', 'amd64')"),
},
"error if App Runner + ARM": {
config: AppRunnerInstanceConfig{
Expand Down
8 changes: 7 additions & 1 deletion internal/pkg/manifest/workload_ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const (
OSWindows = dockerengine.OSWindows
OSWindowsServer2019Core = "windows_server_2019_core"
OSWindowsServer2019Full = "windows_server_2019_full"
OSWindowsServer2022Core = "windows_server_2022_core"
OSWindowsServer2022Full = "windows_server_2022_full"

ArchAMD64 = dockerengine.ArchAMD64
ArchX86 = dockerengine.ArchX86
Expand All @@ -43,7 +45,7 @@ const (
// Platform related settings.
var (
defaultPlatform = platformString(OSLinux, ArchAMD64)
windowsOSFamilies = []string{OSWindows, OSWindowsServer2019Core, OSWindowsServer2019Full}
windowsOSFamilies = []string{OSWindows, OSWindowsServer2019Core, OSWindowsServer2019Full, OSWindowsServer2022Core, OSWindowsServer2022Full}
validShortPlatforms = []string{ // All of the os/arch combinations that the PlatformString field may accept.
dockerengine.PlatformString(OSLinux, ArchAMD64),
dockerengine.PlatformString(OSLinux, ArchX86),
Expand All @@ -63,6 +65,10 @@ var (
{OSFamily: aws.String(OSWindowsServer2019Core), Arch: aws.String(ArchAMD64)},
{OSFamily: aws.String(OSWindowsServer2019Full), Arch: aws.String(ArchX86)},
{OSFamily: aws.String(OSWindowsServer2019Full), Arch: aws.String(ArchAMD64)},
{OSFamily: aws.String(OSWindowsServer2022Core), Arch: aws.String(ArchX86)},
{OSFamily: aws.String(OSWindowsServer2022Core), Arch: aws.String(ArchAMD64)},
{OSFamily: aws.String(OSWindowsServer2022Full), Arch: aws.String(ArchX86)},
{OSFamily: aws.String(OSWindowsServer2022Full), Arch: aws.String(ArchAMD64)},
}
)

Expand Down
87 changes: 84 additions & 3 deletions internal/pkg/manifest/workload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func TestPlatformArgsOrString_OS(t *testing.T) {
},
wanted: "linux",
},
"should return OS when platform is a map": {
"should return OS when platform is a map 2019 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2019_core"),
Expand All @@ -475,7 +475,7 @@ func TestPlatformArgsOrString_OS(t *testing.T) {
},
wanted: "windows_server_2019_core",
},
"should return lowercase OS": {
"should return lowercase OS 2019 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("wINdows_sERver_2019_cORe"),
Expand All @@ -484,6 +484,60 @@ func TestPlatformArgsOrString_OS(t *testing.T) {
},
wanted: "windows_server_2019_core",
},
"should return OS when platform is a map 2019 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2019_full"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2019_full",
},
"should return lowercase OS 2019 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("wINdows_sERver_2019_fUll"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2019_full",
},
"should return OS when platform is a map 2022 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2022_core"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2022_core",
},
"should return lowercase OS 2022 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("wINdows_sERver_2022_cORe"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2022_core",
},
"should return OS when platform is a map 2022 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2022_full"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2022_full",
},
"should return lowercase OS 2022 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("wINdows_sERver_2022_fUll"),
Arch: aws.String("x86_64"),
},
},
wanted: "windows_server_2022_full",
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
Expand All @@ -503,7 +557,7 @@ func TestPlatformArgsOrString_Arch(t *testing.T) {
},
wanted: "arm",
},
"should return arch when platform is a map": {
"should return arch when platform is a map 2019 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2019_core"),
Expand All @@ -512,6 +566,33 @@ func TestPlatformArgsOrString_Arch(t *testing.T) {
},
wanted: "x86_64",
},
"should return arch when platform is a map 2019 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2019_full"),
Arch: aws.String("x86_64"),
},
},
wanted: "x86_64",
},
"should return arch when platform is a map 2022 core": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2022_core"),
Arch: aws.String("x86_64"),
},
},
wanted: "x86_64",
},
"should return arch when platform is a map 2022 full": {
in: &PlatformArgsOrString{
PlatformArgs: PlatformArgs{
OSFamily: aws.String("windows_server_2022_full"),
Arch: aws.String("x86_64"),
},
},
wanted: "x86_64",
},
"should return lowercase arch": {
in: &PlatformArgsOrString{
PlatformString: (*PlatformString)(aws.String("windows/aMd64")),
Expand Down
Loading