From 6b9760383b98e2524c372e9bcd4e4dd0a8b73882 Mon Sep 17 00:00:00 2001 From: Fiachra Corcoran Date: Wed, 6 Nov 2024 14:10:19 +0000 Subject: [PATCH] Remove Function api resource --- .../porch/v1alpha1/fake/fake_function.go | 139 -------- .../porch/v1alpha1/fake/fake_porch_client.go | 4 - .../typed/porch/v1alpha1/function.go | 193 ----------- .../porch/v1alpha1/generated_expansion.go | 2 - .../typed/porch/v1alpha1/porch_client.go | 5 - .../informers/externalversions/generic.go | 2 - .../porch/v1alpha1/function.go | 88 ----- .../porch/v1alpha1/interface.go | 7 - .../porch/v1alpha1/expansion_generated.go | 8 - .../listers/porch/v1alpha1/function.go | 97 ------ api/generated/openapi/zz_generated.openapi.go | 314 ------------------ api/porch/register.go | 2 - api/porch/types.go | 97 +----- api/porch/v1alpha1/register.go | 3 - api/porch/v1alpha1/types.go | 100 +----- api/porch/v1alpha1/zz_generated.conversion.go | 208 ------------ api/porch/v1alpha1/zz_generated.deepcopy.go | 149 --------- api/porch/zz_generated.deepcopy.go | 149 --------- examples/config/function-repository.yaml | 25 -- internal/kpt/util/cmdutil/cmdutil.go | 82 ----- internal/kpt/util/cmdutil/cmdutil_test.go | 44 --- internal/kpt/util/function/catalogfn.go | 42 --- internal/kpt/util/function/matcher.go | 102 ------ internal/kpt/util/porch/function.go | 104 ------ pkg/apiserver/apiserver.go | 6 - pkg/apiserver/resolvetoimage.go | 74 ----- 26 files changed, 3 insertions(+), 2043 deletions(-) delete mode 100644 api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_function.go delete mode 100644 api/generated/clientset/versioned/typed/porch/v1alpha1/function.go delete mode 100644 api/generated/informers/externalversions/porch/v1alpha1/function.go delete mode 100644 api/generated/listers/porch/v1alpha1/function.go delete mode 100644 examples/config/function-repository.yaml delete mode 100644 internal/kpt/util/function/catalogfn.go delete mode 100644 internal/kpt/util/function/matcher.go delete mode 100644 internal/kpt/util/porch/function.go delete mode 100644 pkg/apiserver/resolvetoimage.go diff --git a/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_function.go b/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_function.go deleted file mode 100644 index 87590d45..00000000 --- a/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_function.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2023-2024 The kpt and Nephio Authors -// -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeFunctions implements FunctionInterface -type FakeFunctions struct { - Fake *FakePorchV1alpha1 - ns string -} - -var functionsResource = v1alpha1.SchemeGroupVersion.WithResource("functions") - -var functionsKind = v1alpha1.SchemeGroupVersion.WithKind("Function") - -// Get takes name of the function, and returns the corresponding function object, and an error if there is any. -func (c *FakeFunctions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Function, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(functionsResource, c.ns, name), &v1alpha1.Function{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Function), err -} - -// List takes label and field selectors, and returns the list of Functions that match those selectors. -func (c *FakeFunctions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FunctionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(functionsResource, functionsKind, c.ns, opts), &v1alpha1.FunctionList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.FunctionList{ListMeta: obj.(*v1alpha1.FunctionList).ListMeta} - for _, item := range obj.(*v1alpha1.FunctionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested functions. -func (c *FakeFunctions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(functionsResource, c.ns, opts)) - -} - -// Create takes the representation of a function and creates it. Returns the server's representation of the function, and an error, if there is any. -func (c *FakeFunctions) Create(ctx context.Context, function *v1alpha1.Function, opts v1.CreateOptions) (result *v1alpha1.Function, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(functionsResource, c.ns, function), &v1alpha1.Function{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Function), err -} - -// Update takes the representation of a function and updates it. Returns the server's representation of the function, and an error, if there is any. -func (c *FakeFunctions) Update(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (result *v1alpha1.Function, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(functionsResource, c.ns, function), &v1alpha1.Function{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Function), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeFunctions) UpdateStatus(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (*v1alpha1.Function, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(functionsResource, "status", c.ns, function), &v1alpha1.Function{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Function), err -} - -// Delete takes name of the function and deletes it. Returns an error if one occurs. -func (c *FakeFunctions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(functionsResource, c.ns, name, opts), &v1alpha1.Function{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeFunctions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(functionsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.FunctionList{}) - return err -} - -// Patch applies the patch and returns the patched function. -func (c *FakeFunctions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Function, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(functionsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Function{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Function), err -} diff --git a/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_porch_client.go b/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_porch_client.go index 1eab32c8..11209b2b 100644 --- a/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_porch_client.go +++ b/api/generated/clientset/versioned/typed/porch/v1alpha1/fake/fake_porch_client.go @@ -26,10 +26,6 @@ type FakePorchV1alpha1 struct { *testing.Fake } -func (c *FakePorchV1alpha1) Functions(namespace string) v1alpha1.FunctionInterface { - return &FakeFunctions{c, namespace} -} - func (c *FakePorchV1alpha1) PackageRevisions(namespace string) v1alpha1.PackageRevisionInterface { return &FakePackageRevisions{c, namespace} } diff --git a/api/generated/clientset/versioned/typed/porch/v1alpha1/function.go b/api/generated/clientset/versioned/typed/porch/v1alpha1/function.go deleted file mode 100644 index 1b0b8254..00000000 --- a/api/generated/clientset/versioned/typed/porch/v1alpha1/function.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2023-2024 The kpt and Nephio Authors -// -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - scheme "github.com/nephio-project/porch/api/generated/clientset/versioned/scheme" - v1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// FunctionsGetter has a method to return a FunctionInterface. -// A group's client should implement this interface. -type FunctionsGetter interface { - Functions(namespace string) FunctionInterface -} - -// FunctionInterface has methods to work with Function resources. -type FunctionInterface interface { - Create(ctx context.Context, function *v1alpha1.Function, opts v1.CreateOptions) (*v1alpha1.Function, error) - Update(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (*v1alpha1.Function, error) - UpdateStatus(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (*v1alpha1.Function, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Function, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FunctionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Function, err error) - FunctionExpansion -} - -// functions implements FunctionInterface -type functions struct { - client rest.Interface - ns string -} - -// newFunctions returns a Functions -func newFunctions(c *PorchV1alpha1Client, namespace string) *functions { - return &functions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the function, and returns the corresponding function object, and an error if there is any. -func (c *functions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Function, err error) { - result = &v1alpha1.Function{} - err = c.client.Get(). - Namespace(c.ns). - Resource("functions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Functions that match those selectors. -func (c *functions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FunctionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.FunctionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("functions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested functions. -func (c *functions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("functions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a function and creates it. Returns the server's representation of the function, and an error, if there is any. -func (c *functions) Create(ctx context.Context, function *v1alpha1.Function, opts v1.CreateOptions) (result *v1alpha1.Function, err error) { - result = &v1alpha1.Function{} - err = c.client.Post(). - Namespace(c.ns). - Resource("functions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(function). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a function and updates it. Returns the server's representation of the function, and an error, if there is any. -func (c *functions) Update(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (result *v1alpha1.Function, err error) { - result = &v1alpha1.Function{} - err = c.client.Put(). - Namespace(c.ns). - Resource("functions"). - Name(function.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(function). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *functions) UpdateStatus(ctx context.Context, function *v1alpha1.Function, opts v1.UpdateOptions) (result *v1alpha1.Function, err error) { - result = &v1alpha1.Function{} - err = c.client.Put(). - Namespace(c.ns). - Resource("functions"). - Name(function.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(function). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the function and deletes it. Returns an error if one occurs. -func (c *functions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("functions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *functions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("functions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched function. -func (c *functions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Function, err error) { - result = &v1alpha1.Function{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("functions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/api/generated/clientset/versioned/typed/porch/v1alpha1/generated_expansion.go b/api/generated/clientset/versioned/typed/porch/v1alpha1/generated_expansion.go index 9eaed5be..d7722a27 100644 --- a/api/generated/clientset/versioned/typed/porch/v1alpha1/generated_expansion.go +++ b/api/generated/clientset/versioned/typed/porch/v1alpha1/generated_expansion.go @@ -16,8 +16,6 @@ package v1alpha1 -type FunctionExpansion interface{} - type PackageRevisionExpansion interface{} type PackageRevisionResourcesExpansion interface{} diff --git a/api/generated/clientset/versioned/typed/porch/v1alpha1/porch_client.go b/api/generated/clientset/versioned/typed/porch/v1alpha1/porch_client.go index 6b9aa316..3db8a589 100644 --- a/api/generated/clientset/versioned/typed/porch/v1alpha1/porch_client.go +++ b/api/generated/clientset/versioned/typed/porch/v1alpha1/porch_client.go @@ -26,7 +26,6 @@ import ( type PorchV1alpha1Interface interface { RESTClient() rest.Interface - FunctionsGetter PackageRevisionsGetter PackageRevisionResourcesGetter PorchPackagesGetter @@ -37,10 +36,6 @@ type PorchV1alpha1Client struct { restClient rest.Interface } -func (c *PorchV1alpha1Client) Functions(namespace string) FunctionInterface { - return newFunctions(c, namespace) -} - func (c *PorchV1alpha1Client) PackageRevisions(namespace string) PackageRevisionInterface { return newPackageRevisions(c, namespace) } diff --git a/api/generated/informers/externalversions/generic.go b/api/generated/informers/externalversions/generic.go index c8b04906..b1bf2dab 100644 --- a/api/generated/informers/externalversions/generic.go +++ b/api/generated/informers/externalversions/generic.go @@ -51,8 +51,6 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=porch.kpt.dev, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("functions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Porch().V1alpha1().Functions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("packagerevisions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Porch().V1alpha1().PackageRevisions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("packagerevisionresources"): diff --git a/api/generated/informers/externalversions/porch/v1alpha1/function.go b/api/generated/informers/externalversions/porch/v1alpha1/function.go deleted file mode 100644 index 9779c210..00000000 --- a/api/generated/informers/externalversions/porch/v1alpha1/function.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023-2024 The kpt and Nephio Authors -// -// 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. - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - time "time" - - versioned "github.com/nephio-project/porch/api/generated/clientset/versioned" - internalinterfaces "github.com/nephio-project/porch/api/generated/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/nephio-project/porch/api/generated/listers/porch/v1alpha1" - porchv1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// FunctionInformer provides access to a shared informer and lister for -// Functions. -type FunctionInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.FunctionLister -} - -type functionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewFunctionInformer constructs a new informer for Function type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFunctionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredFunctionInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredFunctionInformer constructs a new informer for Function type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredFunctionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.PorchV1alpha1().Functions(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.PorchV1alpha1().Functions(namespace).Watch(context.TODO(), options) - }, - }, - &porchv1alpha1.Function{}, - resyncPeriod, - indexers, - ) -} - -func (f *functionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredFunctionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *functionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&porchv1alpha1.Function{}, f.defaultInformer) -} - -func (f *functionInformer) Lister() v1alpha1.FunctionLister { - return v1alpha1.NewFunctionLister(f.Informer().GetIndexer()) -} diff --git a/api/generated/informers/externalversions/porch/v1alpha1/interface.go b/api/generated/informers/externalversions/porch/v1alpha1/interface.go index 27cfadf2..bf0ad9da 100644 --- a/api/generated/informers/externalversions/porch/v1alpha1/interface.go +++ b/api/generated/informers/externalversions/porch/v1alpha1/interface.go @@ -22,8 +22,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // Functions returns a FunctionInformer. - Functions() FunctionInformer // PackageRevisions returns a PackageRevisionInformer. PackageRevisions() PackageRevisionInformer // PackageRevisionResources returns a PackageRevisionResourcesInformer. @@ -43,11 +41,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// Functions returns a FunctionInformer. -func (v *version) Functions() FunctionInformer { - return &functionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // PackageRevisions returns a PackageRevisionInformer. func (v *version) PackageRevisions() PackageRevisionInformer { return &packageRevisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/api/generated/listers/porch/v1alpha1/expansion_generated.go b/api/generated/listers/porch/v1alpha1/expansion_generated.go index e0c93301..0697e553 100644 --- a/api/generated/listers/porch/v1alpha1/expansion_generated.go +++ b/api/generated/listers/porch/v1alpha1/expansion_generated.go @@ -16,14 +16,6 @@ package v1alpha1 -// FunctionListerExpansion allows custom methods to be added to -// FunctionLister. -type FunctionListerExpansion interface{} - -// FunctionNamespaceListerExpansion allows custom methods to be added to -// FunctionNamespaceLister. -type FunctionNamespaceListerExpansion interface{} - // PackageRevisionListerExpansion allows custom methods to be added to // PackageRevisionLister. type PackageRevisionListerExpansion interface{} diff --git a/api/generated/listers/porch/v1alpha1/function.go b/api/generated/listers/porch/v1alpha1/function.go deleted file mode 100644 index 9d713c0b..00000000 --- a/api/generated/listers/porch/v1alpha1/function.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2023-2024 The kpt and Nephio Authors -// -// 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. - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// FunctionLister helps list Functions. -// All objects returned here must be treated as read-only. -type FunctionLister interface { - // List lists all Functions in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Function, err error) - // Functions returns an object that can list and get Functions. - Functions(namespace string) FunctionNamespaceLister - FunctionListerExpansion -} - -// functionLister implements the FunctionLister interface. -type functionLister struct { - indexer cache.Indexer -} - -// NewFunctionLister returns a new FunctionLister. -func NewFunctionLister(indexer cache.Indexer) FunctionLister { - return &functionLister{indexer: indexer} -} - -// List lists all Functions in the indexer. -func (s *functionLister) List(selector labels.Selector) (ret []*v1alpha1.Function, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Function)) - }) - return ret, err -} - -// Functions returns an object that can list and get Functions. -func (s *functionLister) Functions(namespace string) FunctionNamespaceLister { - return functionNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// FunctionNamespaceLister helps list and get Functions. -// All objects returned here must be treated as read-only. -type FunctionNamespaceLister interface { - // List lists all Functions in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Function, err error) - // Get retrieves the Function from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.Function, error) - FunctionNamespaceListerExpansion -} - -// functionNamespaceLister implements the FunctionNamespaceLister -// interface. -type functionNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Functions in the indexer for a given namespace. -func (s functionNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Function, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Function)) - }) - return ret, err -} - -// Get retrieves the Function from the indexer for a given namespace and name. -func (s functionNamespaceLister) Get(name string) (*v1alpha1.Function, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("function"), name) - } - return obj.(*v1alpha1.Function), nil -} diff --git a/api/generated/openapi/zz_generated.openapi.go b/api/generated/openapi/zz_generated.openapi.go index 1fd49b46..44daf27f 100644 --- a/api/generated/openapi/zz_generated.openapi.go +++ b/api/generated/openapi/zz_generated.openapi.go @@ -29,20 +29,13 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "github.com/nephio-project/porch/api/porch.Function": schema_nephio_project_porch_api_porch_Function(ref), "github.com/nephio-project/porch/api/porch.PackageRevision": schema_nephio_project_porch_api_porch_PackageRevision(ref), "github.com/nephio-project/porch/api/porch.PackageRevisionResources": schema_nephio_project_porch_api_porch_PackageRevisionResources(ref), "github.com/nephio-project/porch/api/porch.PorchPackage": schema_nephio_project_porch_api_porch_PorchPackage(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.Condition": schema_porch_api_porch_v1alpha1_Condition(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.Field": schema_porch_api_porch_v1alpha1_Field(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.File": schema_porch_api_porch_v1alpha1_File(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.Function": schema_porch_api_porch_v1alpha1_Function(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionConfig": schema_porch_api_porch_v1alpha1_FunctionConfig(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionEvalTaskSpec": schema_porch_api_porch_v1alpha1_FunctionEvalTaskSpec(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionList": schema_porch_api_porch_v1alpha1_FunctionList(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionRef": schema_porch_api_porch_v1alpha1_FunctionRef(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionSpec": schema_porch_api_porch_v1alpha1_FunctionSpec(ref), - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionStatus": schema_porch_api_porch_v1alpha1_FunctionStatus(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.GitLock": schema_porch_api_porch_v1alpha1_GitLock(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.GitPackage": schema_porch_api_porch_v1alpha1_GitPackage(ref), "github.com/nephio-project/porch/api/porch/v1alpha1.NameMeta": schema_porch_api_porch_v1alpha1_NameMeta(ref), @@ -135,53 +128,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA } } -func schema_nephio_project_porch_api_porch_Function(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "Function represents a kpt function discovered in a repository Function resources are created automatically by discovery in a registered Repository. Function resource names will be computed as : to ensure uniqueness of names, and will follow formatting of [DNS Subdomain Names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names).", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch.FunctionSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch.FunctionStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/nephio-project/porch/api/porch.FunctionSpec", "github.com/nephio-project/porch/api/porch.FunctionStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - func schema_nephio_project_porch_api_porch_PackageRevision(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -416,95 +362,6 @@ func schema_porch_api_porch_v1alpha1_File(ref common.ReferenceCallback) common.O } } -func schema_porch_api_porch_v1alpha1_Function(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "Function represents a kpt function discovered in a repository Function resources are created automatically by discovery in a registered Repository. Function resource names will be computed as : to ensure uniqueness of names, and will follow formatting of [DNS Subdomain Names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names).", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch/v1alpha1.FunctionSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch/v1alpha1.FunctionStatus"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionSpec", "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - -func schema_porch_api_porch_v1alpha1_FunctionConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FunctionConfig specifies all the valid types of the function config for this function. If unspecified, defaults to v1/ConfigMap. For example, function `set-namespace` accepts both `ConfigMap` and `SetNamespace`", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "requiredFields": { - SchemaProps: spec.SchemaProps{ - Description: "Experimental: requiredFields tells necessary fields and is aimed to help users write the FunctionConfig. Otherwise, users can get the required fields info from the function evaluation error message.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - func schema_porch_api_porch_v1alpha1_FunctionEvalTaskSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -576,177 +433,6 @@ func schema_porch_api_porch_v1alpha1_FunctionEvalTaskSpec(ref common.ReferenceCa } } -func schema_porch_api_porch_v1alpha1_FunctionList(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FunctionList", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), - }, - }, - "items": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch/v1alpha1.Function"), - }, - }, - }, - }, - }, - }, - Required: []string{"items"}, - }, - }, - Dependencies: []string{ - "github.com/nephio-project/porch/api/porch/v1alpha1.Function", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, - } -} - -func schema_porch_api_porch_v1alpha1_FunctionRef(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FunctionRef is a reference to a Function resource.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "name": { - SchemaProps: spec.SchemaProps{ - Description: "Name is the name of the Function resource referenced. The resource is expected to be within the same namespace.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"name"}, - }, - }, - } -} - -func schema_porch_api_porch_v1alpha1_FunctionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FunctionSpec defines the desired state of a Function", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "image": { - SchemaProps: spec.SchemaProps{ - Description: "Image specifies the function image, such as 'gcr.io/kpt-fn/gatekeeper:v0.2'.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "repositoryRef": { - SchemaProps: spec.SchemaProps{ - Description: "RepositoryRef references the repository in which the function is located.", - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch/v1alpha1.RepositoryRef"), - }, - }, - "functionTypes": { - SchemaProps: spec.SchemaProps{ - Description: "FunctionType specifies the function types (mutator, validator or/and others).", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "functionConfigs": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/nephio-project/porch/api/porch/v1alpha1.FunctionConfig"), - }, - }, - }, - }, - }, - "keywords": { - SchemaProps: spec.SchemaProps{ - Description: "Keywords are used as filters to provide correlation in function discovery.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "description": { - SchemaProps: spec.SchemaProps{ - Description: "Description is a short description of the function.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "documentationUrl": { - SchemaProps: spec.SchemaProps{ - Description: "`DocumentationUrl specifies the URL of comprehensive function documentation`", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"image", "repositoryRef", "description"}, - }, - }, - Dependencies: []string{ - "github.com/nephio-project/porch/api/porch/v1alpha1.FunctionConfig", "github.com/nephio-project/porch/api/porch/v1alpha1.RepositoryRef"}, - } -} - -func schema_porch_api_porch_v1alpha1_FunctionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FunctionStatus defines the observed state of Function", - Type: []string{"object"}, - }, - }, - } -} - func schema_porch_api_porch_v1alpha1_GitLock(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/api/porch/register.go b/api/porch/register.go index 151d3412..db279b36 100644 --- a/api/porch/register.go +++ b/api/porch/register.go @@ -44,8 +44,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PackageRevisionList{}, &PackageRevisionResources{}, &PackageRevisionResourcesList{}, - &Function{}, - &FunctionList{}, ) return nil } diff --git a/api/porch/types.go b/api/porch/types.go index 021804d6..c903ce10 100644 --- a/api/porch/types.go +++ b/api/porch/types.go @@ -265,7 +265,7 @@ type RepositoryRef struct { type FunctionEvalTaskSpec struct { // `Subpackage` is a directory path to a subpackage in which to evaluate the function. Subpackage string `json:"subpackage,omitempty"` - // `Image` specifies the function image, such as `gcr.io/kpt-fn/gatekeeper:v0.2`. Use of `Image` is mutually exclusive with `FunctionRef`. + // `Image` specifies the function image, such as `gcr.io/kpt-fn/gatekeeper:v0.2`. Image string `json:"image,omitempty"` // `ConfigMap` specifies the function config (https://kpt.dev/reference/cli/fn/eval/). Mutually exclusive with Config. ConfigMap map[string]string `json:"configMap,omitempty"` @@ -530,98 +530,3 @@ type PackageStatus struct { // published package revision belonging to this package LatestRevision string `json:"latestRevision,omitempty"` } - - -// Function represents a kpt function discovered in a repository -// Function resources are created automatically by discovery in a registered Repository. -// Function resource names will be computed as : -// to ensure uniqueness of names, and will follow formatting of -// [DNS Subdomain Names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names). -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -type Function struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FunctionSpec `json:"spec,omitempty"` - Status FunctionStatus `json:"status,omitempty"` -} - -// FunctionList -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type FunctionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - - Items []Function `json:"items"` -} - -type FunctionType string - -const ( - FunctionTypeValidator FunctionType = "validator" - FunctionTypeMutator FunctionType = "mutator" -) - -// FunctionSpec defines the desired state of a Function -type FunctionSpec struct { - // Image specifies the function image, such as 'gcr.io/kpt-fn/gatekeeper:v0.2'. - Image string `json:"image"` - - // RepositoryRef references the repository in which the function is located. - RepositoryRef RepositoryRef `json:"repositoryRef"` - - // FunctionType specifies the function types (mutator, validator or/and others). - FunctionTypes []FunctionType `json:"functionTypes,omitempty"` - - FunctionConfigs []FunctionConfig `json:"functionConfigs,omitempty"` - - // Keywords are used as filters to provide correlation in function discovery. - Keywords []string `json:"keywords,omitempty"` - - // Description is a short description of the function. - Description string `json:"description"` - - // `DocumentationUrl specifies the URL of comprehensive function documentation` - DocumentationUrl string `json:"documentationUrl,omitempty"` - - // InputTypes specifies to which input KRM types the function applies. Specified as Group Version Kind. - // For example: - // - // inputTypes: - // - kind: RoleBinding - // # If version is unspecified, applies to all versions - // apiVersion: rbac.authorization.k8s.io - // - kind: ClusterRoleBinding - // apiVersion: rbac.authorization.k8s.io/v1 - // InputTypes []metav1.TypeMeta - - // OutputTypes specifies types of any KRM resources the function creates - // For example: - // - // outputTypes: - // - kind: ConfigMap - // apiVersion: v1 - // OutputTypes []metav1.TypeMeta - -} - -// FunctionConfig specifies all the valid types of the function config for this function. -// If unspecified, defaults to v1/ConfigMap. For example, function `set-namespace` accepts both `ConfigMap` and `SetNamespace` -type FunctionConfig struct { - metav1.TypeMeta `json:",inline"` - // Experimental: requiredFields tells necessary fields and is aimed to help users write the FunctionConfig. - // Otherwise, users can get the required fields info from the function evaluation error message. - RequiredFields []string `json:"requiredFields,omitempty"` -} - -// FunctionRef is a reference to a Function resource. -type FunctionRef struct { - // Name is the name of the Function resource referenced. The resource is expected to be within the same namespace. - Name string `json:"name"` -} - -// FunctionStatus defines the observed state of Function -type FunctionStatus struct { -} diff --git a/api/porch/v1alpha1/register.go b/api/porch/v1alpha1/register.go index 029f95cb..b6f15a08 100644 --- a/api/porch/v1alpha1/register.go +++ b/api/porch/v1alpha1/register.go @@ -31,7 +31,6 @@ var ( PackageGVR = SchemeGroupVersion.WithResource("packages") PackageRevisionGVR = SchemeGroupVersion.WithResource("packagerevisions") PackageRevisionResourcesGVR = SchemeGroupVersion.WithResource("packagerevisionresources") - FunctionGVR = SchemeGroupVersion.WithResource("functions") ) func init() { @@ -49,8 +48,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PackageRevisionList{}, &PackageRevisionResources{}, &PackageRevisionResourcesList{}, - &Function{}, - &FunctionList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/api/porch/v1alpha1/types.go b/api/porch/v1alpha1/types.go index f3c4375f..96903c86 100644 --- a/api/porch/v1alpha1/types.go +++ b/api/porch/v1alpha1/types.go @@ -292,7 +292,7 @@ type RepositoryRef struct { type FunctionEvalTaskSpec struct { // `Subpackage` is a directory path to a subpackage in which to evaluate the function. Subpackage string `json:"subpackage,omitempty"` - // `Image` specifies the function image, such as `gcr.io/kpt-fn/gatekeeper:v0.2`. Use of `Image` is mutually exclusive with `FunctionRef`. + // `Image` specifies the function image, such as `gcr.io/kpt-fn/gatekeeper:v0.2`. Image string `json:"image,omitempty"` // `ConfigMap` specifies the function config (https://kpt.dev/reference/cli/fn/eval/). Mutually exclusive with Config. ConfigMap map[string]string `json:"configMap,omitempty"` @@ -559,100 +559,4 @@ type PackageStatus struct { // LatestRevision identifies the package revision that is the latest // published package revision belonging to this package LatestRevision string `json:"latestRevision,omitempty"` -} - - -// Function represents a kpt function discovered in a repository -// Function resources are created automatically by discovery in a registered Repository. -// Function resource names will be computed as : -// to ensure uniqueness of names, and will follow formatting of -// [DNS Subdomain Names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names). -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -type Function struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FunctionSpec `json:"spec,omitempty"` - Status FunctionStatus `json:"status,omitempty"` -} - -// FunctionList -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type FunctionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - - Items []Function `json:"items"` -} - -type FunctionType string - -const ( - FunctionTypeValidator FunctionType = "validator" - FunctionTypeMutator FunctionType = "mutator" -) - -// FunctionSpec defines the desired state of a Function -type FunctionSpec struct { - // Image specifies the function image, such as 'gcr.io/kpt-fn/gatekeeper:v0.2'. - Image string `json:"image"` - - // RepositoryRef references the repository in which the function is located. - RepositoryRef RepositoryRef `json:"repositoryRef"` - - // FunctionType specifies the function types (mutator, validator or/and others). - FunctionTypes []FunctionType `json:"functionTypes,omitempty"` - - FunctionConfigs []FunctionConfig `json:"functionConfigs,omitempty"` - - // Keywords are used as filters to provide correlation in function discovery. - Keywords []string `json:"keywords,omitempty"` - - // Description is a short description of the function. - Description string `json:"description"` - - // `DocumentationUrl specifies the URL of comprehensive function documentation` - DocumentationUrl string `json:"documentationUrl,omitempty"` - - // InputTypes specifies to which input KRM types the function applies. Specified as Group Version Kind. - // For example: - // - // inputTypes: - // - kind: RoleBinding - // # If version is unspecified, applies to all versions - // apiVersion: rbac.authorization.k8s.io - // - kind: ClusterRoleBinding - // apiVersion: rbac.authorization.k8s.io/v1 - // InputTypes []metav1.TypeMeta - - // OutputTypes specifies types of any KRM resources the function creates - // For example: - // - // outputTypes: - // - kind: ConfigMap - // apiVersion: v1 - // OutputTypes []metav1.TypeMeta - -} - -// FunctionConfig specifies all the valid types of the function config for this function. -// If unspecified, defaults to v1/ConfigMap. For example, function `set-namespace` accepts both `ConfigMap` and `SetNamespace` -type FunctionConfig struct { - metav1.TypeMeta `json:",inline"` - // Experimental: requiredFields tells necessary fields and is aimed to help users write the FunctionConfig. - // Otherwise, users can get the required fields info from the function evaluation error message. - RequiredFields []string `json:"requiredFields,omitempty"` -} - -// FunctionRef is a reference to a Function resource. -type FunctionRef struct { - // Name is the name of the Function resource referenced. The resource is expected to be within the same namespace. - Name string `json:"name"` -} - -// FunctionStatus defines the observed state of Function -type FunctionStatus struct { -} - +} \ No newline at end of file diff --git a/api/porch/v1alpha1/zz_generated.conversion.go b/api/porch/v1alpha1/zz_generated.conversion.go index a93469b2..11849652 100644 --- a/api/porch/v1alpha1/zz_generated.conversion.go +++ b/api/porch/v1alpha1/zz_generated.conversion.go @@ -64,26 +64,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*Function)(nil), (*porch.Function)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_Function_To_porch_Function(a.(*Function), b.(*porch.Function), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.Function)(nil), (*Function)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_Function_To_v1alpha1_Function(a.(*porch.Function), b.(*Function), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*FunctionConfig)(nil), (*porch.FunctionConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_FunctionConfig_To_porch_FunctionConfig(a.(*FunctionConfig), b.(*porch.FunctionConfig), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.FunctionConfig)(nil), (*FunctionConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_FunctionConfig_To_v1alpha1_FunctionConfig(a.(*porch.FunctionConfig), b.(*FunctionConfig), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*FunctionEvalTaskSpec)(nil), (*porch.FunctionEvalTaskSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_FunctionEvalTaskSpec_To_porch_FunctionEvalTaskSpec(a.(*FunctionEvalTaskSpec), b.(*porch.FunctionEvalTaskSpec), scope) }); err != nil { @@ -94,46 +74,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*FunctionList)(nil), (*porch.FunctionList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_FunctionList_To_porch_FunctionList(a.(*FunctionList), b.(*porch.FunctionList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.FunctionList)(nil), (*FunctionList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_FunctionList_To_v1alpha1_FunctionList(a.(*porch.FunctionList), b.(*FunctionList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*FunctionRef)(nil), (*porch.FunctionRef)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_FunctionRef_To_porch_FunctionRef(a.(*FunctionRef), b.(*porch.FunctionRef), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.FunctionRef)(nil), (*FunctionRef)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_FunctionRef_To_v1alpha1_FunctionRef(a.(*porch.FunctionRef), b.(*FunctionRef), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*FunctionSpec)(nil), (*porch.FunctionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_FunctionSpec_To_porch_FunctionSpec(a.(*FunctionSpec), b.(*porch.FunctionSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.FunctionSpec)(nil), (*FunctionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_FunctionSpec_To_v1alpha1_FunctionSpec(a.(*porch.FunctionSpec), b.(*FunctionSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*FunctionStatus)(nil), (*porch.FunctionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_FunctionStatus_To_porch_FunctionStatus(a.(*FunctionStatus), b.(*porch.FunctionStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*porch.FunctionStatus)(nil), (*FunctionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_porch_FunctionStatus_To_v1alpha1_FunctionStatus(a.(*porch.FunctionStatus), b.(*FunctionStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*GitLock)(nil), (*porch.GitLock)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_GitLock_To_porch_GitLock(a.(*GitLock), b.(*porch.GitLock), scope) }); err != nil { @@ -579,58 +519,6 @@ func Convert_porch_File_To_v1alpha1_File(in *porch.File, out *File, s conversion return autoConvert_porch_File_To_v1alpha1_File(in, out, s) } -func autoConvert_v1alpha1_Function_To_porch_Function(in *Function, out *porch.Function, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1alpha1_FunctionSpec_To_porch_FunctionSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1alpha1_FunctionStatus_To_porch_FunctionStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha1_Function_To_porch_Function is an autogenerated conversion function. -func Convert_v1alpha1_Function_To_porch_Function(in *Function, out *porch.Function, s conversion.Scope) error { - return autoConvert_v1alpha1_Function_To_porch_Function(in, out, s) -} - -func autoConvert_porch_Function_To_v1alpha1_Function(in *porch.Function, out *Function, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_porch_FunctionSpec_To_v1alpha1_FunctionSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_porch_FunctionStatus_To_v1alpha1_FunctionStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_porch_Function_To_v1alpha1_Function is an autogenerated conversion function. -func Convert_porch_Function_To_v1alpha1_Function(in *porch.Function, out *Function, s conversion.Scope) error { - return autoConvert_porch_Function_To_v1alpha1_Function(in, out, s) -} - -func autoConvert_v1alpha1_FunctionConfig_To_porch_FunctionConfig(in *FunctionConfig, out *porch.FunctionConfig, s conversion.Scope) error { - out.RequiredFields = *(*[]string)(unsafe.Pointer(&in.RequiredFields)) - return nil -} - -// Convert_v1alpha1_FunctionConfig_To_porch_FunctionConfig is an autogenerated conversion function. -func Convert_v1alpha1_FunctionConfig_To_porch_FunctionConfig(in *FunctionConfig, out *porch.FunctionConfig, s conversion.Scope) error { - return autoConvert_v1alpha1_FunctionConfig_To_porch_FunctionConfig(in, out, s) -} - -func autoConvert_porch_FunctionConfig_To_v1alpha1_FunctionConfig(in *porch.FunctionConfig, out *FunctionConfig, s conversion.Scope) error { - out.RequiredFields = *(*[]string)(unsafe.Pointer(&in.RequiredFields)) - return nil -} - -// Convert_porch_FunctionConfig_To_v1alpha1_FunctionConfig is an autogenerated conversion function. -func Convert_porch_FunctionConfig_To_v1alpha1_FunctionConfig(in *porch.FunctionConfig, out *FunctionConfig, s conversion.Scope) error { - return autoConvert_porch_FunctionConfig_To_v1alpha1_FunctionConfig(in, out, s) -} - func autoConvert_v1alpha1_FunctionEvalTaskSpec_To_porch_FunctionEvalTaskSpec(in *FunctionEvalTaskSpec, out *porch.FunctionEvalTaskSpec, s conversion.Scope) error { out.Subpackage = in.Subpackage out.Image = in.Image @@ -667,102 +555,6 @@ func Convert_porch_FunctionEvalTaskSpec_To_v1alpha1_FunctionEvalTaskSpec(in *por return autoConvert_porch_FunctionEvalTaskSpec_To_v1alpha1_FunctionEvalTaskSpec(in, out, s) } -func autoConvert_v1alpha1_FunctionList_To_porch_FunctionList(in *FunctionList, out *porch.FunctionList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - out.Items = *(*[]porch.Function)(unsafe.Pointer(&in.Items)) - return nil -} - -// Convert_v1alpha1_FunctionList_To_porch_FunctionList is an autogenerated conversion function. -func Convert_v1alpha1_FunctionList_To_porch_FunctionList(in *FunctionList, out *porch.FunctionList, s conversion.Scope) error { - return autoConvert_v1alpha1_FunctionList_To_porch_FunctionList(in, out, s) -} - -func autoConvert_porch_FunctionList_To_v1alpha1_FunctionList(in *porch.FunctionList, out *FunctionList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - out.Items = *(*[]Function)(unsafe.Pointer(&in.Items)) - return nil -} - -// Convert_porch_FunctionList_To_v1alpha1_FunctionList is an autogenerated conversion function. -func Convert_porch_FunctionList_To_v1alpha1_FunctionList(in *porch.FunctionList, out *FunctionList, s conversion.Scope) error { - return autoConvert_porch_FunctionList_To_v1alpha1_FunctionList(in, out, s) -} - -func autoConvert_v1alpha1_FunctionRef_To_porch_FunctionRef(in *FunctionRef, out *porch.FunctionRef, s conversion.Scope) error { - out.Name = in.Name - return nil -} - -// Convert_v1alpha1_FunctionRef_To_porch_FunctionRef is an autogenerated conversion function. -func Convert_v1alpha1_FunctionRef_To_porch_FunctionRef(in *FunctionRef, out *porch.FunctionRef, s conversion.Scope) error { - return autoConvert_v1alpha1_FunctionRef_To_porch_FunctionRef(in, out, s) -} - -func autoConvert_porch_FunctionRef_To_v1alpha1_FunctionRef(in *porch.FunctionRef, out *FunctionRef, s conversion.Scope) error { - out.Name = in.Name - return nil -} - -// Convert_porch_FunctionRef_To_v1alpha1_FunctionRef is an autogenerated conversion function. -func Convert_porch_FunctionRef_To_v1alpha1_FunctionRef(in *porch.FunctionRef, out *FunctionRef, s conversion.Scope) error { - return autoConvert_porch_FunctionRef_To_v1alpha1_FunctionRef(in, out, s) -} - -func autoConvert_v1alpha1_FunctionSpec_To_porch_FunctionSpec(in *FunctionSpec, out *porch.FunctionSpec, s conversion.Scope) error { - out.Image = in.Image - if err := Convert_v1alpha1_RepositoryRef_To_porch_RepositoryRef(&in.RepositoryRef, &out.RepositoryRef, s); err != nil { - return err - } - out.FunctionTypes = *(*[]porch.FunctionType)(unsafe.Pointer(&in.FunctionTypes)) - out.FunctionConfigs = *(*[]porch.FunctionConfig)(unsafe.Pointer(&in.FunctionConfigs)) - out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) - out.Description = in.Description - out.DocumentationUrl = in.DocumentationUrl - return nil -} - -// Convert_v1alpha1_FunctionSpec_To_porch_FunctionSpec is an autogenerated conversion function. -func Convert_v1alpha1_FunctionSpec_To_porch_FunctionSpec(in *FunctionSpec, out *porch.FunctionSpec, s conversion.Scope) error { - return autoConvert_v1alpha1_FunctionSpec_To_porch_FunctionSpec(in, out, s) -} - -func autoConvert_porch_FunctionSpec_To_v1alpha1_FunctionSpec(in *porch.FunctionSpec, out *FunctionSpec, s conversion.Scope) error { - out.Image = in.Image - if err := Convert_porch_RepositoryRef_To_v1alpha1_RepositoryRef(&in.RepositoryRef, &out.RepositoryRef, s); err != nil { - return err - } - out.FunctionTypes = *(*[]FunctionType)(unsafe.Pointer(&in.FunctionTypes)) - out.FunctionConfigs = *(*[]FunctionConfig)(unsafe.Pointer(&in.FunctionConfigs)) - out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) - out.Description = in.Description - out.DocumentationUrl = in.DocumentationUrl - return nil -} - -// Convert_porch_FunctionSpec_To_v1alpha1_FunctionSpec is an autogenerated conversion function. -func Convert_porch_FunctionSpec_To_v1alpha1_FunctionSpec(in *porch.FunctionSpec, out *FunctionSpec, s conversion.Scope) error { - return autoConvert_porch_FunctionSpec_To_v1alpha1_FunctionSpec(in, out, s) -} - -func autoConvert_v1alpha1_FunctionStatus_To_porch_FunctionStatus(in *FunctionStatus, out *porch.FunctionStatus, s conversion.Scope) error { - return nil -} - -// Convert_v1alpha1_FunctionStatus_To_porch_FunctionStatus is an autogenerated conversion function. -func Convert_v1alpha1_FunctionStatus_To_porch_FunctionStatus(in *FunctionStatus, out *porch.FunctionStatus, s conversion.Scope) error { - return autoConvert_v1alpha1_FunctionStatus_To_porch_FunctionStatus(in, out, s) -} - -func autoConvert_porch_FunctionStatus_To_v1alpha1_FunctionStatus(in *porch.FunctionStatus, out *FunctionStatus, s conversion.Scope) error { - return nil -} - -// Convert_porch_FunctionStatus_To_v1alpha1_FunctionStatus is an autogenerated conversion function. -func Convert_porch_FunctionStatus_To_v1alpha1_FunctionStatus(in *porch.FunctionStatus, out *FunctionStatus, s conversion.Scope) error { - return autoConvert_porch_FunctionStatus_To_v1alpha1_FunctionStatus(in, out, s) -} - func autoConvert_v1alpha1_GitLock_To_porch_GitLock(in *GitLock, out *porch.GitLock, s conversion.Scope) error { out.Repo = in.Repo out.Directory = in.Directory diff --git a/api/porch/v1alpha1/zz_generated.deepcopy.go b/api/porch/v1alpha1/zz_generated.deepcopy.go index d399a7e9..643b6b80 100644 --- a/api/porch/v1alpha1/zz_generated.deepcopy.go +++ b/api/porch/v1alpha1/zz_generated.deepcopy.go @@ -71,56 +71,6 @@ func (in *File) DeepCopy() *File { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Function) DeepCopyInto(out *Function) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Function. -func (in *Function) DeepCopy() *Function { - if in == nil { - return nil - } - out := new(Function) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Function) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionConfig) DeepCopyInto(out *FunctionConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.RequiredFields != nil { - in, out := &in.RequiredFields, &out.RequiredFields - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionConfig. -func (in *FunctionConfig) DeepCopy() *FunctionConfig { - if in == nil { - return nil - } - out := new(FunctionConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FunctionEvalTaskSpec) DeepCopyInto(out *FunctionEvalTaskSpec) { *out = *in @@ -146,105 +96,6 @@ func (in *FunctionEvalTaskSpec) DeepCopy() *FunctionEvalTaskSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionList) DeepCopyInto(out *FunctionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Function, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionList. -func (in *FunctionList) DeepCopy() *FunctionList { - if in == nil { - return nil - } - out := new(FunctionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FunctionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionRef) DeepCopyInto(out *FunctionRef) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionRef. -func (in *FunctionRef) DeepCopy() *FunctionRef { - if in == nil { - return nil - } - out := new(FunctionRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionSpec) DeepCopyInto(out *FunctionSpec) { - *out = *in - out.RepositoryRef = in.RepositoryRef - if in.FunctionTypes != nil { - in, out := &in.FunctionTypes, &out.FunctionTypes - *out = make([]FunctionType, len(*in)) - copy(*out, *in) - } - if in.FunctionConfigs != nil { - in, out := &in.FunctionConfigs, &out.FunctionConfigs - *out = make([]FunctionConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Keywords != nil { - in, out := &in.Keywords, &out.Keywords - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionSpec. -func (in *FunctionSpec) DeepCopy() *FunctionSpec { - if in == nil { - return nil - } - out := new(FunctionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionStatus) DeepCopyInto(out *FunctionStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionStatus. -func (in *FunctionStatus) DeepCopy() *FunctionStatus { - if in == nil { - return nil - } - out := new(FunctionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitLock) DeepCopyInto(out *GitLock) { *out = *in diff --git a/api/porch/zz_generated.deepcopy.go b/api/porch/zz_generated.deepcopy.go index 3ece4324..03c20e61 100644 --- a/api/porch/zz_generated.deepcopy.go +++ b/api/porch/zz_generated.deepcopy.go @@ -71,56 +71,6 @@ func (in *File) DeepCopy() *File { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Function) DeepCopyInto(out *Function) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Function. -func (in *Function) DeepCopy() *Function { - if in == nil { - return nil - } - out := new(Function) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Function) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionConfig) DeepCopyInto(out *FunctionConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.RequiredFields != nil { - in, out := &in.RequiredFields, &out.RequiredFields - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionConfig. -func (in *FunctionConfig) DeepCopy() *FunctionConfig { - if in == nil { - return nil - } - out := new(FunctionConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FunctionEvalTaskSpec) DeepCopyInto(out *FunctionEvalTaskSpec) { *out = *in @@ -146,105 +96,6 @@ func (in *FunctionEvalTaskSpec) DeepCopy() *FunctionEvalTaskSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionList) DeepCopyInto(out *FunctionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Function, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionList. -func (in *FunctionList) DeepCopy() *FunctionList { - if in == nil { - return nil - } - out := new(FunctionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FunctionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionRef) DeepCopyInto(out *FunctionRef) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionRef. -func (in *FunctionRef) DeepCopy() *FunctionRef { - if in == nil { - return nil - } - out := new(FunctionRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionSpec) DeepCopyInto(out *FunctionSpec) { - *out = *in - out.RepositoryRef = in.RepositoryRef - if in.FunctionTypes != nil { - in, out := &in.FunctionTypes, &out.FunctionTypes - *out = make([]FunctionType, len(*in)) - copy(*out, *in) - } - if in.FunctionConfigs != nil { - in, out := &in.FunctionConfigs, &out.FunctionConfigs - *out = make([]FunctionConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Keywords != nil { - in, out := &in.Keywords, &out.Keywords - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionSpec. -func (in *FunctionSpec) DeepCopy() *FunctionSpec { - if in == nil { - return nil - } - out := new(FunctionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FunctionStatus) DeepCopyInto(out *FunctionStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionStatus. -func (in *FunctionStatus) DeepCopy() *FunctionStatus { - if in == nil { - return nil - } - out := new(FunctionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitLock) DeepCopyInto(out *GitLock) { *out = *in diff --git a/examples/config/function-repository.yaml b/examples/config/function-repository.yaml deleted file mode 100644 index 273388f8..00000000 --- a/examples/config/function-repository.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2022 The kpt and Nephio Authors -# -# 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. - -apiVersion: config.porch.kpt.dev/v1alpha1 -kind: Repository -metadata: - name: kpt-functions - namespace: default -spec: - description: Standard library of core kpt functions to manipulate KRM blueprints. - content: Function - type: oci - oci: - registry: gcr.io/kpt-fn diff --git a/internal/kpt/util/cmdutil/cmdutil.go b/internal/kpt/util/cmdutil/cmdutil.go index 017b65fc..edece955 100644 --- a/internal/kpt/util/cmdutil/cmdutil.go +++ b/internal/kpt/util/cmdutil/cmdutil.go @@ -15,18 +15,12 @@ package cmdutil import ( - "encoding/json" "fmt" "io" "os" "strings" - "github.com/nephio-project/porch/api/porch/v1alpha1" - "github.com/nephio-project/porch/internal/kpt/util/function" - "github.com/nephio-project/porch/internal/kpt/util/httputil" - "github.com/nephio-project/porch/internal/kpt/util/porch" "github.com/spf13/cobra" - "golang.org/x/mod/semver" "sigs.k8s.io/kustomize/kyaml/kio" "sigs.k8s.io/kustomize/kyaml/kio/kioutil" ) @@ -131,79 +125,3 @@ func GetKeywordsFromFlag(cmd *cobra.Command) []string { } return trimmed } - -// SuggestFunctions looks for functions from kpt curated catalog list as well as the Porch -// orchestrator to suggest functions. -func SuggestFunctions(cmd *cobra.Command) []string { - matchers := []function.Matcher{ - function.TypeMatcher{FnType: cmd.Flag("type").Value.String()}, - function.KeywordsMatcher{Keywords: GetKeywordsFromFlag(cmd)}, - } - functions := DiscoverFunctions(cmd) - matched := function.MatchFunctions(functions, matchers...) - return function.GetNames(matched) -} - -// SuggestKeywords looks for all the unique keywords from Porch functions. This keywords -// can later help users to select functions. -func SuggestKeywords(cmd *cobra.Command) []string { - functions := DiscoverFunctions(cmd) - matched := function.MatchFunctions(functions, function.TypeMatcher{FnType: cmd.Flag("type").Value.String()}) - return porch.UnifyKeywords(matched) -} - -func DiscoverFunctions(cmd *cobra.Command) []v1alpha1.Function { - porchFns := porch.FunctionListGetter{}.Get(cmd.Context()) - catalogV2Fns := fetchCatalogFunctions() - return append(porchFns, catalogV2Fns...) -} - -// fetchCatalogFunctions returns the list of latest function images from catalog.kpt.dev. -func fetchCatalogFunctions() []v1alpha1.Function { - content, err := httputil.FetchContent(FunctionsCatalogURL) - if err != nil { - return nil - } - return parseFunctions(content) -} - -// fnName -> v. -> catalogEntry -type catalogV2 map[string]map[string]struct { - LatestPatchVersion string - Examples interface{} - Types []string - Keywords []string -} - -// listImages returns the list of latest images from the input catalog content -func parseFunctions(content string) []v1alpha1.Function { - var jsonData catalogV2 - err := json.Unmarshal([]byte(content), &jsonData) - if err != nil { - return nil - } - var functions []v1alpha1.Function - for fnName, fnInfo := range jsonData { - var latestVersion string - var keywords []string - var fnTypes []v1alpha1.FunctionType - for _, catalogEntry := range fnInfo { - version := catalogEntry.LatestPatchVersion - if semver.Compare(version, latestVersion) == 1 { - latestVersion = version - keywords = catalogEntry.Keywords - for _, tp := range catalogEntry.Types { - switch tp { - case "validator": - fnTypes = append(fnTypes, v1alpha1.FunctionTypeValidator) - case "mutator": - fnTypes = append(fnTypes, v1alpha1.FunctionTypeMutator) - } - } - } - } - fnName := fmt.Sprintf("%s:%s", fnName, latestVersion) - functions = append(functions, function.CatalogFunction(fnName, keywords, fnTypes)) - } - return functions -} diff --git a/internal/kpt/util/cmdutil/cmdutil_test.go b/internal/kpt/util/cmdutil/cmdutil_test.go index cad06074..98da7e38 100644 --- a/internal/kpt/util/cmdutil/cmdutil_test.go +++ b/internal/kpt/util/cmdutil/cmdutil_test.go @@ -17,10 +17,8 @@ package cmdutil import ( "bytes" "path/filepath" - "sort" "testing" - "github.com/nephio-project/porch/internal/kpt/util/function" "github.com/stretchr/testify/assert" "sigs.k8s.io/kustomize/kyaml/kio" ) @@ -306,45 +304,3 @@ metadata: }) } } - -func TestListImages(t *testing.T) { - functions := parseFunctions(`{ - "apply-setters": { - "v0.1": { - "LatestPatchVersion": "v0.1.1", - "Examples": { - "apply-setters-simple": { - "LocalExamplePath": "/apply-setters/v0.1/apply-setters-simple", - "RemoteExamplePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/apply-setters/v0.1/examples/apply-setters-simple", - "RemoteSourcePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/apply-setters/v0.1/functions/go/apply-setters" - } - } - } - }, - "gatekeeper": { - "v0.1": { - "LatestPatchVersion": "v0.1.3", - "Examples": { - "gatekeeper-warning-only": { - "LocalExamplePath": "/gatekeeper/v0.1/gatekeeper-warning-only", - "RemoteExamplePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.1/examples/gatekeeper-warning-only", - "RemoteSourcePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.1/functions/go/gatekeeper" - } - } - }, - "v0.2": { - "LatestPatchVersion": "v0.2.1", - "Examples": { - "gatekeeper-warning-only": { - "LocalExamplePath": "/gatekeeper/v0.2/gatekeeper-warning-only", - "RemoteExamplePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/examples/gatekeeper-warning-only", - "RemoteSourcePath": "https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/gatekeeper/v0.2/functions/go/gatekeeper" - } - } - } - } -}`) - result := function.GetNames(functions) - sort.Strings(result) - assert.Equal(t, []string{"apply-setters:v0.1.1", "gatekeeper:v0.2.1"}, result) -} diff --git a/internal/kpt/util/function/catalogfn.go b/internal/kpt/util/function/catalogfn.go deleted file mode 100644 index 827bd821..00000000 --- a/internal/kpt/util/function/catalogfn.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022 The kpt and Nephio Authors -// -// 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 function - -import ( - "fmt" - - "github.com/nephio-project/porch/api/porch/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// CatalogV2 is the an invalid namespace used to build catalog function into the porch v1alpha1.function struct. -// This namespace distinguishes catalog function from porch functions. This will be trimmed before showing to users. -const CatalogV2 = "__catalog_v2" - -// CatalogFunction converts catalog function into the porch v1alpha1.function struct. -func CatalogFunction(name string, keywords []string, fnTypes []v1alpha1.FunctionType) v1alpha1.Function { - return v1alpha1.Function{ - TypeMeta: metav1.TypeMeta{}, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: CatalogV2, - }, - Spec: v1alpha1.FunctionSpec{ - Image: fmt.Sprintf("gcr.io/kpt-fn/%s", name), - FunctionTypes: fnTypes, - Keywords: keywords, - }, - } -} diff --git a/internal/kpt/util/function/matcher.go b/internal/kpt/util/function/matcher.go deleted file mode 100644 index 9ef286bb..00000000 --- a/internal/kpt/util/function/matcher.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2022 The kpt and Nephio Authors -// -// 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 function - -import ( - "fmt" - - "github.com/nephio-project/porch/api/porch/v1alpha1" -) - -type Matcher interface { - Match(v1alpha1.Function) bool -} - -var _ Matcher = TypeMatcher{} -var _ Matcher = KeywordsMatcher{} - -type TypeMatcher struct { - FnType string -} - -// Match determines whether the `function` (which can be multi-typed), belongs -// to the matcher's FnType. type value should only be `validator` or `mutator`. -func (m TypeMatcher) Match(function v1alpha1.Function) bool { - if m.FnType == "" { - // type is not given, shown all functions. - return true - } - for _, actualType := range function.Spec.FunctionTypes { - if string(actualType) == m.FnType { - return true - } - } - return false -} - -type KeywordsMatcher struct { - Keywords []string -} - -// Match determines whether the `function` has keywords which match the matcher's `Keywords`. -// Experimental: This logic may change to only if all function keywords are found from matcher's `Keywords`, -// can it claims a match (return true). -func (m KeywordsMatcher) Match(function v1alpha1.Function) bool { - if len(m.Keywords) == 0 { - // Accept all functions if keywords are not given. - return true - } - for _, actual := range function.Spec.Keywords { - for _, expected := range m.Keywords { - if actual == expected { - return true - } - } - } - return false -} - -func MatchFunctions(functions []v1alpha1.Function, matchers ...Matcher) []v1alpha1.Function { - var suggestedFunctions []v1alpha1.Function - for _, function := range functions { - match := true - for _, matcher := range matchers { - if !matcher.Match(function) { - match = false - } - } - if match { - suggestedFunctions = append(suggestedFunctions, function) - } - } - return suggestedFunctions -} - -// GetNames returns the list of function names. -// - Porch function name is ::. e.g. kpt-functions:set-annotation:v0.1 -// - Catalog v2 function name is trimed to only contain :, and exclude gcr.io/kpt-fn. e.g. set-annotation:v0.1 -func GetNames(functions []v1alpha1.Function) []string { - var names []string - for _, function := range functions { - var name string - if function.Namespace == CatalogV2 { - name = function.Name - } else { - name = fmt.Sprintf("%v:%v", function.Namespace, function.Name) - } - names = append(names, name) - } - return names -} diff --git a/internal/kpt/util/porch/function.go b/internal/kpt/util/porch/function.go deleted file mode 100644 index e322d3c9..00000000 --- a/internal/kpt/util/porch/function.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2022 The kpt and Nephio Authors -// -// 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 porch - -import ( - "context" - "time" - - "github.com/nephio-project/porch/api/porch/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/cli-runtime/pkg/genericclioptions" - - // Enable the GCP Authentication plugin - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" -) - -const Expiration time.Duration = 10 * time.Second - -// FunctionListGetter gets the list of v1alpha1.Functions from the cluster. -type FunctionListGetter struct{} - -func (f FunctionListGetter) Get(ctx context.Context) []v1alpha1.Function { - kubeflags := genericclioptions.NewConfigFlags(true) - client, err := CreateRESTClient(kubeflags) - if err != nil { - return nil - } - scheme := runtime.NewScheme() - if err := v1alpha1.SchemeBuilder.AddToScheme(scheme); err != nil { - return nil - } - codec := runtime.NewParameterCodec(scheme) - var functions v1alpha1.FunctionList - if err := client.Get(). - Timeout(Expiration). - Resource("functions"). - VersionedParams(&metav1.GetOptions{}, codec). - Do(ctx). - Into(&functions); err != nil { - return nil - } - return functions.Items -} - -// FunctionGetter gets a specific v1alpha1.Functions by name. -type FunctionGetter struct{} - -func (f FunctionGetter) Get(ctx context.Context, name, namespace string) (v1alpha1.Function, error) { - kubeflags := genericclioptions.NewConfigFlags(true) - var function v1alpha1.Function - client, err := CreateRESTClient(kubeflags) - if err != nil { - return function, err - } - scheme := runtime.NewScheme() - if err := v1alpha1.SchemeBuilder.AddToScheme(scheme); err != nil { - return function, err - } - codec := runtime.NewParameterCodec(scheme) - err = client.Get(). - Timeout(Expiration). - Resource("functions"). - Name(name). - Namespace(namespace). - VersionedParams(&metav1.GetOptions{}, codec). - Do(ctx). - Into(&function) - return function, err -} - -func ToShortNames(functions []v1alpha1.Function) []string { - var shortNameFunctions []string - for _, function := range functions { - shortNameFunctions = append(shortNameFunctions, function.Name) - } - return shortNameFunctions -} - -func UnifyKeywords(functions []v1alpha1.Function) []string { - var keywords []string - keywordsMap := map[string]bool{} - for _, function := range functions { - for _, kw := range function.Spec.Keywords { - if _, ok := keywordsMap[kw]; !ok { - keywordsMap[kw] = true - keywords = append(keywords, kw) - } - } - } - return keywords -} diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index af6631bc..f109ee24 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -236,12 +236,6 @@ func (c completedConfig) New() (*PorchServer, error) { runnerOptionsResolver := func(namespace string) fnruntime.RunnerOptions { runnerOptions := fnruntime.RunnerOptions{} runnerOptions.InitDefaults() - r := &KubeFunctionResolver{ - client: coreClient, - defaultImagePrefix: c.ExtraConfig.DefaultImagePrefix, - namespace: namespace, - } - runnerOptions.ResolveToImage = r.resolveToImagePorch return runnerOptions } diff --git a/pkg/apiserver/resolvetoimage.go b/pkg/apiserver/resolvetoimage.go deleted file mode 100644 index 99f17100..00000000 --- a/pkg/apiserver/resolvetoimage.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 The kpt and Nephio Authors -// -// 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 apiserver - -import ( - "context" - "fmt" - "strings" - - "github.com/nephio-project/porch/api/porch/v1alpha1" - "github.com/nephio-project/porch/internal/kpt/util/porch" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// KubeFunctionResolver resolves function names to full image paths -type KubeFunctionResolver struct { - client client.WithWatch - defaultImagePrefix string - // resolver *FunctionResolver - namespace string -} - -// resolveToImagePorch converts the function short path to the full image url. -// If the function is Catalog function, it adds "gcr.io/kpt-fn/".e.g. set-namespace:v0.1 --> gcr.io/kpt-fn/set-namespace:v0.1 -// If the function is porch function, it queries porch to get the function image by name and namespace. -// e.g. default:set-namespace:v0.1 --> us-west1-docker.pkg.dev/cpa-kit-dev/packages/set-namespace:v0.1 -func (r *KubeFunctionResolver) resolveToImagePorch(ctx context.Context, image string) (string, error) { - segments := strings.Split(image, ":") - if len(segments) == 4 { - // Porch function - // TODO: Remove this legacy configuration - functionName := strings.Join(segments[1:], ":") - function, err := porch.FunctionGetter{}.Get(ctx, functionName, segments[0]) - if err != nil { - return "", fmt.Errorf("failed to get image for function %q: %w", image, err) - } - return function.Spec.Image, nil - } - if !strings.Contains(image, "/") { - var function v1alpha1.Function - // TODO: Use fieldSelectors and better lookup - name := "functions:" + image + ":latest" - key := types.NamespacedName{ - Namespace: r.namespace, - Name: name, - } - // We query the apiserver for these types, even if we could query directly; this will then work with CRDs etc. - // TODO: We need to think about priority-and-fairness with loopback queries - if err := r.client.Get(ctx, key, &function); err != nil { - if !apierrors.IsNotFound(err) { - return "", fmt.Errorf("failed to get image for function %q: %w", image, err) - } - } else { - return function.Spec.Image, nil - } - // TODO: Fallback to cluster-scoped? - return r.defaultImagePrefix + image, nil - } - return image, nil -}