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

Commit

Permalink
default config
Browse files Browse the repository at this point in the history
  • Loading branch information
k8s-ci-robot authored and sophieliu15 committed Feb 28, 2020
2 parents ac8554b + a2bad3f commit 7eacdb3
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 467 deletions.
79 changes: 0 additions & 79 deletions incubator/hnc/api/v1alpha1/hierarchical_namespace.go

This file was deleted.

4 changes: 2 additions & 2 deletions incubator/hnc/api/v1alpha1/hierarchy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

// Constants for types and well-known names
const (
Singleton = "hierarchy"
HierarchyConfigurations = "hierarchyconfigurations"
Singleton = "hierarchy"
Resource = "hierarchyconfigurations"
)

// Constants for labels and annotations
Expand Down
73 changes: 0 additions & 73 deletions incubator/hnc/api/v1alpha1/zz_generated.deepcopy.go

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

This file was deleted.

1 change: 0 additions & 1 deletion incubator/hnc/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
resources:
- bases/hnc.x-k8s.io_hierarchyconfigurations.yaml
- bases/hnc.x-k8s.io_hncconfigurations.yaml
- bases/hnc.x-k8s.io_hierarchicalnamespaces.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
5 changes: 0 additions & 5 deletions incubator/hnc/config/samples/hnc_v1_hns.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions incubator/hnc/pkg/kubectl/create2.go

This file was deleted.

20 changes: 3 additions & 17 deletions incubator/hnc/pkg/kubectl/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type realClient struct{}
type Client interface {
getHierarchy(nnm string) *api.HierarchyConfiguration
updateHierarchy(hier *api.HierarchyConfiguration, reason string)
createHierarchicalNamespace(nnm string, hnnm string)
}

func init() {
Expand Down Expand Up @@ -88,7 +87,6 @@ func init() {
rootCmd.AddCommand(newDescribeCmd())
rootCmd.AddCommand(newTreeCmd())
rootCmd.AddCommand(newCreateCmd())
rootCmd.AddCommand(newCreate2Cmd())
}

func Execute() {
Expand All @@ -113,7 +111,7 @@ func (cl *realClient) getHierarchy(nnm string) *api.HierarchyConfiguration {
hier := &api.HierarchyConfiguration{}
hier.Name = api.Singleton
hier.Namespace = nnm
err := hncClient.Get().Resource(api.HierarchyConfigurations).Namespace(nnm).Name(api.Singleton).Do().Into(hier)
err := hncClient.Get().Resource(api.Resource).Namespace(nnm).Name(api.Singleton).Do().Into(hier)
if err != nil && !errors.IsNotFound(err) {
fmt.Printf("Error reading hierarchy for %s: %s\n", nnm, err)
os.Exit(1)
Expand All @@ -125,28 +123,16 @@ func (cl *realClient) updateHierarchy(hier *api.HierarchyConfiguration, reason s
nnm := hier.Namespace
var err error
if hier.CreationTimestamp.IsZero() {
err = hncClient.Post().Resource(api.HierarchyConfigurations).Namespace(nnm).Name(api.Singleton).Body(hier).Do().Error()
err = hncClient.Post().Resource(api.Resource).Namespace(nnm).Name(api.Singleton).Body(hier).Do().Error()
} else {
err = hncClient.Put().Resource(api.HierarchyConfigurations).Namespace(nnm).Name(api.Singleton).Body(hier).Do().Error()
err = hncClient.Put().Resource(api.Resource).Namespace(nnm).Name(api.Singleton).Body(hier).Do().Error()
}
if err != nil {
fmt.Printf("\nCould not %s.\nReason: %s\n", reason, err)
os.Exit(1)
}
}

func (cl *realClient) createHierarchicalNamespace(nnm string, hnnm string) {
hns := &api.HierarchicalNamespace{}
hns.Name = hnnm
hns.Namespace = nnm
err := hncClient.Post().Resource(api.HierarchicalNamespaces).Namespace(nnm).Name(hnnm).Body(hns).Do().Error()
if err != nil {
fmt.Printf("\nCould not create hierarchicalnamespace instance.\nReason: %s\n", err)
os.Exit(1)
}
fmt.Printf("Successfully created \"%s\" hierarchicalnamespace instance in \"%s\" namespace\n", hnnm, nnm)
}

func childNamespaceExists(hier *api.HierarchyConfiguration, cn string) bool {
for _, n := range hier.Spec.RequiredChildren {
if cn == n {
Expand Down
Loading

0 comments on commit 7eacdb3

Please sign in to comment.