Skip to content

Commit

Permalink
Generate reconcilers for resources out of tree. (knative#1175)
Browse files Browse the repository at this point in the history
* genreconciler:nonNamespaced

* Adding a force-kinds flag to the reconciler generator to allow us to generate reconcilers for non-owned types.

* force-kinds --> force-genreconciler-kinds

* some minor nits with the generators for non-knative types needed to be removed.

* remove whitespace

Co-authored-by: Nacho Cano <[email protected]>
  • Loading branch information
n3wscott and nachocano authored Mar 25, 2020
1 parent 079ae27 commit 8a6d25b
Show file tree
Hide file tree
Showing 17 changed files with 1,377 additions and 21 deletions.
1 change: 1 addition & 0 deletions Gopkg.lock

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

94 changes: 94 additions & 0 deletions apis/test/example/v1alpha1/fiz_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Copyright 2020 The Knative 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 v1alpha1

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/kmeta"
)

// +genclient
// +genclient:nonNamespaced
// +genreconciler
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterFiz is for testing.
type ClusterFiz struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec holds the desired state of the ClusterFiz (from the client).
// +optional
Spec ClusterFizSpec `json:"spec,omitempty"`

// Status communicates the observed state of the ClusterFiz (from the controller).
// +optional
Status ClusterFizStatus `json:"status,omitempty"`
}

// Check that ClusterFiz can be validated and defaulted.
var _ apis.Validatable = (*ClusterFiz)(nil)
var _ apis.Defaultable = (*ClusterFiz)(nil)
var _ kmeta.OwnerRefable = (*ClusterFiz)(nil)

// ClusterFizSpec holds the desired state of the ClusterFiz (from the client).
type ClusterFizSpec struct{}

// ClusterFizStatus communicates the observed state of the ClusterFiz (from the controller).
type ClusterFizStatus struct {
duckv1.Status `json:",inline"`
}

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

// ClusterFizList is a list of ClusterFiz resources
type ClusterFizList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ClusterFiz `json:"items"`
}

// -- lifecycle --

func (fs *ClusterFizStatus) InitializeConditions() {}

// GetGroupVersionKind implements kmeta.OwnerRefable
func (f *ClusterFiz) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Bar")
}

// -- Defaults --

// SetDefaults implements apis.Defaultable
func (f *ClusterFiz) SetDefaults(ctx context.Context) {
// Nothing to default.
}

// -- Validation --

// Validate implements apis.Validatable
func (f *ClusterFiz) Validate(ctx context.Context) *apis.FieldError {
// Nothing to validate.
return nil
}
94 changes: 94 additions & 0 deletions apis/test/example/v1alpha1/zz_generated.deepcopy.go

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

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

Loading

0 comments on commit 8a6d25b

Please sign in to comment.