Skip to content

Commit

Permalink
fix: svc package for rdws when image.build is used (#5638)
Browse files Browse the repository at this point in the history
related #5634 


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
KollaAdithya authored Jan 26, 2024
1 parent a72c893 commit 7e4350b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
47 changes: 47 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/rd_web_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
12 changes: 9 additions & 3 deletions internal/pkg/deploy/cloudformation/stack/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 package` is used with out `--upload-assets` flag.
// 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 != "" {
imageRepositoryType, err = apprunner.DetermineImageRepositoryType(img)
if err != nil {
return nil, fmt.Errorf("determine image repository type: %w", err)
}
}

if w.imageConfig.Port == nil {
Expand Down

0 comments on commit 7e4350b

Please sign in to comment.