Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
036463dd
Unverified
Commit
036463dd
authored
Feb 23, 2017
by
Lucas Käldström
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix golint issues
parent
69c24afc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
kubeconfig.go
cmd/kubeadm/app/cmd/phases/kubeconfig.go
+6
-6
kubeconfig.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
+6
-4
No files found.
cmd/kubeadm/app/cmd/phases/kubeconfig.go
View file @
036463dd
...
@@ -40,7 +40,7 @@ func NewCmdKubeConfig(out io.Writer) *cobra.Command {
...
@@ -40,7 +40,7 @@ func NewCmdKubeConfig(out io.Writer) *cobra.Command {
}
}
func
NewCmdToken
(
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdToken
(
out
io
.
Writer
)
*
cobra
.
Command
{
config
:=
&
kubeconfigphase
.
Kube
ConfigProperties
{
config
:=
&
kubeconfigphase
.
Build
ConfigProperties
{
MakeClientCerts
:
false
,
MakeClientCerts
:
false
,
}
}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -57,7 +57,7 @@ func NewCmdToken(out io.Writer) *cobra.Command {
...
@@ -57,7 +57,7 @@ func NewCmdToken(out io.Writer) *cobra.Command {
}
}
func
NewCmdClientCerts
(
out
io
.
Writer
)
*
cobra
.
Command
{
func
NewCmdClientCerts
(
out
io
.
Writer
)
*
cobra
.
Command
{
config
:=
&
kubeconfigphase
.
Kube
ConfigProperties
{
config
:=
&
kubeconfigphase
.
Build
ConfigProperties
{
MakeClientCerts
:
true
,
MakeClientCerts
:
true
,
}
}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -73,13 +73,13 @@ func NewCmdClientCerts(out io.Writer) *cobra.Command {
...
@@ -73,13 +73,13 @@ func NewCmdClientCerts(out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
addCommonFlags
(
cmd
*
cobra
.
Command
,
config
*
kubeconfigphase
.
Kube
ConfigProperties
)
{
func
addCommonFlags
(
cmd
*
cobra
.
Command
,
config
*
kubeconfigphase
.
Build
ConfigProperties
)
{
cmd
.
Flags
()
.
StringVar
(
&
config
.
CertDir
,
"cert-dir"
,
kubeadmconstants
.
DefaultCertDir
,
"The path to the directory where the certificates are."
)
cmd
.
Flags
()
.
StringVar
(
&
config
.
CertDir
,
"cert-dir"
,
kubeadmconstants
.
DefaultCertDir
,
"The path to the directory where the certificates are."
)
cmd
.
Flags
()
.
StringVar
(
&
config
.
ClientName
,
"client-name"
,
""
,
"The name of the client for which the KubeConfig file will be generated."
)
cmd
.
Flags
()
.
StringVar
(
&
config
.
ClientName
,
"client-name"
,
""
,
"The name of the client for which the KubeConfig file will be generated."
)
cmd
.
Flags
()
.
StringVar
(
&
config
.
APIServer
,
"server"
,
""
,
"The location of the api server."
)
cmd
.
Flags
()
.
StringVar
(
&
config
.
APIServer
,
"server"
,
""
,
"The location of the api server."
)
}
}
func
validateCommonFlags
(
config
*
kubeconfigphase
.
Kube
ConfigProperties
)
error
{
func
validateCommonFlags
(
config
*
kubeconfigphase
.
Build
ConfigProperties
)
error
{
if
len
(
config
.
ClientName
)
==
0
{
if
len
(
config
.
ClientName
)
==
0
{
return
fmt
.
Errorf
(
"The --client-name flag is required"
)
return
fmt
.
Errorf
(
"The --client-name flag is required"
)
}
}
...
@@ -90,7 +90,7 @@ func validateCommonFlags(config *kubeconfigphase.KubeConfigProperties) error {
...
@@ -90,7 +90,7 @@ func validateCommonFlags(config *kubeconfigphase.KubeConfigProperties) error {
}
}
// RunCreateWithToken generates a kubeconfig file from with a token as the authentication mechanism
// RunCreateWithToken generates a kubeconfig file from with a token as the authentication mechanism
func
RunCreateWithToken
(
out
io
.
Writer
,
config
*
kubeconfigphase
.
Kube
ConfigProperties
)
error
{
func
RunCreateWithToken
(
out
io
.
Writer
,
config
*
kubeconfigphase
.
Build
ConfigProperties
)
error
{
if
len
(
config
.
Token
)
==
0
{
if
len
(
config
.
Token
)
==
0
{
return
fmt
.
Errorf
(
"The --token flag is required"
)
return
fmt
.
Errorf
(
"The --token flag is required"
)
}
}
...
@@ -106,7 +106,7 @@ func RunCreateWithToken(out io.Writer, config *kubeconfigphase.KubeConfigPropert
...
@@ -106,7 +106,7 @@ func RunCreateWithToken(out io.Writer, config *kubeconfigphase.KubeConfigPropert
}
}
// RunCreateWithClientCerts generates a kubeconfig file from with client certs as the authentication mechanism
// RunCreateWithClientCerts generates a kubeconfig file from with client certs as the authentication mechanism
func
RunCreateWithClientCerts
(
out
io
.
Writer
,
config
*
kubeconfigphase
.
Kube
ConfigProperties
)
error
{
func
RunCreateWithClientCerts
(
out
io
.
Writer
,
config
*
kubeconfigphase
.
Build
ConfigProperties
)
error
{
if
err
:=
validateCommonFlags
(
config
);
err
!=
nil
{
if
err
:=
validateCommonFlags
(
config
);
err
!=
nil
{
return
err
return
err
}
}
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
View file @
036463dd
...
@@ -31,7 +31,8 @@ import (
...
@@ -31,7 +31,8 @@ import (
kubeconfigutil
"k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
kubeconfigutil
"k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
)
)
type
KubeConfigProperties
struct
{
// BuildConfigProperties holds some simple information about how this phase should build the KubeConfig object
type
BuildConfigProperties
struct
{
CertDir
string
CertDir
string
ClientName
string
ClientName
string
Organization
[]
string
Organization
[]
string
...
@@ -59,7 +60,7 @@ func CreateInitKubeConfigFiles(masterEndpoint, pkiDir, outDir string) error {
...
@@ -59,7 +60,7 @@ func CreateInitKubeConfigFiles(masterEndpoint, pkiDir, outDir string) error {
}
}
// Create a lightweight specification for what the files should look like
// Create a lightweight specification for what the files should look like
filesToCreateFromSpec
:=
map
[
string
]
Kube
ConfigProperties
{
filesToCreateFromSpec
:=
map
[
string
]
Build
ConfigProperties
{
kubeadmconstants
.
AdminKubeConfigFileName
:
{
kubeadmconstants
.
AdminKubeConfigFileName
:
{
ClientName
:
"kubernetes-admin"
,
ClientName
:
"kubernetes-admin"
,
APIServer
:
masterEndpoint
,
APIServer
:
masterEndpoint
,
...
@@ -105,7 +106,8 @@ func CreateInitKubeConfigFiles(masterEndpoint, pkiDir, outDir string) error {
...
@@ -105,7 +106,8 @@ func CreateInitKubeConfigFiles(masterEndpoint, pkiDir, outDir string) error {
return
nil
return
nil
}
}
func
GetKubeConfigBytesFromSpec
(
config
KubeConfigProperties
)
([]
byte
,
error
)
{
// GetKubeConfigBytesFromSpec takes properties how to build a KubeConfig file and then returns the bytes of that file
func
GetKubeConfigBytesFromSpec
(
config
BuildConfigProperties
)
([]
byte
,
error
)
{
kubeconfig
,
err
:=
buildKubeConfig
(
config
)
kubeconfig
,
err
:=
buildKubeConfig
(
config
)
if
err
!=
nil
{
if
err
!=
nil
{
return
[]
byte
{},
err
return
[]
byte
{},
err
...
@@ -119,7 +121,7 @@ func GetKubeConfigBytesFromSpec(config KubeConfigProperties) ([]byte, error) {
...
@@ -119,7 +121,7 @@ func GetKubeConfigBytesFromSpec(config KubeConfigProperties) ([]byte, error) {
}
}
// buildKubeConfig creates a kubeconfig object from some commonly specified properties in the struct above
// buildKubeConfig creates a kubeconfig object from some commonly specified properties in the struct above
func
buildKubeConfig
(
config
Kube
ConfigProperties
)
(
*
clientcmdapi
.
Config
,
error
)
{
func
buildKubeConfig
(
config
Build
ConfigProperties
)
(
*
clientcmdapi
.
Config
,
error
)
{
// Try to load ca.crt and ca.key from the PKI directory
// Try to load ca.crt and ca.key from the PKI directory
caCert
,
caKey
,
err
:=
pkiutil
.
TryLoadCertAndKeyFromDisk
(
config
.
CertDir
,
kubeadmconstants
.
CACertAndKeyBaseName
)
caCert
,
caKey
,
err
:=
pkiutil
.
TryLoadCertAndKeyFromDisk
(
config
.
CertDir
,
kubeadmconstants
.
CACertAndKeyBaseName
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment