-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deletionProtection for releases and objects
Signed-off-by: Nicolas Bigler <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,997 additions
and
543 deletions.
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
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,81 @@ | ||
package v1alpha1 | ||
|
||
import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
|
||
// Note(turkenh): Provider Kubernetes Object already has a ManagementPolicy | ||
// field and implements the logic in its own controller. | ||
// This file contains temporary hacks until we remove the ManagementPolicy field | ||
// from the Provider Kubernetes Object in favor of the one in the ResourceSpec. | ||
// Ultimately, we should remove the ManagementPolicy field from the Provider | ||
// Kubernetes Object and use the one in the ResourceSpec with the help of | ||
// a conversion webhook. | ||
// Something like https://github.com/crossplane/crossplane/pull/3822#issuecomment-1550039349 | ||
|
||
// A ResourceSpec defines the desired state of a managed resource. | ||
type ResourceSpec struct { | ||
// WriteConnectionSecretToReference specifies the namespace and name of a | ||
// Secret to which any connection details for this managed resource should | ||
// be written. Connection details frequently include the endpoint, username, | ||
// and password required to connect to the managed resource. | ||
// This field is planned to be replaced in a future release in favor of | ||
// PublishConnectionDetailsTo. Currently, both could be set independently | ||
// and connection details would be published to both without affecting | ||
// each other. | ||
// +optional | ||
WriteConnectionSecretToReference *xpv1.SecretReference `json:"writeConnectionSecretToRef,omitempty"` | ||
|
||
// PublishConnectionDetailsTo specifies the connection secret config which | ||
// contains a name, metadata and a reference to secret store config to | ||
// which any connection details for this managed resource should be written. | ||
// Connection details frequently include the endpoint, username, | ||
// and password required to connect to the managed resource. | ||
// +optional | ||
PublishConnectionDetailsTo *xpv1.PublishConnectionDetailsTo `json:"publishConnectionDetailsTo,omitempty"` | ||
|
||
// 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 *xpv1.Reference `json:"providerConfigRef,omitempty"` | ||
|
||
// ProviderReference specifies the provider that will be used to create, | ||
// observe, update, and delete this managed resource. | ||
// Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef` | ||
ProviderReference *xpv1.Reference `json:"providerRef,omitempty"` | ||
|
||
// THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored | ||
// unless the relevant Crossplane feature flag is enabled, and may be | ||
// changed or removed without notice. | ||
// ManagementPolicy specifies the level of control Crossplane has over the | ||
// managed external resource. | ||
// This field is planned to replace the DeletionPolicy field in a future | ||
// release. Currently, both could be set independently and non-default | ||
// values would be honored if the feature flag is enabled. | ||
// See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 | ||
// +optional | ||
// +kubebuilder:default=FullControl | ||
// ManagementPolicy xpv1.ManagementPolicy `json:"managementPolicy,omitempty"` | ||
|
||
// DeletionPolicy specifies what will happen to the underlying external | ||
// when this managed resource is deleted - either "Delete" or "Orphan" the | ||
// external resource. | ||
// This field is planned to be deprecated in favor of the ManagementPolicy | ||
// field in a future release. Currently, both could be set independently and | ||
// non-default values would be honored if the feature flag is enabled. | ||
// See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 | ||
// +optional | ||
// +kubebuilder:default=Delete | ||
DeletionPolicy xpv1.DeletionPolicy `json:"deletionPolicy,omitempty"` | ||
} | ||
|
||
// GetManagementPolicies of this Object. | ||
func (mg *Object) GetManagementPolicies() xpv1.ManagementPolicies { | ||
// Note(turkenh): Crossplane runtime reconciler should leave handling of | ||
// ManagementPolicies to the provider controller. This is a temporary hack | ||
// until we remove the ManagementPolicy field from the Provider Kubernetes | ||
// Object in favor of the one in the ResourceSpec. | ||
return []xpv1.ManagementAction{xpv1.ManagementActionAll} | ||
} | ||
|
||
// SetManagementPolicies of this Object. | ||
func (mg *Object) SetManagementPolicies(r xpv1.ManagementPolicies) {} |
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 2020 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} | ||
) | ||
|
||
// Object type metadata. | ||
var ( | ||
ObjectKind = reflect.TypeOf(Object{}).Name() | ||
ObjectGroupKind = schema.GroupKind{Group: Group, Kind: ObjectKind}.String() | ||
ObjectKindAPIVersion = ObjectKind + "." + SchemeGroupVersion.String() | ||
ObjectGroupVersionKind = SchemeGroupVersion.WithKind(ObjectKind) | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Object{}, &ObjectList{}) | ||
} |
Oops, something went wrong.