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

Commit a0d7930

Browse files
Merge pull request #2058 from ibuildthecloud/main
Add name to all resources in acornfile
2 parents 29717d0 + e370727 commit a0d7930

File tree

8 files changed

+90
-7
lines changed

8 files changed

+90
-7
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ replace (
1313
require (
1414
cuelang.org/go v0.5.0
1515
github.com/AlecAivazis/survey/v2 v2.3.6
16-
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775
16+
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c
1717
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0
1818
github.com/acorn-io/mink v0.0.0-20230804175412-8d121aae112c
1919
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY
9292
github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE=
9393
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
9494
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
95-
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775 h1:K4vvon2mKG7/+eb1aGMUXLdSXebPAYUM+azb6L6IKRM=
96-
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
95+
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c h1:S3TEHyI7VtPm54Nwrg4Su7fnWClD9/AwlIPujDqjFGs=
96+
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
9797
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0 h1:drWnpW23C7OykbTp9uD6tljFXs1jeicOmatDifbHNog=
9898
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0/go.mod h1:LtwaWrYK/VuGptWxeD5Sgl0sgJV1ksicpTzyLilow1U=
9999
github.com/acorn-io/mink v0.0.0-20230804175412-8d121aae112c h1:3equCG9oMf2I5iDZxllb41jmNNSTiIpU3IegCHBtVyk=

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

+6
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ type ScopedLabels []ScopedLabel
632632
type Container struct {
633633
Labels map[string]string `json:"labels,omitempty"`
634634
Annotations map[string]string `json:"annotations,omitempty"`
635+
Name string `json:"name,omitempty"`
635636
Description string `json:"description,omitempty"`
636637
Dirs map[string]VolumeMount `json:"dirs,omitempty"`
637638
Files Files `json:"files,omitempty"`
@@ -704,6 +705,7 @@ type Routes []Route
704705
type Router struct {
705706
Labels map[string]string `json:"labels,omitempty"`
706707
Annotations map[string]string `json:"annotations,omitempty"`
708+
Name string `json:"name,omitempty"`
707709
Description string `json:"description,omitempty"`
708710
Routes Routes `json:"routes,omitempty"`
709711
}
@@ -719,6 +721,7 @@ func (in Acorn) GetOriginalImage() string {
719721
type Acorn struct {
720722
Labels ScopedLabels `json:"labels,omitempty"`
721723
Annotations ScopedLabels `json:"annotations,omitempty"`
724+
Name string `json:"name,omitempty"`
722725
Description string `json:"description,omitempty"`
723726
Image string `json:"image,omitempty"`
724727
Build *AcornBuild `json:"build,omitempty"`
@@ -743,6 +746,7 @@ type Secret struct {
743746
Alias string `json:"alias,omitempty"`
744747
Labels map[string]string `json:"labels,omitempty"`
745748
Annotations map[string]string `json:"annotations,omitempty"`
749+
Name string `json:"name,omitempty"`
746750
Description string `json:"description,omitempty"`
747751
Type string `json:"type,omitempty"`
748752
Params GenericMap `json:"params,omitempty"`
@@ -754,6 +758,7 @@ type AccessModes []AccessMode
754758
type VolumeRequest struct {
755759
Labels map[string]string `json:"labels,omitempty"`
756760
Annotations map[string]string `json:"annotations,omitempty"`
761+
Name string `json:"name,omitempty"`
757762
Description string `json:"description,omitempty"`
758763
Class string `json:"class,omitempty"`
759764
Size Quantity `json:"size,omitempty"`
@@ -778,6 +783,7 @@ type GeneratedService struct {
778783
type Service struct {
779784
Labels ScopedLabels `json:"labels,omitempty"`
780785
Annotations ScopedLabels `json:"annotations,omitempty"`
786+
Name string `json:"name,omitempty"`
781787
Description string `json:"description,omitempty"`
782788
Default bool `json:"default,omitempty"`
783789
External string `json:"external,omitempty"`

pkg/build/build.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ func build(ctx *buildContext) (*v1.AppImage, error) {
9898

9999
var dataFiles appdefinition.DataFiles
100100
if buildSpec.Icon != "" {
101-
dataFiles.Icon, err = getFile(ctx, buildSpec.Icon)
101+
dataFiles.Icon, err = getFile(ctx, filepath.Join(ctx.cwd, buildSpec.Icon))
102102
if err != nil {
103103
return nil, err
104104
}
105105
dataFiles.IconSuffix = filepath.Ext(buildSpec.Icon)
106106
}
107107

108108
if buildSpec.Readme != "" {
109-
dataFiles.Readme, err = getFile(ctx, buildSpec.Readme)
109+
dataFiles.Readme, err = getFile(ctx, filepath.Join(ctx.cwd, buildSpec.Readme))
110110
if err != nil {
111111
return nil, err
112112
}

pkg/controller/appstatus/secrets.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (a *appStatusRenderer) readSecrets() (err error) {
5858

5959
sourceSecret := &corev1.Secret{}
6060
if err := a.c.Get(a.ctx, router.Key(a.app.Namespace, secret.Labels[labels.AcornSecretSourceName]), sourceSecret); apierrors.IsNotFound(err) {
61+
s.State = "waiting"
6162
a.app.Status.AppStatus.Secrets[secretName] = s
6263
continue
6364
} else if err != nil {

pkg/openapi/generated/openapi_generated.go

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/secrets/interpolation.go

+4
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ func (i *Interpolator) resolve(token string) (_ string, _ bool, err error) {
420420
}
421421
}()
422422

423+
if strings.HasPrefix(token, "@{") {
424+
return token, true, nil
425+
}
426+
423427
scheme, tail, ok := strings.Cut(token, "://")
424428
if ok {
425429
switch scheme {

pkg/server/registry/apigroups/acorn/apps/info.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import (
88
apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
99
v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1"
1010
kclient "github.com/acorn-io/runtime/pkg/k8sclient"
11+
"github.com/acorn-io/runtime/pkg/labels"
1112
"github.com/acorn-io/runtime/pkg/secrets"
13+
apierrors "k8s.io/apimachinery/pkg/api/errors"
1214
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
klabels "k8s.io/apimachinery/pkg/labels"
16+
"k8s.io/apimachinery/pkg/runtime/schema"
1317
"k8s.io/apiserver/pkg/endpoints/request"
1418
"k8s.io/apiserver/pkg/registry/rest"
1519
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -30,19 +34,39 @@ type InfoStrategy struct {
3034
func (s *InfoStrategy) Get(ctx context.Context, namespace, name string) (types.Object, error) {
3135
ri, _ := request.RequestInfoFrom(ctx)
3236

33-
app := &v1.AppInstance{}
37+
app := &apiv1.App{}
3438
err := s.client.Get(ctx, kclient.ObjectKey{Namespace: ri.Namespace, Name: ri.Name}, app)
3539
if err != nil {
3640
return nil, err
3741
}
3842

43+
appInstances := &v1.AppInstanceList{}
44+
err = s.client.List(ctx, appInstances, &kclient.ListOptions{
45+
LabelSelector: klabels.SelectorFromSet(klabels.Set{
46+
labels.AcornPublicName: name,
47+
}),
48+
Namespace: ri.Namespace,
49+
})
50+
if err != nil {
51+
return nil, err
52+
}
53+
54+
if len(appInstances.Items) != 1 {
55+
return nil, apierrors.NewNotFound(schema.GroupResource{
56+
Group: apiv1.SchemeGroupVersion.Group,
57+
Resource: "apps",
58+
}, name)
59+
}
60+
61+
appInstance := &appInstances.Items[0]
62+
3963
resp := &apiv1.AppInfo{
4064
ObjectMeta: metav1.ObjectMeta{
4165
Name: ri.Name,
4266
Namespace: ri.Namespace,
4367
},
4468
}
45-
resp.Info, err = secrets.NewInterpolator(ctx, s.client, app).Replace(app.Status.AppSpec.Info)
69+
resp.Info, err = secrets.NewInterpolator(ctx, s.client, appInstance).Replace(appInstance.Status.AppSpec.Info)
4670
if err != nil {
4771
resp.InterpolationError = err.Error()
4872
}

0 commit comments

Comments
 (0)