diff --git a/pkg/appfile/appfile.go b/pkg/appfile/appfile.go index ac93cb58b..991e6a305 100644 --- a/pkg/appfile/appfile.go +++ b/pkg/appfile/appfile.go @@ -81,11 +81,12 @@ func (app *AppFile) buildOAM(ns string, io cmdutil.IOStreams, buildImage bool, t v, ok := svc["image"] if ok { image = v.(string) - } else { - return nil, nil, ErrImageNotDefined } if b := svc.GetBuild(); b != nil { + if image == "" { + return nil, nil, ErrImageNotDefined + } if buildImage { io.Infof("\nBuilding service (%s)...\n", sname) if err := b.BuildImage(io, image); err != nil { @@ -94,8 +95,8 @@ func (app *AppFile) buildOAM(ns string, io cmdutil.IOStreams, buildImage bool, t } } - io.Infof("\nRendering component configs for service (%s)...\n", sname) - acComp, comp, err := svc.RenderService(tm, sname, ns, image) + io.Infof("\nRendering configs for service (%s)...\n", sname) + acComp, comp, err := svc.RenderService(tm, sname, ns) if err != nil { return nil, nil, err } diff --git a/pkg/appfile/appfile_test.go b/pkg/appfile/appfile_test.go index 2abd364ae..4f7560ed2 100644 --- a/pkg/appfile/appfile_test.go +++ b/pkg/appfile/appfile_test.go @@ -36,6 +36,9 @@ services: yamlNoImage := `name: myapp services: bad-server: + build: + docker: + file: Dockerfile cmd: ["node", "server.js"] ` diff --git a/pkg/appfile/service.go b/pkg/appfile/service.go index ceef65ed0..851c5b499 100644 --- a/pkg/appfile/service.go +++ b/pkg/appfile/service.go @@ -62,7 +62,7 @@ func (s Service) GetBuild() *Build { // RenderService render all capabilities of a service to CUE values of a Component. // It outputs a Component which will be marshaled as standalone Component and also returned AppConfig Component section. -func (s Service) RenderService(tm template.Manager, name, ns, image string) ( +func (s Service) RenderService(tm template.Manager, name, ns string) ( *v1alpha2.ApplicationConfigurationComponent, *v1alpha2.Component, error) { // sort out configs by workload/trait @@ -89,8 +89,7 @@ func (s Service) RenderService(tm template.Manager, name, ns, image string) ( // only render webservice workload for now. ctxData := map[string]string{ - "name": name, - "image": image, + "name": name, } u, err := evalComponent(tm.LoadTemplate(wtype), ctxData, intifyValues(workloadKeys)) if err != nil {