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

Commit cfa52a1

Browse files
committed
fix cycle in the dependency
1 parent a52d583 commit cfa52a1

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

pkg/crinit/common/common.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333

3434
certutil "k8s.io/client-go/util/cert"
3535
"k8s.io/cluster-registry/pkg/crinit/util"
36-
"k8s.io/client-go/util/cert/triple"
3736
)
3837

3938
const (
@@ -63,18 +62,7 @@ var (
6362
}
6463
)
6564

66-
type EntityKeyPairs struct {
67-
CA *triple.KeyPair
68-
Server *triple.KeyPair
69-
Admin *triple.KeyPair
70-
}
7165

72-
type Credentials struct {
73-
Username string
74-
Password string
75-
Token string
76-
CertEntKeyPairs *EntityKeyPairs
77-
}
7866

7967
// CreateNamespace helper to create the cluster registry namespace object and return
8068
// the object.
@@ -183,7 +171,7 @@ func GetClusterNodeIPs(clientset client.Interface) ([]string, error) {
183171
// CreateAPIServerCredentialsSecret helper to create secret object and return
184172
// the object.
185173
func CreateAPIServerCredentialsSecret(clientset client.Interface, namespace,
186-
credentialsName string, credentials *Credentials, dryRun bool) (*v1.Secret, error) {
174+
credentialsName string, credentials *util.Credentials, dryRun bool) (*v1.Secret, error) {
187175
// Build the secret object with API server credentials.
188176
data := map[string][]byte{
189177
"ca.crt": certutil.EncodeCertPEM(credentials.CertEntKeyPairs.CA.Cert),

pkg/crinit/options/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (o *SubcommandOptions) CreateService(cmdOut io.Writer,
226226
// GenerateCredentials creates the credentials for apiserver secret.
227227
func (o *SubcommandOptions) GenerateCredentials(cmdOut io.Writer, svcName string,
228228
ips, hostnames []string, apiServerEnableHTTPBasicAuth,
229-
apiServerEnableTokenAuth bool) (*common.Credentials, error) {
229+
apiServerEnableTokenAuth bool) (*util.Credentials, error) {
230230

231231
fmt.Fprint(cmdOut,
232232
"Creating cluster registry objects (credentials, persistent volume claim)...")
@@ -246,7 +246,7 @@ func (o *SubcommandOptions) GenerateCredentials(cmdOut io.Writer, svcName string
246246
// CreateAPIServerCredentialsSecret creates the secret containing the
247247
// apiserver credentials passed in.
248248
func (o *SubcommandOptions) CreateAPIServerCredentialsSecret(clientset client.Interface,
249-
credentials *common.Credentials) error {
249+
credentials *util.Credentials) error {
250250

251251
_, err := common.CreateAPIServerCredentialsSecret(clientset,
252252
o.ClusterRegistryNamespace, serverCredName, credentials, o.DryRun)
@@ -315,7 +315,7 @@ func (o *SubcommandOptions) CreateAPIServer(cmdOut io.Writer, clientset client.I
315315
// while printing and logging progress.
316316
func (o *SubcommandOptions) UpdateKubeconfig(cmdOut io.Writer,
317317
pathOptions *clientcmd.PathOptions, svc *v1.Service, ips, hostnames []string,
318-
credentials *common.Credentials) error {
318+
credentials *util.Credentials) error {
319319

320320
fmt.Fprint(cmdOut, "Updating kubeconfig...")
321321
glog.V(4).Info("Updating kubeconfig")

pkg/crinit/util/util.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
3131
certutil "k8s.io/client-go/util/cert"
3232
"k8s.io/client-go/util/cert/triple"
33-
"k8s.io/cluster-registry/pkg/crinit/common"
3433
"github.com/golang/glog"
3534
)
3635

@@ -39,11 +38,24 @@ const (
3938
AdminCN = "admin"
4039
)
4140

41+
type EntityKeyPairs struct {
42+
CA *triple.KeyPair
43+
Server *triple.KeyPair
44+
Admin *triple.KeyPair
45+
}
46+
47+
type Credentials struct {
48+
Username string
49+
Password string
50+
Token string
51+
CertEntKeyPairs *EntityKeyPairs
52+
}
53+
4254
// generateCredentials helper to create the certs for the apiserver.
4355
func GenerateCredentials(svcNamespace, name, svcName, localDNSZoneName string,
44-
ips, hostnames []string, enableHTTPBasicAuth, enableTokenAuth bool) (*common.Credentials, error) {
56+
ips, hostnames []string, enableHTTPBasicAuth, enableTokenAuth bool) (*Credentials, error) {
4557

46-
credentials := common.Credentials{
58+
credentials := Credentials{
4759
Username: AdminCN,
4860
}
4961
if enableHTTPBasicAuth {
@@ -62,7 +74,7 @@ func GenerateCredentials(svcNamespace, name, svcName, localDNSZoneName string,
6274
}
6375

6476
func GenCerts(svcNamespace, name, svcName, localDNSZoneName string,
65-
ips, hostnames []string) (*common.EntityKeyPairs, error) {
77+
ips, hostnames []string) (*EntityKeyPairs, error) {
6678
ca, err := triple.NewCA(name)
6779

6880
if err != nil {
@@ -76,7 +88,7 @@ func GenCerts(svcNamespace, name, svcName, localDNSZoneName string,
7688
if err != nil {
7789
return nil, fmt.Errorf("failed to create client key and certificate for an admin: %v", err)
7890
}
79-
return &common.EntityKeyPairs{
91+
return &EntityKeyPairs{
8092
CA: ca,
8193
Server: server,
8294
Admin: admin,
@@ -99,7 +111,7 @@ func ArgMapsToArgStrings(argsMap, overrides map[string]string) []string {
99111
// UpdateKubeconfig helper to update the kubeconfig file based on input
100112
// parameters.
101113
func UpdateKubeconfig(pathOptions *clientcmd.PathOptions, name, endpoint,
102-
kubeConfigPath string, credentials *common.Credentials, dryRun bool) error {
114+
kubeConfigPath string, credentials *Credentials, dryRun bool) error {
103115

104116
pathOptions.LoadingRules.ExplicitPath = kubeConfigPath
105117
kubeconfig, err := pathOptions.GetStartingConfig()
@@ -193,7 +205,7 @@ func AuthFileContents(username, authSecret string) []byte {
193205

194206
// GetCAKeyPair retrieves the CA key pair stored in the internal credentials
195207
// structure.
196-
func GetCAKeyPair(credentials *common.Credentials) *triple.KeyPair {
208+
func GetCAKeyPair(credentials *Credentials) *triple.KeyPair {
197209
if credentials == nil {
198210
glog.V(4).Info("credentials argument is nil!")
199211
return nil

0 commit comments

Comments
 (0)