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
0a9164e7
Unverified
Commit
0a9164e7
authored
May 31, 2018
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client-go: promote exec plugin support to beta
parent
8952b8f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
6 deletions
+87
-6
exec.go
.../src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
+14
-6
exec_test.go
...k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go
+73
-0
No files found.
staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
View file @
0a9164e7
...
...
@@ -38,6 +38,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/pkg/apis/clientauthentication"
"k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1"
"k8s.io/client-go/pkg/apis/clientauthentication/v1beta1"
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/transport"
"k8s.io/client-go/util/connrotation"
...
...
@@ -51,6 +52,7 @@ var codecs = serializer.NewCodecFactory(scheme)
func
init
()
{
v1
.
AddToGroupVersion
(
scheme
,
schema
.
GroupVersion
{
Version
:
"v1"
})
v1alpha1
.
AddToScheme
(
scheme
)
v1beta1
.
AddToScheme
(
scheme
)
clientauthentication
.
AddToScheme
(
scheme
)
}
...
...
@@ -61,6 +63,7 @@ var (
// The list of API versions we accept.
apiVersions
=
map
[
string
]
schema
.
GroupVersion
{
v1alpha1
.
SchemeGroupVersion
.
String
()
:
v1alpha1
.
SchemeGroupVersion
,
v1beta1
.
SchemeGroupVersion
.
String
()
:
v1beta1
.
SchemeGroupVersion
,
}
)
...
...
@@ -294,13 +297,18 @@ func (a *Authenticator) refreshCredsLocked(r *clientauthentication.Response) err
},
}
data
,
err
:=
runtime
.
Encode
(
codecs
.
LegacyCodec
(
a
.
group
),
cred
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"encode ExecCredentials: %v"
,
err
)
}
env
:=
append
(
a
.
environ
(),
a
.
env
...
)
env
=
append
(
env
,
fmt
.
Sprintf
(
"%s=%s"
,
execInfoEnv
,
data
))
if
a
.
group
==
v1alpha1
.
SchemeGroupVersion
{
// Input spec disabled for beta due to lack of use. Possibly re-enable this later if
// someone wants it back.
//
// See: https://github.com/kubernetes/kubernetes/issues/61796
data
,
err
:=
runtime
.
Encode
(
codecs
.
LegacyCodec
(
a
.
group
),
cred
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"encode ExecCredentials: %v"
,
err
)
}
env
=
append
(
env
,
fmt
.
Sprintf
(
"%s=%s"
,
execInfoEnv
,
data
))
}
stdout
:=
&
bytes
.
Buffer
{}
cmd
:=
exec
.
Command
(
a
.
cmd
,
a
.
args
...
)
...
...
staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec_test.go
View file @
0a9164e7
...
...
@@ -380,6 +380,72 @@ func TestRefreshCreds(t *testing.T) {
}`
,
certData
),
wantErr
:
true
,
},
{
name
:
"beta-basic-request"
,
config
:
api
.
ExecConfig
{
APIVersion
:
"client.authentication.k8s.io/v1beta1"
,
},
output
:
`{
"kind": "ExecCredential",
"apiVersion": "client.authentication.k8s.io/v1beta1",
"status": {
"token": "foo-bar"
}
}`
,
wantCreds
:
credentials
{
token
:
"foo-bar"
},
},
{
name
:
"beta-expiry"
,
config
:
api
.
ExecConfig
{
APIVersion
:
"client.authentication.k8s.io/v1beta1"
,
},
output
:
`{
"kind": "ExecCredential",
"apiVersion": "client.authentication.k8s.io/v1beta1",
"status": {
"token": "foo-bar",
"expirationTimestamp": "2006-01-02T15:04:05Z"
}
}`
,
wantExpiry
:
time
.
Date
(
2006
,
01
,
02
,
15
,
04
,
05
,
0
,
time
.
UTC
),
wantCreds
:
credentials
{
token
:
"foo-bar"
},
},
{
name
:
"beta-no-group-version"
,
config
:
api
.
ExecConfig
{
APIVersion
:
"client.authentication.k8s.io/v1beta1"
,
},
output
:
`{
"kind": "ExecCredential",
"status": {
"token": "foo-bar"
}
}`
,
wantErr
:
true
,
},
{
name
:
"beta-no-status"
,
config
:
api
.
ExecConfig
{
APIVersion
:
"client.authentication.k8s.io/v1beta1"
,
},
output
:
`{
"kind": "ExecCredential",
"apiVersion":"client.authentication.k8s.io/v1beta1"
}`
,
wantErr
:
true
,
},
{
name
:
"beta-no-token"
,
config
:
api
.
ExecConfig
{
APIVersion
:
"client.authentication.k8s.io/v1beta1"
,
},
output
:
`{
"kind": "ExecCredential",
"apiVersion":"client.authentication.k8s.io/v1beta1",
"status": {}
}`
,
wantErr
:
true
,
},
}
for
_
,
test
:=
range
tests
{
...
...
@@ -420,6 +486,13 @@ func TestRefreshCreds(t *testing.T) {
t
.
Errorf
(
"expected expiry %v got %v"
,
test
.
wantExpiry
,
a
.
exp
)
}
if
test
.
wantInput
==
""
{
if
got
:=
strings
.
TrimSpace
(
stderr
.
String
());
got
!=
""
{
t
.
Errorf
(
"expected no input parameters, got %q"
,
got
)
}
return
}
compJSON
(
t
,
stderr
.
Bytes
(),
[]
byte
(
test
.
wantInput
))
})
}
...
...
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