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

handle dev clone on nested acorns (#2247) #2252

Merged
merged 2 commits into from
Oct 17, 2023
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
22 changes: 14 additions & 8 deletions pkg/apis/internal.acorn.io/v1/appimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ type AppImage struct {
// ImageInstance.Name
ID string `json:"id,omitempty"`
// Name is the image name requested by the user of any format
Name string `json:"name,omitempty"`
Digest string `json:"digest,omitempty"`
Acornfile string `json:"acornfile,omitempty"`
ImageData ImagesData `json:"imageData,omitempty"`
BuildArgs *GenericMap `json:"buildArgs,omitempty"`
Profiles []string `json:"profiles,omitempty"`
VCS VCS `json:"vcs,omitempty"`
Version *AppImageVersion `json:"version,omitempty"`
Name string `json:"name,omitempty"`
Digest string `json:"digest,omitempty"`
Acornfile string `json:"acornfile,omitempty"`
ImageData ImagesData `json:"imageData,omitempty"`
BuildArgs *GenericMap `json:"buildArgs,omitempty"`
BuildContext BuildContext `json:"buildContext,omitempty"`
Profiles []string `json:"profiles,omitempty"`
VCS VCS `json:"vcs,omitempty"`
Version *AppImageVersion `json:"version,omitempty"`
}

type BuildContext struct {
Cwd string `json:"cwd,omitempty"`
AcornfilePath string `json:"acornfilePath,omitempty"`
}

type AppImageVersion struct {
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go

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

22 changes: 14 additions & 8 deletions pkg/appdefinition/appdefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import (
)

const (
IconFile = "icon"
ReadmeFile = "README"
Acornfile = "Acornfile"
ImageDataFile = "images.json"
VersionFile = "version.json"
VCSDataFile = "vcs.json"
BuildDataFile = "build.json"
messageSuffix = ", you may need to define the image/build in the images section of the Acornfile"
IconFile = "icon"
ReadmeFile = "README"
Acornfile = "Acornfile"
ImageDataFile = "images.json"
VersionFile = "version.json"
VCSDataFile = "vcs.json"
BuildDataFile = "build.json"
BuildContextFile = "build-context.json"
messageSuffix = ", you may need to define the image/build in the images section of the Acornfile"

AcornfileSchemaVersion = "v1"
V0Pragma = "//acorn:amlv0"
Expand Down Expand Up @@ -476,6 +477,11 @@ func AppImageFromTar(reader io.Reader) (*v1.AppImage, *DataFiles, error) {
if err != nil {
return nil, nil, err
}
case BuildContextFile:
err := json.NewDecoder(tar).Decode(&result.BuildContext)
if err != nil {
return nil, nil, err
}
case ReadmeFile:
dataFiles.Readme, err = io.ReadAll(tar)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/build/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func getContextFromAppImage(dataFiles appdefinition.DataFiles, appImage *v1.AppI
return "", err
}
}
if err := addFile(tempDir, appdefinition.BuildContextFile, appImage.BuildContext); err != nil {
return "", err
}
return tempDir, nil
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ func build(ctx *buildContext) (*v1.AppImage, error) {
Acornfile: string(acornfileData),
ImageData: imageData,
BuildArgs: v1.NewGenericMap(buildArgs),
Profiles: profiles,
VCS: ctx.opts.VCS,
BuildContext: v1.BuildContext{
Cwd: ctx.cwd,
AcornfilePath: ctx.acornfilePath,
},
Profiles: profiles,
VCS: ctx.opts.VCS,
}
if err != nil {
return nil, err
Expand Down Expand Up @@ -239,6 +243,8 @@ func buildAcorns(ctx *buildContext, acorns map[string]v1.AcornBuilderSpec) (map[
newCtx.opts.Acornfile = ""
newCtx.acornfilePath = filepath.Join(ctx.cwd, acornImage.Build.Acornfile)
newCtx.cwd = filepath.Join(ctx.cwd, acornImage.Build.Context)
// We know this field will never be correct for nested build so just blank it out
newCtx.opts.VCS.Acornfile = ""
appImage, err := build(&newCtx)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/testdata/all/all_test_json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ ACORNS:
"staged": {
"appImage": {
"imageData": {},
"buildContext": {},
"vcs": {}
}
},
"appImage": {
"imageData": {},
"buildContext": {},
"vcs": {}
},
"appSpec": {},
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/testdata/all/all_test_yaml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ items:
target: found
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -19,6 +20,7 @@ items:
defaults: {}
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/appdefinition/testdata/TestComputeMem.golden
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ spec:
stop: false
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -87,6 +88,7 @@ status:
defaults: {}
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down Expand Up @@ -117,6 +119,7 @@ spec:
stop: false
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -125,6 +128,7 @@ status:
defaults: {}
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down Expand Up @@ -175,6 +179,7 @@ spec:
byname.child: 3
status:
appImage:
buildContext: {}
id: foo
imageData: {}
vcs: {}
Expand All @@ -195,6 +200,7 @@ status:
namespace: app-created-namespace
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ spec:
volume: vol
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -116,6 +117,7 @@ status:
defaults: {}
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down Expand Up @@ -146,6 +148,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: foo
imageData: {}
vcs: {}
Expand Down Expand Up @@ -209,6 +212,7 @@ status:
namespace: app-created-namespace
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ spec:
stop: false
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -136,6 +137,7 @@ status:
defaults: {}
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down Expand Up @@ -202,6 +204,7 @@ spec:
value: outervalue
status:
appImage:
buildContext: {}
id: foo
imageData: {}
vcs: {}
Expand Down Expand Up @@ -253,6 +256,7 @@ status:
namespace: app-created-namespace
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
spec: {}
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -22,6 +23,7 @@ status:
namespace: default-1234567890ab
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand All @@ -37,6 +39,7 @@ metadata:
spec: {}
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -51,6 +54,7 @@ status:
namespace: default-1234567890ab
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
image: myimage:latest
status:
appImage:
buildContext: {}
imageData: {}
vcs: {}
appSpec: {}
Expand All @@ -24,6 +25,7 @@ status:
namespace: app-created-namespace
staged:
appImage:
buildContext: {}
digest: sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
imageData: {}
name: myimage:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: test
imageData: {}
vcs: {}
Expand Down Expand Up @@ -258,6 +259,7 @@ status:
memory: 2Mi
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: test
imageData: {}
vcs: {}
Expand Down Expand Up @@ -257,6 +258,7 @@ status:
memory: 1Mi
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: test
imageData: {}
vcs: {}
Expand Down Expand Up @@ -257,6 +258,7 @@ status:
memory: 1Mi
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: test
imageData: {}
vcs: {}
Expand Down Expand Up @@ -408,6 +409,7 @@ status:
memory: 1Mi
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ spec:
image: test
status:
appImage:
buildContext: {}
id: test
imageData: {}
vcs: {}
Expand Down Expand Up @@ -225,6 +226,7 @@ status:
memory: 1Mi
staged:
appImage:
buildContext: {}
imageData: {}
vcs: {}
summary: {}
Expand Down
Loading