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

Commit

Permalink
Merge pull request #127 from wackxu/ref
Browse files Browse the repository at this point in the history
Refactor crinit util package into multiple packages
  • Loading branch information
k8s-ci-robot committed Jan 11, 2018
2 parents 6fce5ea + 7e6530b commit 2e72694
Show file tree
Hide file tree
Showing 11 changed files with 947 additions and 865 deletions.
2 changes: 2 additions & 0 deletions pkg/crinit/aggregated/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/clusterregistry/v1alpha1:go_default_library",
"//pkg/crinit/common:go_default_library",
"//pkg/crinit/options:go_default_library",
"//pkg/crinit/util:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
Expand Down
18 changes: 10 additions & 8 deletions pkg/crinit/aggregated/aggregated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"k8s.io/client-go/util/cert"
"k8s.io/cluster-registry/pkg/apis/clusterregistry/v1alpha1"
"k8s.io/cluster-registry/pkg/crinit/util"
"k8s.io/cluster-registry/pkg/crinit/options"
"k8s.io/cluster-registry/pkg/crinit/common"
apiregv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1"
apiregclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"

Expand Down Expand Up @@ -97,12 +99,12 @@ var (
)

type aggregatedClusterRegistryOptions struct {
util.SubcommandOptions
options.SubcommandOptions
apiServerServiceTypeString string
}

func (o *aggregatedClusterRegistryOptions) Bind(flags *pflag.FlagSet) {
flags.StringVar(&o.apiServerServiceTypeString, util.APIServerServiceTypeFlag,
flags.StringVar(&o.apiServerServiceTypeString, options.APIServerServiceTypeFlag,
string(v1.ServiceTypeNodePort),
"The type of service to create for the cluster registry. Options: 'LoadBalancer', 'NodePort'.")
}
Expand Down Expand Up @@ -299,7 +301,7 @@ func createServiceAccount(clientset client.Interface,
ObjectMeta: metav1.ObjectMeta{
Name: serviceAccountName,
Namespace: namespace,
Labels: util.ComponentLabel,
Labels: common.ComponentLabel,
},
}

Expand All @@ -324,7 +326,7 @@ func createClusterRole(clientset client.Interface,
cr := &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: clusterRoleName,
Labels: util.ComponentLabel,
Labels: common.ComponentLabel,
},
Rules: []rbacv1.PolicyRule{rule},
}
Expand All @@ -345,7 +347,7 @@ func createClusterRoleBindings(clientset client.Interface,
// cluster role.
crb, err := createClusterRoleBindingObject(clientset, apiServerCRBName,
rbacv1.ServiceAccountKind, serviceAccountName, namespace, rbacv1.GroupName,
"ClusterRole", clusterRoleName, util.ComponentLabel, dryRun)
"ClusterRole", clusterRoleName, common.ComponentLabel, dryRun)

if err != nil {
glog.V(4).Infof("Failed to create cluster role binding %v: %v", crb, err)
Expand All @@ -355,7 +357,7 @@ func createClusterRoleBindings(clientset client.Interface,
// Create cluster role binding for the system:auth-delegator cluster role.
crb, err = createClusterRoleBindingObject(clientset, authDelegatorCRBName,
rbacv1.ServiceAccountKind, serviceAccountName, namespace, rbacv1.GroupName,
"ClusterRole", "system:auth-delegator", util.ComponentLabel, dryRun)
"ClusterRole", "system:auth-delegator", common.ComponentLabel, dryRun)

if err != nil {
glog.V(4).Infof("Failed to create cluster role binding %v: %v", crb, err)
Expand Down Expand Up @@ -404,7 +406,7 @@ func createExtensionAPIServerAuthenticationRoleBinding(clientset client.Interfac
rb := &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: util.ComponentLabel,
Labels: common.ComponentLabel,
},
Subjects: []rbacv1.Subject{
{
Expand Down Expand Up @@ -462,7 +464,7 @@ func createAPIServiceObject(clientset apiregclient.Interface,
apiSvc := &apiregv1beta1.APIService{
ObjectMeta: metav1.ObjectMeta{
Name: apiServiceName,
Labels: util.ComponentLabel,
Labels: common.ComponentLabel,
},
Spec: apiregv1beta1.APIServiceSpec{
Service: &apiregv1beta1.ServiceReference{
Expand Down
19 changes: 19 additions & 0 deletions pkg/crinit/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["common.go"],
importpath = "k8s.io/cluster-registry/pkg/crinit/common",
visibility = ["//visibility:public"],
deps = [
"//pkg/crinit/util:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/util/cert:go_default_library",
],
)
Loading

0 comments on commit 2e72694

Please sign in to comment.