-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ObservedObjectCollection
API type
#217
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5cf0b0c
Add `ObservedObjectCollection` API type
pedjak 755416f
addressed reviewers comments
pedjak 78bf7cb
use clients.ClientForProvider in connector Connect function
pedjak a13774a
Addressed more reviewer comments
pedjak 0fd806c
Change object names generation convention
pedjak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Copyright 2024 The Crossplane 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 contains the v1alpha1 group ObservedObjectCollection resources of the Kubernetes provider. | ||
// +kubebuilder:ac:generate=true | ||
// +kubebuilder:object:generate=true | ||
// +groupName=kubernetes.crossplane.io | ||
// +versionName=v1alpha1 | ||
package v1alpha1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2024 The Crossplane 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 ( | ||
"reflect" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
// Package type metadata. | ||
const ( | ||
Group = "kubernetes.crossplane.io" | ||
Version = "v1alpha1" | ||
) | ||
|
||
var ( | ||
// SchemeGroupVersion is group version used to register these objects | ||
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} | ||
) | ||
|
||
// ProviderConfig type metadata. | ||
var ( | ||
ObservedObjectCollectionKind = reflect.TypeOf(ObservedObjectCollection{}).Name() | ||
ObservedObjectCollectionGroupKind = schema.GroupKind{Group: Group, Kind: ObservedObjectCollectionKind}.String() | ||
ObservedObjectCollectionAPIVersion = ObservedObjectCollectionKind + "." + SchemeGroupVersion.String() | ||
ObservedObjectCollectionGroupVersionKind = SchemeGroupVersion.WithKind(ObservedObjectCollectionKind) | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&ObservedObjectCollection{}, &ObservedObjectCollectionList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
Copyright 2024 The Crossplane 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 ( | ||
"k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
v12 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// A ObservedObjectCollection is a provider Kubernetes API type | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="KIND",type="string",JSONPath=".spec.kind" | ||
// +kubebuilder:printcolumn:name="APIVERSION",type="string",JSONPath=".spec.apiVersion",priority=1 | ||
// +kubebuilder:printcolumn:name="PROVIDERCONFIG",type="string",JSONPath=".spec.providerConfigRef.name" | ||
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" | ||
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" | ||
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" | ||
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,kubernetes} | ||
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 64",message="metadata.name max length is 63" | ||
type ObservedObjectCollection struct { | ||
v1.TypeMeta `json:",inline"` | ||
v1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec ObservedObjectCollectionSpec `json:"spec"` | ||
Status ObservedObjectCollectionStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// ObservedObjectCollectionList contains a list of ObservedObjectCollection | ||
type ObservedObjectCollectionList struct { | ||
v1.TypeMeta `json:",inline"` | ||
v1.ListMeta `json:"metadata,omitempty"` | ||
Items []ObservedObjectCollection `json:"items"` | ||
} | ||
|
||
// ObservedObjectCollectionSpec defines the desired state of ObservedObjectCollection | ||
type ObservedObjectCollectionSpec struct { | ||
|
||
// ObserveObjects declares what criteria object need to fulfil | ||
// to become a member of this collection | ||
ObserveObjects ObserveObjectCriteria `json:"observeObjects"` | ||
|
||
// ProviderConfigReference specifies how the provider that will be used to | ||
// create, observe, update, and delete this managed resource should be | ||
// configured. | ||
// +kubebuilder:default={"name": "default"} | ||
ProviderConfigReference v12.Reference `json:"providerConfigRef,omitempty"` | ||
|
||
// Template when defined is used for creating Object instances | ||
// +optional | ||
Template *ObservedObjectTemplate `json:"objectTemplate,omitempty"` | ||
} | ||
|
||
// ObserveObjectCriteria declares criteria for an object to be a part of collection | ||
type ObserveObjectCriteria struct { | ||
|
||
// APIVersion of objects that should be matched by the selector | ||
// +kubebuilder:validation:MinLength:=1 | ||
APIVersion string `json:"apiVersion"` | ||
|
||
// Kind of objects that should be matched by the selector | ||
// +kubebuilder:validation:MinLength:=1 | ||
Kind string `json:"kind"` | ||
|
||
// Namespace where to look for objects. | ||
// If omitted, search is performed across all namespaces. | ||
// For cluster-scoped objects, omit it. | ||
// +optional | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// Selector defines the criteria for including objects into the collection | ||
Selector v1.LabelSelector `json:"selector"` | ||
} | ||
|
||
// ObservedObjectTemplate represents template used when creating observe-only Objects matching the given selector | ||
type ObservedObjectTemplate struct { | ||
|
||
// Objects metadata | ||
Metadata ObservedObjectTemplateMetadata `json:"metadata,omitempty"` | ||
} | ||
|
||
// ObservedObjectTemplateMetadata represents objects metadata | ||
type ObservedObjectTemplateMetadata struct { | ||
|
||
// Labels of an object | ||
Labels map[string]string `json:"labels,omitempty"` | ||
|
||
// Annotations of an object | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
} | ||
|
||
// ObservedObjectCollectionStatus represents the observed state of a ObservedObjectCollection | ||
type ObservedObjectCollectionStatus struct { | ||
v12.ResourceStatus `json:",inline"` | ||
|
||
// MembershipLabel is the label set on each member of this collection | ||
// and can be used for fetching them. | ||
// +optional | ||
MembershipLabel map[string]string `json:"membershipLabel,omitempty"` | ||
} | ||
|
||
// ObservedObjectReference represents a reference to Object with ObserveOnly management policy | ||
type ObservedObjectReference struct { | ||
|
||
// Name of the observed object | ||
// +kubebuilder:validation:MinLength:=1 | ||
// +kubebuilder:validation:MaxLength:=253 | ||
Name string `json:"name"` | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this field in the status? AFAIU, it is always deterministic and we don't have to store this in status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #217 (comment)
IMHO, instead of relying on a convention, we can make the label discoverable by users.