Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ require (
kmodules.xyz/go-containerregistry v0.0.15
kmodules.xyz/monitoring-agent-api v0.34.3
kmodules.xyz/offshoot-api v0.34.0
kmodules.xyz/resource-metadata v0.47.1-0.20260626123515-f3c8c1fb4e83
kmodules.xyz/resource-metadata v0.47.1-0.20260626202730-925518073731
kmodules.xyz/resource-metrics v0.34.4-0.20260626131047-afdc9726717d
kmodules.xyz/resource-metrics/utils v0.34.1-0.20260622121456-42ed2b0a80a4
kmodules.xyz/sets v0.29.0
kubeops.dev/falco-ui-server v0.0.6-0.20251227130353-14d6f838d2f4
kubeops.dev/scanner v0.0.21-0.20251228044914-f03cf9e0e521
kubepack.dev/lib-app v0.16.1-0.20251228165728-e1f332468ae7
kubepack.dev/lib-app v0.23.1-0.20260626193801-519cc46890f2
kubepack.dev/lib-helm v0.34.1
open-cluster-management.io/api v1.2.0
sigs.k8s.io/cli-utils v0.37.2
Expand All @@ -76,7 +76,7 @@ require (
filippo.io/edwards25519 v1.1.1 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0-beta.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
Expand Down Expand Up @@ -116,7 +116,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.30.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.40.2 // indirect
github.com/aws/smithy-go v1.24.2 // indirect
github.com/aws/smithy-go v1.24.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
Expand Down Expand Up @@ -209,7 +209,7 @@ require (
github.com/jonboulle/clockwork v0.5.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.2 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
Expand Down Expand Up @@ -304,7 +304,7 @@ require (
google.golang.org/api v0.256.0 // indirect
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
google.golang.org/grpc v1.80.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 h1:JXg2dwJUmPB9JmtVmdEB16APJ7jurfbY5jnfXpJoRMc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0-beta.3 h1:0g4UTtvRA9goC37cmD9ZHdW6CCNJR4cOXBnHz0r4ubM=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.0-beta.3/go.mod h1:fEiHi0sbYqbo3shUkIF1SNxm8GyeEJl+Poc/djOvbdE=
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY=
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA=
Expand Down Expand Up @@ -141,8 +141,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.7 h1:gTsnx0xXNQ6SBbymoDvcoRHL
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.7/go.mod h1:klO+ejMvYsB4QATfEOIXk8WAEwN4N0aBfJpvC+5SZBo=
github.com/aws/aws-sdk-go-v2/service/sts v1.40.2 h1:HK5ON3KmQV2HcAunnx4sKLB9aPf3gKGwVAf7xnx0QT0=
github.com/aws/aws-sdk-go-v2/service/sts v1.40.2/go.mod h1:E19xDjpzPZC7LS2knI9E6BaRFDK43Eul7vd6rSq2HWk=
github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=
github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/aws/smithy-go v1.24.3 h1:XgOAaUgx+HhVBoP4v8n6HCQoTRDhoMghKqw4LNHsDNg=
github.com/aws/smithy-go v1.24.3/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -512,8 +512,8 @@ github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXw
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kmodules/apimachinery v0.35.0-alpha.0.0.20251228052616-311f10bd421d h1:M+Riuz7kQ+20OFXCOgr0+n8vHDLTbb9WFpzuR3tvlC4=
Expand Down Expand Up @@ -1084,8 +1084,8 @@ google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuO
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down Expand Up @@ -1187,8 +1187,8 @@ kmodules.xyz/monitoring-agent-api v0.34.3 h1:8dCTSatkKbi9CTAQ3+u7OmoyUghLvKTqqcl
kmodules.xyz/monitoring-agent-api v0.34.3/go.mod h1:0WtVdliczkCmjA/QyB2ZriVwABSA8Fhzt01yMEukFLY=
kmodules.xyz/offshoot-api v0.34.0 h1:HnOOp8FrCjTWjtNApRDo6Ahe79tOlLrJmyye4xxO4Kk=
kmodules.xyz/offshoot-api v0.34.0/go.mod h1:F+B59yYw4CZJ4uD4xu6C+mMLzIXUtuH7E+SbDICl9jE=
kmodules.xyz/resource-metadata v0.47.1-0.20260626123515-f3c8c1fb4e83 h1:TDMAyTYHY12VRXwq471jqsUI5VBu/8X9E9ZOMLrlW4g=
kmodules.xyz/resource-metadata v0.47.1-0.20260626123515-f3c8c1fb4e83/go.mod h1:ejz7IVjhqmj6VH8CVfprocJK/IM++OeunrfUp51ZrIw=
kmodules.xyz/resource-metadata v0.47.1-0.20260626202730-925518073731 h1:10DfU8wlQMZuf3zNrm2OifWN9vbUOudkjqjGyWwXJsc=
kmodules.xyz/resource-metadata v0.47.1-0.20260626202730-925518073731/go.mod h1:ejz7IVjhqmj6VH8CVfprocJK/IM++OeunrfUp51ZrIw=
kmodules.xyz/resource-metrics v0.34.4-0.20260626131047-afdc9726717d h1:vgDVnRBzVuhbhlHYi8VWL/mJ8LHNk+z5ipVjIpTA2N4=
kmodules.xyz/resource-metrics v0.34.4-0.20260626131047-afdc9726717d/go.mod h1:R34IKtp5+NqcQz7AQJheBJK6Iem0LqrCbm/55Mn+ECQ=
kmodules.xyz/resource-metrics/utils v0.34.1-0.20260622121456-42ed2b0a80a4 h1:AhuMryuO4hKbnqH7QyVciCar8mQ2WYPqP0f1WVqzALQ=
Expand All @@ -1205,8 +1205,8 @@ kubeops.dev/scanner v0.0.21-0.20251228044914-f03cf9e0e521 h1:nVLKN+sGLGVERkSdfFc
kubeops.dev/scanner v0.0.21-0.20251228044914-f03cf9e0e521/go.mod h1:NP3CtxQrcY1USwkrc3XJ3QFIFoE4RfWvd2s7h5ETHWk=
kubepack.dev/kubepack v0.34.0 h1:sQ+SyobE84O+ZlLtyQBJEM0QiVYT4zzGePE3Ko7w9rY=
kubepack.dev/kubepack v0.34.0/go.mod h1:o02NT21ct75qGzrCev4lXTTaSGsu1Geg9pU6EKQLDqY=
kubepack.dev/lib-app v0.16.1-0.20251228165728-e1f332468ae7 h1:zciHWcS3rbbEUtXMgkP8aBMoABzVBJ4TDFhUvlWMvdc=
kubepack.dev/lib-app v0.16.1-0.20251228165728-e1f332468ae7/go.mod h1:cnn+AHoVYNTJZQl7VsZ4fcegRCTdTVHPHmg0JRJsdV0=
kubepack.dev/lib-app v0.23.1-0.20260626193801-519cc46890f2 h1:x9sEj9ojiFWsF6oLPIbVr6flLh6tJBwvutLOgqtTcZI=
kubepack.dev/lib-app v0.23.1-0.20260626193801-519cc46890f2/go.mod h1:EFVworzQqHdjzFG06LDh6Tkp/b5WGhRaXknc1u+PoEk=
kubepack.dev/lib-helm v0.34.1 h1:O3lt2Z8UZTuvEKz5IIkXUR/jbKwuaW6IoDDhk8LP8EQ=
kubepack.dev/lib-helm v0.34.1/go.mod h1:D/XdlsafH80UC4qKYthNuM+UUXA2Hmim8blTZlXhLFE=
kubevault.dev/apimachinery v0.24.0 h1:WNWVAeQ2dLudc1ZaKe0r7UDiB5EIE6PmlM3vFBgGkQg=
Expand Down
15 changes: 15 additions & 0 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
resourcesservicestorage "kubeops.dev/ui-server/pkg/registry/core/resourceservice"
resourcesummarystorage "kubeops.dev/ui-server/pkg/registry/core/resourcesummary"
coststorage "kubeops.dev/ui-server/pkg/registry/cost/reports"
editortemplatestorage "kubeops.dev/ui-server/pkg/registry/editor/editortemplate"
audittokenreqstorage "kubeops.dev/ui-server/pkg/registry/identity/audittokenrequest"
clusteridstorage "kubeops.dev/ui-server/pkg/registry/identity/clusteridentity"
inboxtokenreqstorage "kubeops.dev/ui-server/pkg/registry/identity/inboxtokenrequest"
Expand Down Expand Up @@ -101,6 +102,8 @@ import (
promclient "kmodules.xyz/monitoring-agent-api/client"
rscoreinstall "kmodules.xyz/resource-metadata/apis/core/install"
rscoreapi "kmodules.xyz/resource-metadata/apis/core/v1alpha1"
editorinstall "kmodules.xyz/resource-metadata/apis/editor/install"
editorapi "kmodules.xyz/resource-metadata/apis/editor/v1alpha1"
identityinstall "kmodules.xyz/resource-metadata/apis/identity/install"
identityapi "kmodules.xyz/resource-metadata/apis/identity/v1alpha1"
mgmtinstall "kmodules.xyz/resource-metadata/apis/management/install"
Expand Down Expand Up @@ -133,6 +136,7 @@ func init() {
costinstall.Install(Scheme)
rsinstall.Install(Scheme)
uiinstall.Install(Scheme)
editorinstall.Install(Scheme)
rscoreinstall.Install(Scheme)
mgmtinstall.Install(Scheme)
crdinstall.Install(Scheme)
Expand Down Expand Up @@ -431,6 +435,17 @@ func (c completedConfig) New(ctx context.Context) (*UIServer, error) {
return nil, err
}
}
{
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(editorapi.SchemeGroupVersion.Group, Scheme, metav1.ParameterCodec, Codecs)

v1alpha1storage := map[string]rest.Storage{}
v1alpha1storage[editorapi.ResourceEditorTemplates] = editortemplatestorage.NewStorage(ctrlClient)
apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage

if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil {
return nil, err
}
}
{
// Create metrics handler and fill the stores with metrics store
// containing Help and Type headers of metrics
Expand Down
129 changes: 129 additions & 0 deletions pkg/registry/editor/editortemplate/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
Copyright AppsCode Inc. and Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package editortemplate

import (
"context"
"encoding/json"
"fmt"
"strings"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/registry/rest"
editorapi "kmodules.xyz/resource-metadata/apis/editor/v1alpha1"
"kubepack.dev/lib-app/pkg/editor"
"sigs.k8s.io/controller-runtime/pkg/client"
driversapi "x-helm.dev/apimachinery/apis/drivers/v1alpha1"
)

type Storage struct {
kc client.Client
}

var (
_ rest.GroupVersionKindProvider = &Storage{}
_ rest.Scoper = &Storage{}
_ rest.Storage = &Storage{}
_ rest.Creater = &Storage{}
_ rest.SingularNameProvider = &Storage{}
)

func NewStorage(kc client.Client) *Storage {
return &Storage{kc: kc}
}

func (r *Storage) GroupVersionKind(_ schema.GroupVersion) schema.GroupVersionKind {
return editorapi.SchemeGroupVersion.WithKind(editorapi.ResourceKindEditorTemplate)
}

func (r *Storage) NamespaceScoped() bool {
return false
}

func (r *Storage) GetSingularName() string {
return strings.ToLower(editorapi.ResourceKindEditorTemplate)
}

func (r *Storage) New() runtime.Object {
return &editorapi.EditorTemplate{}
}

func (r *Storage) Destroy() {}

// Create reconstructs the editor template for an existing installation from the
// chart values supplied in the request. The caller (b3) is responsible for the
// slow parts -- pulling the chart (getChart) and creating the AppRelease if
// missing -- so this method only performs fast in-cluster reads and stays within
// the aggregated apiserver request budget.
func (r *Storage) Create(ctx context.Context, obj runtime.Object, _ rest.ValidateObjectFunc, _ *metav1.CreateOptions) (runtime.Object, error) {
in, ok := obj.(*editorapi.EditorTemplate)
if !ok {
return nil, fmt.Errorf("invalid object type: %T", obj)
}
if in.Request == nil {
return nil, apierrors.NewBadRequest("missing request")
}
md := in.Request.Metadata

values := map[string]any{}
if in.Request.Values != nil && len(in.Request.Values.Raw) > 0 {
if err := json.Unmarshal(in.Request.Values.Raw, &values); err != nil {
return nil, apierrors.NewBadRequest(err.Error())
}
}

var app driversapi.AppRelease
if err := r.kc.Get(ctx, client.ObjectKey{Namespace: md.Release.Namespace, Name: md.Release.Name}, &app); err != nil {
return nil, err
}

tpl, err := editor.EditorChartValueManifest(r.kc, &app, md, values)
if err != nil {
return nil, err
}

resp := &editorapi.EditorTemplateResponse{
Manifest: string(tpl.Manifest),
}
if tpl.Values != nil {
raw, err := json.Marshal(tpl.Values)
if err != nil {
return nil, err
}
resp.Values = &runtime.RawExtension{Raw: raw}
}
for _, res := range tpl.Resources {
item := editorapi.EditorTemplateResource{
Filename: res.Filename,
Key: res.Key,
}
if res.Data != nil {
raw, err := json.Marshal(res.Data)
if err != nil {
return nil, err
}
item.Data = &runtime.RawExtension{Raw: raw}
}
resp.Resources = append(resp.Resources, item)
}
in.Response = resp

return in, nil
}

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

Loading
Loading