Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Change subnamespace object to SubnamespaceAnchor #704

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions incubator/hnc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ Within the `reconcilers` directory, there are four reconcilers:

* **HNCConfiguration reconciler:** manages the HNCConfiguration via the
cluster-wide `config` singleton.
* **HierarchicalNamespace reconciler:** manages the self-service namespaces via
the `hierarchicalnamespace` resources.
* **Anchor reconciler:** manages the subnamespace anchors via
the `subnamespaceanchor` resources.
* **HierarchyConfiguration reconciler:** manages the hierarchy and the
namespaces via the `hierarchy` singleton per namespace.
* **Object reconciler:** propagates (copies and deletes) the relevant objects
Expand Down
84 changes: 0 additions & 84 deletions incubator/hnc/api/v1alpha1/hierarchical_namespace.go

This file was deleted.

16 changes: 8 additions & 8 deletions incubator/hnc/api/v1alpha1/hierarchy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const (

// Condition codes. *All* codes must also be documented in the comment to Condition.Code.
const (
CritParentMissing Code = "CritParentMissing"
CritParentInvalid Code = "CritParentInvalid"
CritAncestor Code = "CritAncestor"
HNSMissing Code = "HNSMissing"
CannotPropagate Code = "CannotPropagateObject"
CannotUpdate Code = "CannotUpdateObject"
CritParentMissing Code = "CritParentMissing"
CritParentInvalid Code = "CritParentInvalid"
CritAncestor Code = "CritAncestor"
SubnamespaceAnchorMissing Code = "SubnamespaceAnchorMissing"
CannotPropagate Code = "CannotPropagateObject"
CannotUpdate Code = "CannotUpdateObject"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down Expand Up @@ -123,8 +123,8 @@ type Condition struct {
// - "CritAncestor": a critical error exists in an ancestor namespace, so this namespace is no
// longer being updated either.
//
// - "HNSMissing": this namespace is a subnamespace, but the hierarchicalnamespace instance
// referenced in its `subnamespaceOf` annotation does not exist in the parent.
// - "SubnamespaceAnchorMissing": this namespace is a subnamespace, but the anchor referenced in
// its `subnamespaceOf` annotation does not exist in the parent.
//
// - "CannotPropagateObject": this namespace contains an object that couldn't be propagated to
// one or more of its descendants. The condition's affect objects will include a list of the
Expand Down
84 changes: 84 additions & 0 deletions incubator/hnc/api/v1alpha1/subnamespace_anchor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*

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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Constants for the subnamespace anchor resource type and namespace annotation.
const (
Anchors = "subnamespaceanchors"
AnchorKind = "SubnamespaceAnchor"
AnchorAPIVersion = MetaGroup + "/v1alpha1"
SubnamespaceOf = MetaGroup + "/subnamespaceOf"
)

// SubnamespaceAnchorState describes the state of the subnamespace. The state could be
// "missing", "ok", "conflict" or "forbidden". The definitions will be described below.
type SubnamespaceAnchorState string

// Anchor states, which are documented in the comment to SubnamespaceAnchorStatus.State.
const (
Missing SubnamespaceAnchorState = "missing"
Ok SubnamespaceAnchorState = "ok"
Conflict SubnamespaceAnchorState = "conflict"
Forbidden SubnamespaceAnchorState = "forbidden"
)

// SubnamespaceAnchorStatus defines the observed state of SubnamespaceAnchor.
type SubnamespaceAnchorStatus struct {
// Describes the state of the subnamespace anchor.
//
// Currently, the supported values are:
//
// - "missing": the subnamespace has not been created yet. This should be the default state when
// the anchor is just created.
//
// - "ok": the subnamespace exists.
//
// - "conflict": a namespace of the same name already exists. The admission controller will
// attempt to prevent this.
//
// - "forbidden": the anchor was created in a namespace that doesn't allow children, such as
// kube-system or hnc-system. The admission controller will attempt to prevent this.
State SubnamespaceAnchorState `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=subnamespaceanchors,shortName=subns,scope=Namespaced

// SubnamespaceAnchor is the Schema for the subnamespace API.
// See details at http://bit.ly/hnc-self-serve-ux.
type SubnamespaceAnchor struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Status SubnamespaceAnchorStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// SubnamespaceAnchorList contains a list of SubnamespaceAnchor.
type SubnamespaceAnchorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SubnamespaceAnchor `json:"items"`
}

func init() {
SchemeBuilder.Register(&SubnamespaceAnchor{}, &SubnamespaceAnchorList{})
}
Loading