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

Commit be8054c

Browse files
author
Oscar Ward
authored
handle dev clone on nested acorns (#2247) (#2252)
1 parent 5763b65 commit be8054c

File tree

133 files changed

+362
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+362
-23
lines changed

pkg/apis/internal.acorn.io/v1/appimage.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ type AppImage struct {
55
// ImageInstance.Name
66
ID string `json:"id,omitempty"`
77
// Name is the image name requested by the user of any format
8-
Name string `json:"name,omitempty"`
9-
Digest string `json:"digest,omitempty"`
10-
Acornfile string `json:"acornfile,omitempty"`
11-
ImageData ImagesData `json:"imageData,omitempty"`
12-
BuildArgs *GenericMap `json:"buildArgs,omitempty"`
13-
Profiles []string `json:"profiles,omitempty"`
14-
VCS VCS `json:"vcs,omitempty"`
15-
Version *AppImageVersion `json:"version,omitempty"`
8+
Name string `json:"name,omitempty"`
9+
Digest string `json:"digest,omitempty"`
10+
Acornfile string `json:"acornfile,omitempty"`
11+
ImageData ImagesData `json:"imageData,omitempty"`
12+
BuildArgs *GenericMap `json:"buildArgs,omitempty"`
13+
BuildContext BuildContext `json:"buildContext,omitempty"`
14+
Profiles []string `json:"profiles,omitempty"`
15+
VCS VCS `json:"vcs,omitempty"`
16+
Version *AppImageVersion `json:"version,omitempty"`
17+
}
18+
19+
type BuildContext struct {
20+
Cwd string `json:"cwd,omitempty"`
21+
AcornfilePath string `json:"acornfilePath,omitempty"`
1622
}
1723

1824
type AppImageVersion struct {

pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/appdefinition/appdefinition.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ import (
2424
)
2525

2626
const (
27-
IconFile = "icon"
28-
ReadmeFile = "README"
29-
Acornfile = "Acornfile"
30-
ImageDataFile = "images.json"
31-
VersionFile = "version.json"
32-
VCSDataFile = "vcs.json"
33-
BuildDataFile = "build.json"
34-
messageSuffix = ", you may need to define the image/build in the images section of the Acornfile"
27+
IconFile = "icon"
28+
ReadmeFile = "README"
29+
Acornfile = "Acornfile"
30+
ImageDataFile = "images.json"
31+
VersionFile = "version.json"
32+
VCSDataFile = "vcs.json"
33+
BuildDataFile = "build.json"
34+
BuildContextFile = "build-context.json"
35+
messageSuffix = ", you may need to define the image/build in the images section of the Acornfile"
3536

3637
AcornfileSchemaVersion = "v1"
3738
V0Pragma = "//acorn:amlv0"
@@ -476,6 +477,11 @@ func AppImageFromTar(reader io.Reader) (*v1.AppImage, *DataFiles, error) {
476477
if err != nil {
477478
return nil, nil, err
478479
}
480+
case BuildContextFile:
481+
err := json.NewDecoder(tar).Decode(&result.BuildContext)
482+
if err != nil {
483+
return nil, nil, err
484+
}
479485
case ReadmeFile:
480486
dataFiles.Readme, err = io.ReadAll(tar)
481487
if err != nil {

pkg/build/app.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func getContextFromAppImage(dataFiles appdefinition.DataFiles, appImage *v1.AppI
111111
return "", err
112112
}
113113
}
114+
if err := addFile(tempDir, appdefinition.BuildContextFile, appImage.BuildContext); err != nil {
115+
return "", err
116+
}
114117
return tempDir, nil
115118
}
116119

pkg/build/build.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ func build(ctx *buildContext) (*v1.AppImage, error) {
117117
Acornfile: string(acornfileData),
118118
ImageData: imageData,
119119
BuildArgs: v1.NewGenericMap(buildArgs),
120-
Profiles: profiles,
121-
VCS: ctx.opts.VCS,
120+
BuildContext: v1.BuildContext{
121+
Cwd: ctx.cwd,
122+
AcornfilePath: ctx.acornfilePath,
123+
},
124+
Profiles: profiles,
125+
VCS: ctx.opts.VCS,
122126
}
123127
if err != nil {
124128
return nil, err
@@ -239,6 +243,8 @@ func buildAcorns(ctx *buildContext, acorns map[string]v1.AcornBuilderSpec) (map[
239243
newCtx.opts.Acornfile = ""
240244
newCtx.acornfilePath = filepath.Join(ctx.cwd, acornImage.Build.Acornfile)
241245
newCtx.cwd = filepath.Join(ctx.cwd, acornImage.Build.Context)
246+
// We know this field will never be correct for nested build so just blank it out
247+
newCtx.opts.VCS.Acornfile = ""
242248
appImage, err := build(&newCtx)
243249
if err != nil {
244250
return nil, nil, err

pkg/cli/testdata/all/all_test_json.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ ACORNS:
2020
"staged": {
2121
"appImage": {
2222
"imageData": {},
23+
"buildContext": {},
2324
"vcs": {}
2425
}
2526
},
2627
"appImage": {
2728
"imageData": {},
29+
"buildContext": {},
2830
"vcs": {}
2931
},
3032
"appSpec": {},

pkg/cli/testdata/all/all_test_yaml.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ items:
1111
target: found
1212
status:
1313
appImage:
14+
buildContext: {}
1415
imageData: {}
1516
vcs: {}
1617
appSpec: {}
@@ -19,6 +20,7 @@ items:
1920
defaults: {}
2021
staged:
2122
appImage:
23+
buildContext: {}
2224
imageData: {}
2325
vcs: {}
2426
summary: {}

pkg/controller/appdefinition/testdata/TestComputeMem.golden

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ spec:
7979
stop: false
8080
status:
8181
appImage:
82+
buildContext: {}
8283
imageData: {}
8384
vcs: {}
8485
appSpec: {}
@@ -87,6 +88,7 @@ status:
8788
defaults: {}
8889
staged:
8990
appImage:
91+
buildContext: {}
9092
imageData: {}
9193
vcs: {}
9294
summary: {}
@@ -117,6 +119,7 @@ spec:
117119
stop: false
118120
status:
119121
appImage:
122+
buildContext: {}
120123
imageData: {}
121124
vcs: {}
122125
appSpec: {}
@@ -125,6 +128,7 @@ status:
125128
defaults: {}
126129
staged:
127130
appImage:
131+
buildContext: {}
128132
imageData: {}
129133
vcs: {}
130134
summary: {}
@@ -175,6 +179,7 @@ spec:
175179
byname.child: 3
176180
status:
177181
appImage:
182+
buildContext: {}
178183
id: foo
179184
imageData: {}
180185
vcs: {}
@@ -195,6 +200,7 @@ status:
195200
namespace: app-created-namespace
196201
staged:
197202
appImage:
203+
buildContext: {}
198204
imageData: {}
199205
vcs: {}
200206
summary: {}

pkg/controller/appdefinition/testdata/acorn/basic/expected.golden

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ spec:
108108
volume: vol
109109
status:
110110
appImage:
111+
buildContext: {}
111112
imageData: {}
112113
vcs: {}
113114
appSpec: {}
@@ -116,6 +117,7 @@ status:
116117
defaults: {}
117118
staged:
118119
appImage:
120+
buildContext: {}
119121
imageData: {}
120122
vcs: {}
121123
summary: {}
@@ -146,6 +148,7 @@ spec:
146148
image: test
147149
status:
148150
appImage:
151+
buildContext: {}
149152
id: foo
150153
imageData: {}
151154
vcs: {}
@@ -209,6 +212,7 @@ status:
209212
namespace: app-created-namespace
210213
staged:
211214
appImage:
215+
buildContext: {}
212216
imageData: {}
213217
vcs: {}
214218
summary: {}

pkg/controller/appdefinition/testdata/acorn/labels/expected.golden

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ spec:
128128
stop: false
129129
status:
130130
appImage:
131+
buildContext: {}
131132
imageData: {}
132133
vcs: {}
133134
appSpec: {}
@@ -136,6 +137,7 @@ status:
136137
defaults: {}
137138
staged:
138139
appImage:
140+
buildContext: {}
139141
imageData: {}
140142
vcs: {}
141143
summary: {}
@@ -202,6 +204,7 @@ spec:
202204
value: outervalue
203205
status:
204206
appImage:
207+
buildContext: {}
205208
id: foo
206209
imageData: {}
207210
vcs: {}
@@ -253,6 +256,7 @@ status:
253256
namespace: app-created-namespace
254257
staged:
255258
appImage:
259+
buildContext: {}
256260
imageData: {}
257261
vcs: {}
258262
summary: {}

pkg/controller/appdefinition/testdata/assignnamespace/expected.golden

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
spec: {}
99
status:
1010
appImage:
11+
buildContext: {}
1112
imageData: {}
1213
vcs: {}
1314
appSpec: {}
@@ -22,6 +23,7 @@ status:
2223
namespace: default-1234567890ab
2324
staged:
2425
appImage:
26+
buildContext: {}
2527
imageData: {}
2628
vcs: {}
2729
summary: {}
@@ -37,6 +39,7 @@ metadata:
3739
spec: {}
3840
status:
3941
appImage:
42+
buildContext: {}
4043
imageData: {}
4144
vcs: {}
4245
appSpec: {}
@@ -51,6 +54,7 @@ status:
5154
namespace: default-1234567890ab
5255
staged:
5356
appImage:
57+
buildContext: {}
5458
imageData: {}
5559
vcs: {}
5660
summary: {}

pkg/controller/appdefinition/testdata/autoupgrade/with-local-image/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ spec:
1010
image: myimage:latest
1111
status:
1212
appImage:
13+
buildContext: {}
1314
imageData: {}
1415
vcs: {}
1516
appSpec: {}
@@ -24,6 +25,7 @@ status:
2425
namespace: app-created-namespace
2526
staged:
2627
appImage:
28+
buildContext: {}
2729
digest: sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2830
imageData: {}
2931
name: myimage:latest

pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ spec:
185185
image: test
186186
status:
187187
appImage:
188+
buildContext: {}
188189
id: test
189190
imageData: {}
190191
vcs: {}
@@ -258,6 +259,7 @@ status:
258259
memory: 2Mi
259260
staged:
260261
appImage:
262+
buildContext: {}
261263
imageData: {}
262264
vcs: {}
263265
summary: {}

pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ spec:
184184
image: test
185185
status:
186186
appImage:
187+
buildContext: {}
187188
id: test
188189
imageData: {}
189190
vcs: {}
@@ -257,6 +258,7 @@ status:
257258
memory: 1Mi
258259
staged:
259260
appImage:
261+
buildContext: {}
260262
imageData: {}
261263
vcs: {}
262264
summary: {}

pkg/controller/appdefinition/testdata/computeclass/container/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ spec:
184184
image: test
185185
status:
186186
appImage:
187+
buildContext: {}
187188
id: test
188189
imageData: {}
189190
vcs: {}
@@ -257,6 +258,7 @@ status:
257258
memory: 1Mi
258259
staged:
259260
appImage:
261+
buildContext: {}
260262
imageData: {}
261263
vcs: {}
262264
summary: {}

pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ spec:
324324
image: test
325325
status:
326326
appImage:
327+
buildContext: {}
327328
id: test
328329
imageData: {}
329330
vcs: {}
@@ -408,6 +409,7 @@ status:
408409
memory: 1Mi
409410
staged:
410411
appImage:
412+
buildContext: {}
411413
imageData: {}
412414
vcs: {}
413415
summary: {}

pkg/controller/appdefinition/testdata/computeclass/job/expected.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ spec:
150150
image: test
151151
status:
152152
appImage:
153+
buildContext: {}
153154
id: test
154155
imageData: {}
155156
vcs: {}
@@ -225,6 +226,7 @@ status:
225226
memory: 1Mi
226227
staged:
227228
appImage:
229+
buildContext: {}
228230
imageData: {}
229231
vcs: {}
230232
summary: {}

0 commit comments

Comments
 (0)