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

Commit 6ffd09b

Browse files
Merge pull request #1541 from ibuildthecloud/main
Service fixes
2 parents 755bee0 + fd43297 commit 6ffd09b

File tree

77 files changed

+1015
-156
lines changed

Some content is hidden

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

77 files changed

+1015
-156
lines changed

docs/docs/100-reference/01-command-line/acorn_image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ acorn images
4040
### SEE ALSO
4141

4242
* [acorn](acorn.md) -
43+
* [acorn image detail](acorn_image_detail.md) - Show details of an Image
4344
* [acorn image rm](acorn_image_rm.md) - Delete an Image
4445

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "acorn image detail"
3+
---
4+
## acorn image detail
5+
6+
Show details of an Image
7+
8+
```
9+
acorn image detail IMAGE_NAME [NESTED DIGEST] [flags]
10+
```
11+
12+
### Examples
13+
14+
```
15+
acorn image detail my-image
16+
```
17+
18+
### Options
19+
20+
```
21+
-h, --help help for detail
22+
-o, --output string Output format (json, yaml, aml) (default "aml")
23+
```
24+
25+
### Options inherited from parent commands
26+
27+
```
28+
-A, --all-projects Use all known projects
29+
--debug Enable debug logging
30+
--debug-level int Debug log level (valid 0-9) (default 7)
31+
--kubeconfig string Explicitly use kubeconfig file, overriding current project
32+
-j, --project string Project to work in
33+
```
34+
35+
### SEE ALSO
36+
37+
* [acorn image](acorn_image.md) - Manage images
38+

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ replace (
1717
require (
1818
cuelang.org/go v0.4.3
1919
github.com/AlecAivazis/survey/v2 v2.3.6
20-
github.com/acorn-io/aml v0.0.0-20230418220934-5635aac007d1
21-
github.com/acorn-io/baaah v0.0.0-20230410050548-f08516abc5c3
20+
github.com/acorn-io/aml v0.0.0-20230428030628-bf98aa39a36a
21+
github.com/acorn-io/baaah v0.0.0-20230428031609-d553bca0d3d8
2222
github.com/acorn-io/mink v0.0.0-20230424190003-9a32355ec823
2323
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78
2424
github.com/adrg/xdg v0.4.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR
156156
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
157157
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
158158
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
159-
github.com/acorn-io/aml v0.0.0-20230418220934-5635aac007d1 h1:kWQ+df1awdZPPVYeVy6fpp5Kw7ueasTSgPlU2oSJZJk=
160-
github.com/acorn-io/aml v0.0.0-20230418220934-5635aac007d1/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
159+
github.com/acorn-io/aml v0.0.0-20230428030628-bf98aa39a36a h1:yI6MDJU3pcbieiqvNCbqDzu8getkxfwc799NMQrsi58=
160+
github.com/acorn-io/aml v0.0.0-20230428030628-bf98aa39a36a/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
161161
github.com/acorn-io/apiserver v0.25.2-ot-2 h1:drxKtiHh2dGnKlhVYxgPCKkFXRvMFxdflCZ5fHpVp8E=
162162
github.com/acorn-io/apiserver v0.25.2-ot-2/go.mod h1:qRxmYneSxb8B1FYvgQf6mPeWuwugIzYKN3TeMmL4FVo=
163-
github.com/acorn-io/baaah v0.0.0-20230410050548-f08516abc5c3 h1:GQZOLkMwPTWlZgIcPs8hMClk4GRcQPMlwuax/IXq5hA=
164-
github.com/acorn-io/baaah v0.0.0-20230410050548-f08516abc5c3/go.mod h1:yE5MQ1xi7osIDHNnBdmdTHmtnBbYxHQgQfXm/q2bbkU=
163+
github.com/acorn-io/baaah v0.0.0-20230428031609-d553bca0d3d8 h1:8DA+z4B0aC+u4x1H+3vlgQHytVlyxlkNdS1aMYE/Y+A=
164+
github.com/acorn-io/baaah v0.0.0-20230428031609-d553bca0d3d8/go.mod h1:yE5MQ1xi7osIDHNnBdmdTHmtnBbYxHQgQfXm/q2bbkU=
165165
github.com/acorn-io/component-base v0.25.2-ot-1 h1:xinqJUNbpW2/zsvm8mDv6Q7riLhvXup9x7Kz9eIPM1M=
166166
github.com/acorn-io/component-base v0.25.2-ot-1/go.mod h1:/5qYr5BXGNPs+cRd6+WL1NfOYtzOstJlm1CMK06cm7s=
167167
github.com/acorn-io/etcd/client/pkg/v3 v3.6.0-ot-1 h1:u2g5S6DbDNyueFeRSAVIBGMrkyLlcBLhTmH8l0a/4DM=

integration/build/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestSimpleTwo(t *testing.T) {
153153
assert.Len(t, image.ImageData.Images, 3)
154154
assert.True(t, len(image.ImageData.Images["ione"].Image) > 0)
155155
assert.True(t, len(image.ImageData.Images["itwo"].Image) > 0)
156-
assert.True(t, len(image.ImageData.Images["three"].Image) > 0)
156+
assert.True(t, len(image.ImageData.Images["ithree"].Image) > 0)
157157
// This isn't always true, no idea why, one day maybe we'll know
158158
//assert.Equal(t, image.ImageData.Containers["two"].Image, image.ImageData.Images["itwo"].Image)
159159
}

integration/build/testdata/simple-two/Acornfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ images: {
2020
context: "two/subdir/subdir2"
2121
}
2222
}
23-
three: {
23+
ithree: {
2424
image: "ghcr.io/acorn-io/images-mirror/busybox:latest"
2525
}
2626
}

integration/helper/wait.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,16 @@ func WaitForObject[T client.Object](t *testing.T, watchFunc WatchFunc, list clie
125125
}
126126

127127
func EnsureDoesNotExist(ctx context.Context, getter func() (client.Object, error)) error {
128-
ticker := time.NewTicker(5 * time.Second)
128+
ticker := time.NewTicker(1 * time.Second)
129129
defer ticker.Stop()
130130
ctx, cancel := context.WithTimeout(ctx, time.Duration(WatchTimeoutSeconds)*time.Second)
131131
defer cancel()
132+
133+
_, err := getter()
134+
if apierrors.IsNotFound(err) {
135+
return nil
136+
}
137+
132138
for {
133139
select {
134140
case <-ctx.Done():

integration/run/run_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/acorn-io/acorn/pkg/run"
2121
"github.com/acorn-io/acorn/pkg/scheme"
2222
"github.com/acorn-io/acorn/pkg/tolerations"
23+
"github.com/acorn-io/baaah/pkg/apply"
2324
"github.com/acorn-io/baaah/pkg/restconfig"
2425
"github.com/acorn-io/baaah/pkg/router"
2526
"github.com/acorn-io/baaah/pkg/watcher"
@@ -1146,6 +1147,38 @@ func TestUsingComputeClasses(t *testing.T) {
11461147
}
11471148
}
11481149

1150+
func TestJobDelete(t *testing.T) {
1151+
helper.StartController(t)
1152+
1153+
ctx := helper.GetCTX(t)
1154+
c, _ := helper.ClientAndNamespace(t)
1155+
1156+
image, err := c.AcornImageBuild(ctx, "./testdata/jobfinalize/Acornfile", &client.AcornImageBuildOptions{
1157+
Cwd: "./testdata/jobfinalize",
1158+
})
1159+
if err != nil {
1160+
t.Fatal(err)
1161+
}
1162+
1163+
app, err := c.AppRun(ctx, image.ID, nil)
1164+
if err != nil {
1165+
t.Fatal(err)
1166+
}
1167+
1168+
app = helper.WaitForObject(t, helper.Watcher(t, c), new(apiv1.AppList), app, func(app *apiv1.App) bool {
1169+
return len(app.Finalizers) > 0 && app.Annotations[apply.AnnotationPrune] == "false"
1170+
})
1171+
1172+
app, err = c.AppDelete(ctx, app.Name)
1173+
if err != nil {
1174+
t.Fatal(err)
1175+
}
1176+
1177+
_ = helper.EnsureDoesNotExist(ctx, func() (crClient.Object, error) {
1178+
return c.AppGet(ctx, app.Name)
1179+
})
1180+
}
1181+
11491182
func TestAppWithBadRegion(t *testing.T) {
11501183
helper.StartController(t)
11511184

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
jobs: delete: {
2+
image: "ghcr.io/acorn-io/images-mirror/busybox:latest"
3+
onDelete: true
4+
dirs: "/app": "./scripts"
5+
command: "/app/run.sh"
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
set -x -e
3+
[ "$ACORN_EVENT" = "onDelete" ]

integration/services/testdata/Acornfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs: test: {
2424
files: "/run/secrets/admin-pass": "f@{secrets.build.admin.password}"
2525
files: "/run/secrets/admin-user": "secret://build.admin/username"
2626
dirs: "/run/secrets/admin": "secret://build.admin"
27-
}
27+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ type Container struct {
371371
// Schedule is only available on jobs
372372
Schedule string `json:"schedule,omitempty"`
373373

374+
// OnDelete is only available on jobs
375+
OnDelete bool `json:"onDelete,omitempty"`
376+
374377
// Init is only available on sidecars
375378
Init bool `json:"init,omitempty"`
376379

@@ -476,7 +479,6 @@ type Service struct {
476479
Environment NameValues `json:"environment,omitempty"`
477480
Secrets SecretBindings `json:"secrets,omitempty"`
478481
Links ServiceBindings `json:"links,omitempty"`
479-
Permissions []Permissions `json:"permissions,omitempty"`
480482
AutoUpgrade *bool `json:"autoUpgrade,omitempty"`
481483
NotifyUpgrade *bool `json:"notifyUpgrade,omitempty"`
482484
AutoUpgradeInterval string `json:"autoUpgradeInterval,omitempty"`

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,49 @@ type ContainerImageBuilderSpec struct {
1515
Sidecars map[string]ContainerImageBuilderSpec `json:"sidecars,omitempty"`
1616
}
1717

18+
func (in *ContainerImageBuilderSpec) Normalize() *ContainerImageBuilderSpec {
19+
out := *in
20+
if out.Image != "" {
21+
out.Build = nil
22+
}
23+
if len(in.Sidecars) > 0 {
24+
out.Sidecars = map[string]ContainerImageBuilderSpec{}
25+
for k, v := range in.Sidecars {
26+
out.Sidecars[k] = *v.Normalize()
27+
}
28+
}
29+
return &out
30+
}
31+
1832
type ImageBuilderSpec struct {
1933
Image string `json:"image,omitempty"`
2034
ContainerBuild *Build `json:"containerBuild,omitempty"`
2135
AcornBuild *AcornBuild `json:"acornBuild,omitempty"`
2236
}
2337

38+
func (in *ImageBuilderSpec) Normalize() *ImageBuilderSpec {
39+
out := *in
40+
if out.Image != "" {
41+
out.ContainerBuild = nil
42+
out.AcornBuild = nil
43+
}
44+
return &out
45+
}
46+
2447
type AcornBuilderSpec struct {
2548
AutoUpgrade bool `json:"autoUpgrade,omitempty"`
2649
Image string `json:"image,omitempty"`
2750
Build *AcornBuild `json:"build,omitempty"`
2851
}
2952

53+
func (in *AcornBuilderSpec) Normalize() *AcornBuilderSpec {
54+
out := *in
55+
if out.Image != "" {
56+
out.Build = nil
57+
}
58+
return &out
59+
}
60+
3061
type BuilderSpec struct {
3162
Services map[string]AcornBuilderSpec `json:"services,omitempty"`
3263
Containers map[string]ContainerImageBuilderSpec `json:"containers,omitempty"`

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ type ImagesData struct {
1818
Jobs map[string]ContainerData `json:"jobs,omitempty"`
1919
Images map[string]ImageData `json:"images,omitempty"`
2020
Acorns map[string]ImageData `json:"acorns,omitempty"`
21+
Builds []BuildRecord `json:"builds,omitempty"`
22+
}
23+
24+
type BuildRecord struct {
25+
AcornBuild *AcornBuilderSpec `json:"acornBuild,omitempty"`
26+
AcornAppImage *AppImage `json:"acornAppImage,omitempty"`
27+
ContainerBuild *ContainerImageBuilderSpec `json:"containerBuild,omitempty"`
28+
ImageBuild *ImageBuilderSpec `json:"imageBuild,omitempty"`
29+
ImageKey string `json:"imageKey,omitempty"`
2130
}
2231

2332
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ func checkForDuplicateNames(in *AppSpec) error {
387387
return err
388388
}
389389
}
390+
for name := range in.Images {
391+
if err := addName(names, name, "image"); err != nil {
392+
return err
393+
}
394+
}
390395

391396
return nil
392397
}

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

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

0 commit comments

Comments
 (0)