From 7c8dcb592b943d94839eaec52a4704b047b375aa Mon Sep 17 00:00:00 2001 From: Adithya Kolla Date: Fri, 26 Jan 2024 11:19:28 -0800 Subject: [PATCH 1/3] skip checking respository type --- .../cloudformation/stack/rd_web_svc_test.go | 47 +++++++++++++++++++ .../deploy/cloudformation/stack/workload.go | 12 +++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go b/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go index efbfc520b88..fb932c82f17 100644 --- a/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go +++ b/internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go @@ -421,6 +421,53 @@ func TestRequestDrivenWebService_Parameters(t *testing.T) { ParameterValue: aws.String("1024"), }}, }, + "skip checking image repository type when `image.build` is specified": { + imageConfig: manifest.ImageWithPort{ + Image: manifest.Image{ + ImageLocationOrBuild: manifest.ImageLocationOrBuild{ + Build: manifest.BuildArgsOrString{ + BuildString: aws.String("./frontend/Dockerfile"), + }, + }, + }, + Port: aws.Uint16(80), + }, + instanceConfig: manifest.AppRunnerInstanceConfig{ + CPU: aws.Int(1024), + Memory: aws.Int(1024), + }, + wantedParams: []*cloudformation.Parameter{{ + ParameterKey: aws.String("AppName"), + ParameterValue: aws.String("phonetool"), + }, { + ParameterKey: aws.String("EnvName"), + ParameterValue: aws.String("test"), + }, { + ParameterKey: aws.String("WorkloadName"), + ParameterValue: aws.String("frontend"), + }, { + ParameterKey: aws.String("ContainerImage"), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String("AddonsTemplateURL"), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(WorkloadArtifactKeyARNParamKey), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(RDWkldImageRepositoryType), + ParameterValue: aws.String(""), + }, { + ParameterKey: aws.String(WorkloadContainerPortParamKey), + ParameterValue: aws.String("80"), + }, { + ParameterKey: aws.String(RDWkldInstanceCPUParamKey), + ParameterValue: aws.String("1024"), + }, { + ParameterKey: aws.String(RDWkldInstanceMemoryParamKey), + ParameterValue: aws.String("1024"), + }}, + }, "error when port unspecified": { imageConfig: manifest.ImageWithPort{ Image: manifest.Image{ diff --git a/internal/pkg/deploy/cloudformation/stack/workload.go b/internal/pkg/deploy/cloudformation/stack/workload.go index e28450bb284..8f949c8b59a 100644 --- a/internal/pkg/deploy/cloudformation/stack/workload.go +++ b/internal/pkg/deploy/cloudformation/stack/workload.go @@ -420,9 +420,15 @@ func (w *appRunnerWkld) Parameters() ([]*cloudformation.Parameter, error) { img = image.URI() } - imageRepositoryType, err := apprunner.DetermineImageRepositoryType(img) - if err != nil { - return nil, fmt.Errorf("determine image repository type: %w", err) + // This happens only when `copilot svc pacakage` is used with out `--upload-assets` flag. + // Incase of `image.build` is used then `w.rc.PushedImages` will be nil which leads to `img` to be empty. + // Skip the image repository type check in that case. + var imageRepositoryType string + if img != "" { + imageRepositoryType, err = apprunner.DetermineImageRepositoryType(img) + if err != nil { + return nil, fmt.Errorf("determine image repository type: %w", err) + } } if w.imageConfig.Port == nil { From 0111240fa03667a9394429aa3f73b4d3b5502126 Mon Sep 17 00:00:00 2001 From: Adithya Kolla Date: Fri, 26 Jan 2024 11:21:06 -0800 Subject: [PATCH 2/3] fix spelling --- internal/pkg/deploy/cloudformation/stack/workload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/deploy/cloudformation/stack/workload.go b/internal/pkg/deploy/cloudformation/stack/workload.go index 8f949c8b59a..3154fe709c1 100644 --- a/internal/pkg/deploy/cloudformation/stack/workload.go +++ b/internal/pkg/deploy/cloudformation/stack/workload.go @@ -420,7 +420,7 @@ func (w *appRunnerWkld) Parameters() ([]*cloudformation.Parameter, error) { img = image.URI() } - // This happens only when `copilot svc pacakage` is used with out `--upload-assets` flag. + // This happens only when `copilot svc package` is used with out `--upload-assets` flag. // Incase of `image.build` is used then `w.rc.PushedImages` will be nil which leads to `img` to be empty. // Skip the image repository type check in that case. var imageRepositoryType string From 011ea20fab7a1b448812c93f2bb8f9a2b26550b2 Mon Sep 17 00:00:00 2001 From: Adithya Kolla <71282729+KollaAdithya@users.noreply.github.com> Date: Fri, 26 Jan 2024 12:18:40 -0800 Subject: [PATCH 3/3] Update internal/pkg/deploy/cloudformation/stack/workload.go Co-authored-by: Penghao He --- internal/pkg/deploy/cloudformation/stack/workload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/deploy/cloudformation/stack/workload.go b/internal/pkg/deploy/cloudformation/stack/workload.go index 3154fe709c1..6a4890b4742 100644 --- a/internal/pkg/deploy/cloudformation/stack/workload.go +++ b/internal/pkg/deploy/cloudformation/stack/workload.go @@ -421,7 +421,7 @@ func (w *appRunnerWkld) Parameters() ([]*cloudformation.Parameter, error) { } // This happens only when `copilot svc package` is used with out `--upload-assets` flag. - // Incase of `image.build` is used then `w.rc.PushedImages` will be nil which leads to `img` to be empty. + // In case of `image.build` is used, then `w.rc.PushedImages` will be nil, which leads to `img` to be empty. // Skip the image repository type check in that case. var imageRepositoryType string if img != "" {