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
d3398e2a
Commit
d3398e2a
authored
Aug 28, 2015
by
Isaac Hollander McCreery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GCE tokens behavior to new format
parent
e8cda9dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
configure-vm.sh
cluster/gce/configure-vm.sh
+2
-1
gce.go
pkg/cloudprovider/providers/gce/gce.go
+2
-1
token_source.go
pkg/cloudprovider/providers/gce/token_source.go
+8
-5
No files found.
cluster/gce/configure-vm.sh
View file @
d3398e2a
...
...
@@ -540,10 +540,11 @@ grains:
- kubernetes-master
cloud: gce
EOF
if
!
[[
-z
"
${
PROJECT_ID
:-}
"
]]
&&
!
[[
-z
"
${
TOKEN_URL
:-}
"
]]
&&
!
[[
-z
"
${
NODE_NETWORK
:-}
"
]]
;
then
if
!
[[
-z
"
${
PROJECT_ID
:-}
"
]]
&&
!
[[
-z
"
${
TOKEN_URL
:-}
"
]]
&&
!
[[
-z
"
${
TOKEN_BODY
:-}
"
]]
&&
!
[[
-z
"
${
NODE_NETWORK
:-}
"
]]
;
then
cat
<<
EOF
>/etc/gce.conf
[global]
token-url =
${
TOKEN_URL
}
token-body =
${
TOKEN_BODY
}
project-id =
${
PROJECT_ID
}
network-name =
${
NODE_NETWORK
}
EOF
...
...
pkg/cloudprovider/providers/gce/gce.go
View file @
d3398e2a
...
...
@@ -61,6 +61,7 @@ type GCECloud struct {
type
Config
struct
{
Global
struct
{
TokenURL
string
`gcfg:"token-url"`
TokenBody
string
`gcfg:"token-body"`
ProjectID
string
`gcfg:"project-id"`
NetworkName
string
`gcfg:"network-name"`
}
...
...
@@ -159,7 +160,7 @@ func newGCECloud(config io.Reader) (*GCECloud, error) {
}
}
if
cfg
.
Global
.
TokenURL
!=
""
{
tokenSource
=
newAltTokenSource
(
cfg
.
Global
.
TokenURL
)
tokenSource
=
newAltTokenSource
(
cfg
.
Global
.
TokenURL
,
cfg
.
Global
.
TokenBody
)
}
}
client
:=
oauth2
.
NewClient
(
oauth2
.
NoContext
,
tokenSource
)
...
...
pkg/cloudprovider/providers/gce/token_source.go
View file @
d3398e2a
...
...
@@ -19,6 +19,7 @@ package gce_cloud
import
(
"encoding/json"
"net/http"
"strings"
"time"
"k8s.io/kubernetes/pkg/util"
...
...
@@ -59,6 +60,7 @@ func init() {
type
altTokenSource
struct
{
oauthClient
*
http
.
Client
tokenURL
string
tokenBody
string
throttle
util
.
RateLimiter
}
...
...
@@ -73,7 +75,7 @@ func (a *altTokenSource) Token() (*oauth2.Token, error) {
}
func
(
a
*
altTokenSource
)
token
()
(
*
oauth2
.
Token
,
error
)
{
req
,
err
:=
http
.
NewRequest
(
"
GET"
,
a
.
tokenURL
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"
POST"
,
a
.
tokenURL
,
strings
.
NewReader
(
a
.
tokenBody
)
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -86,23 +88,24 @@ func (a *altTokenSource) token() (*oauth2.Token, error) {
return
nil
,
err
}
var
tok
struct
{
AccessToken
string
`json:"accessToken"`
Expir
yTimeSeconds
int64
`json:"expiryTimeSeconds,string
"`
AccessToken
string
`json:"accessToken"`
Expir
eTime
time
.
Time
`json:"expireTime
"`
}
if
err
:=
json
.
NewDecoder
(
res
.
Body
)
.
Decode
(
&
tok
);
err
!=
nil
{
return
nil
,
err
}
return
&
oauth2
.
Token
{
AccessToken
:
tok
.
AccessToken
,
Expiry
:
t
ime
.
Unix
(
tok
.
ExpiryTimeSeconds
,
0
)
,
Expiry
:
t
ok
.
ExpireTime
,
},
nil
}
func
newAltTokenSource
(
tokenURL
string
)
oauth2
.
TokenSource
{
func
newAltTokenSource
(
tokenURL
,
tokenBody
string
)
oauth2
.
TokenSource
{
client
:=
oauth2
.
NewClient
(
oauth2
.
NoContext
,
google
.
ComputeTokenSource
(
""
))
a
:=
&
altTokenSource
{
oauthClient
:
client
,
tokenURL
:
tokenURL
,
tokenBody
:
tokenBody
,
throttle
:
util
.
NewTokenBucketRateLimiter
(
tokenURLQPS
,
tokenURLBurst
),
}
return
oauth2
.
ReuseTokenSource
(
nil
,
a
)
...
...
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