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

Commit

Permalink
Merge pull request #2058 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
Add name to all resources in acornfile
  • Loading branch information
ibuildthecloud committed Aug 14, 2023
2 parents 29717d0 + e370727 commit a0d7930
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ replace (
require (
cuelang.org/go v0.5.0
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0
github.com/acorn-io/mink v0.0.0-20230804175412-8d121aae112c
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY
github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775 h1:K4vvon2mKG7/+eb1aGMUXLdSXebPAYUM+azb6L6IKRM=
github.com/acorn-io/aml v0.0.0-20230810193619-44518c9bc775/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c h1:S3TEHyI7VtPm54Nwrg4Su7fnWClD9/AwlIPujDqjFGs=
github.com/acorn-io/aml v0.0.0-20230814072513-12acbd5f883c/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0 h1:drWnpW23C7OykbTp9uD6tljFXs1jeicOmatDifbHNog=
github.com/acorn-io/baaah v0.0.0-20230809195515-5b03d4cd75f0/go.mod h1:LtwaWrYK/VuGptWxeD5Sgl0sgJV1ksicpTzyLilow1U=
github.com/acorn-io/mink v0.0.0-20230804175412-8d121aae112c h1:3equCG9oMf2I5iDZxllb41jmNNSTiIpU3IegCHBtVyk=
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/internal.acorn.io/v1/appspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ type ScopedLabels []ScopedLabel
type Container struct {
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Dirs map[string]VolumeMount `json:"dirs,omitempty"`
Files Files `json:"files,omitempty"`
Expand Down Expand Up @@ -704,6 +705,7 @@ type Routes []Route
type Router struct {
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Routes Routes `json:"routes,omitempty"`
}
Expand All @@ -719,6 +721,7 @@ func (in Acorn) GetOriginalImage() string {
type Acorn struct {
Labels ScopedLabels `json:"labels,omitempty"`
Annotations ScopedLabels `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Image string `json:"image,omitempty"`
Build *AcornBuild `json:"build,omitempty"`
Expand All @@ -743,6 +746,7 @@ type Secret struct {
Alias string `json:"alias,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
Params GenericMap `json:"params,omitempty"`
Expand All @@ -754,6 +758,7 @@ type AccessModes []AccessMode
type VolumeRequest struct {
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Class string `json:"class,omitempty"`
Size Quantity `json:"size,omitempty"`
Expand All @@ -778,6 +783,7 @@ type GeneratedService struct {
type Service struct {
Labels ScopedLabels `json:"labels,omitempty"`
Annotations ScopedLabels `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Default bool `json:"default,omitempty"`
External string `json:"external,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ func build(ctx *buildContext) (*v1.AppImage, error) {

var dataFiles appdefinition.DataFiles
if buildSpec.Icon != "" {
dataFiles.Icon, err = getFile(ctx, buildSpec.Icon)
dataFiles.Icon, err = getFile(ctx, filepath.Join(ctx.cwd, buildSpec.Icon))
if err != nil {
return nil, err
}
dataFiles.IconSuffix = filepath.Ext(buildSpec.Icon)
}

if buildSpec.Readme != "" {
dataFiles.Readme, err = getFile(ctx, buildSpec.Readme)
dataFiles.Readme, err = getFile(ctx, filepath.Join(ctx.cwd, buildSpec.Readme))
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/appstatus/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (a *appStatusRenderer) readSecrets() (err error) {

sourceSecret := &corev1.Secret{}
if err := a.c.Get(a.ctx, router.Key(a.app.Namespace, secret.Labels[labels.AcornSecretSourceName]), sourceSecret); apierrors.IsNotFound(err) {
s.State = "waiting"
a.app.Status.AppStatus.Secrets[secretName] = s
continue
} else if err != nil {
Expand Down
48 changes: 48 additions & 0 deletions pkg/openapi/generated/openapi_generated.go

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

4 changes: 4 additions & 0 deletions pkg/secrets/interpolation.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ func (i *Interpolator) resolve(token string) (_ string, _ bool, err error) {
}
}()

if strings.HasPrefix(token, "@{") {
return token, true, nil
}

scheme, tail, ok := strings.Cut(token, "://")
if ok {
switch scheme {
Expand Down
28 changes: 26 additions & 2 deletions pkg/server/registry/apigroups/acorn/apps/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import (
apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1"
kclient "github.com/acorn-io/runtime/pkg/k8sclient"
"github.com/acorn-io/runtime/pkg/labels"
"github.com/acorn-io/runtime/pkg/secrets"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
klabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -30,19 +34,39 @@ type InfoStrategy struct {
func (s *InfoStrategy) Get(ctx context.Context, namespace, name string) (types.Object, error) {
ri, _ := request.RequestInfoFrom(ctx)

app := &v1.AppInstance{}
app := &apiv1.App{}
err := s.client.Get(ctx, kclient.ObjectKey{Namespace: ri.Namespace, Name: ri.Name}, app)
if err != nil {
return nil, err
}

appInstances := &v1.AppInstanceList{}
err = s.client.List(ctx, appInstances, &kclient.ListOptions{
LabelSelector: klabels.SelectorFromSet(klabels.Set{
labels.AcornPublicName: name,
}),
Namespace: ri.Namespace,
})
if err != nil {
return nil, err
}

if len(appInstances.Items) != 1 {
return nil, apierrors.NewNotFound(schema.GroupResource{
Group: apiv1.SchemeGroupVersion.Group,
Resource: "apps",
}, name)
}

appInstance := &appInstances.Items[0]

resp := &apiv1.AppInfo{
ObjectMeta: metav1.ObjectMeta{
Name: ri.Name,
Namespace: ri.Namespace,
},
}
resp.Info, err = secrets.NewInterpolator(ctx, s.client, app).Replace(app.Status.AppSpec.Info)
resp.Info, err = secrets.NewInterpolator(ctx, s.client, appInstance).Replace(appInstance.Status.AppSpec.Info)
if err != nil {
resp.InterpolationError = err.Error()
}
Expand Down

0 comments on commit a0d7930

Please sign in to comment.