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
2aaf8b47
Commit
2aaf8b47
authored
Jan 05, 2018
by
Bowei Du
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up documentation.
parent
9a708855
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
3 deletions
+120
-3
doc.go
pkg/cloudprovider/providers/gce/cloud/doc.go
+1
-0
gce_projects.go
pkg/cloudprovider/providers/gce/cloud/gce_projects.go
+5
-1
gen.go
pkg/cloudprovider/providers/gce/cloud/gen.go
+95
-0
main.go
pkg/cloudprovider/providers/gce/cloud/gen/main.go
+3
-1
method.go
pkg/cloudprovider/providers/gce/cloud/meta/method.go
+10
-1
service.go
pkg/cloudprovider/providers/gce/cloud/meta/service.go
+4
-0
project.go
pkg/cloudprovider/providers/gce/cloud/project.go
+1
-0
ratelimit.go
pkg/cloudprovider/providers/gce/cloud/ratelimit.go
+1
-0
No files found.
pkg/cloudprovider/providers/gce/cloud/doc.go
View file @
2aaf8b47
...
...
@@ -60,6 +60,7 @@ limitations under the License.
// &ServiceInfo{
// Object: "InstanceGroup", // Name of the object type.
// Service: "InstanceGroups", // Name of the service.
// Resource: "instanceGroups", // Lowercase resource name (as appears in the URL).
// version: meta.VersionAlpha, // API version (one entry per version is needed).
// keyType: Zonal, // What kind of resource this is.
// serviceType: reflect.TypeOf(&alpha.InstanceGroupsService{}), // Associated golang type.
...
...
pkg/cloudprovider/providers/gce/cloud/gce_projects.go
View file @
2aaf8b47
...
...
@@ -21,9 +21,9 @@ import (
"fmt"
"net/http"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
compute
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
)
// ProjectsOps is the manually implemented methods for the Projects service.
...
...
@@ -37,6 +37,7 @@ type MockProjectOpsState struct {
metadata
map
[
string
]
*
compute
.
Metadata
}
// Get a project by projectID.
func
(
m
*
MockProjects
)
Get
(
ctx
context
.
Context
,
projectID
string
)
(
*
compute
.
Project
,
error
)
{
m
.
Lock
.
Lock
()
defer
m
.
Lock
.
Unlock
()
...
...
@@ -50,6 +51,7 @@ func (m *MockProjects) Get(ctx context.Context, projectID string) (*compute.Proj
}
}
// Get a project by projectID.
func
(
g
*
GCEProjects
)
Get
(
ctx
context
.
Context
,
projectID
string
)
(
*
compute
.
Project
,
error
)
{
rk
:=
&
RateLimitKey
{
ProjectID
:
projectID
,
...
...
@@ -65,6 +67,7 @@ func (g *GCEProjects) Get(ctx context.Context, projectID string) (*compute.Proje
return
call
.
Do
()
}
// SetCommonInstanceMetadata for a given project.
func
(
m
*
MockProjects
)
SetCommonInstanceMetadata
(
ctx
context
.
Context
,
projectID
string
,
meta
*
compute
.
Metadata
)
error
{
if
m
.
X
==
nil
{
m
.
X
=
&
MockProjectOpsState
{
metadata
:
map
[
string
]
*
compute
.
Metadata
{}}
...
...
@@ -74,6 +77,7 @@ func (m *MockProjects) SetCommonInstanceMetadata(ctx context.Context, projectID
return
nil
}
// SetCommonInstanceMetadata for a given project.
func
(
g
*
GCEProjects
)
SetCommonInstanceMetadata
(
ctx
context
.
Context
,
projectID
string
,
m
*
compute
.
Metadata
)
error
{
rk
:=
&
RateLimitKey
{
ProjectID
:
projectID
,
...
...
pkg/cloudprovider/providers/gce/cloud/gen.go
View file @
2aaf8b47
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/gce/cloud/gen/main.go
View file @
2aaf8b47
...
...
@@ -30,8 +30,8 @@ import (
"text/template"
"time"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
)
const
(
...
...
@@ -167,6 +167,7 @@ type GCE struct {
}
{{range .All}}
// {{.WrapType}} returns the interface for the {{.Version}} {{.Service}}.
func (gce *GCE) {{.WrapType}}() {{.WrapType}} {
return gce.{{.Field}}
}
...
...
@@ -196,6 +197,7 @@ type MockGCE struct {
{{- end}}
}
{{range .All}}
// {{.WrapType}} returns the interface for the {{.Version}} {{.Service}}.
func (mock *MockGCE) {{.WrapType}}() {{.WrapType}} {
return mock.{{.MockField}}
}
...
...
pkg/cloudprovider/providers/gce/cloud/meta/method.go
View file @
2aaf8b47
...
...
@@ -91,7 +91,7 @@ func newMethod(s *ServiceInfo, m reflect.Method) *Method {
return
ret
}
// Method is used to generate the calling code non-standard methods.
// Method is used to generate the calling code
for
non-standard methods.
type
Method
struct
{
*
ServiceInfo
m
reflect
.
Method
...
...
@@ -135,6 +135,7 @@ func (mr *Method) args(skip int, nameArgs bool, prefix []string) []string {
return
append
(
prefix
,
a
...
)
}
// init the method, preforming some rudimentary static checking.
func
(
mr
*
Method
)
init
()
{
fType
:=
mr
.
m
.
Func
.
Type
()
if
fType
.
NumIn
()
<
mr
.
argsSkip
()
{
...
...
@@ -189,10 +190,14 @@ func (mr *Method) init() {
}
}
// Name is the name of the method.
func
(
mr
*
Method
)
Name
()
string
{
return
mr
.
m
.
Name
}
// CallArgs is a list of comma separated "argN" used for calling the method.
// For example, if the method has two additional arguments, this will return
// "arg0, arg1".
func
(
mr
*
Method
)
CallArgs
()
string
{
var
args
[]
string
for
i
:=
mr
.
argsSkip
();
i
<
mr
.
m
.
Func
.
Type
()
.
NumIn
();
i
++
{
...
...
@@ -204,10 +209,12 @@ func (mr *Method) CallArgs() string {
return
fmt
.
Sprintf
(
", %s"
,
strings
.
Join
(
args
,
", "
))
}
// MockHookName is the name of the hook function in the mock.
func
(
mr
*
Method
)
MockHookName
()
string
{
return
mr
.
m
.
Name
+
"Hook"
}
// MockHook is the definition of the hook function.
func
(
mr
*
Method
)
MockHook
()
string
{
args
:=
mr
.
args
(
mr
.
argsSkip
(),
false
,
[]
string
{
fmt
.
Sprintf
(
"*%s"
,
mr
.
MockWrapType
()),
...
...
@@ -220,6 +227,7 @@ func (mr *Method) MockHook() string {
return
fmt
.
Sprintf
(
"%v func(%v) (*%v.%v, error)"
,
mr
.
MockHookName
(),
strings
.
Join
(
args
,
", "
),
mr
.
Version
(),
mr
.
ReturnType
)
}
// FcnArgs is the function signature for the definition of the method.
func
(
mr
*
Method
)
FcnArgs
()
string
{
args
:=
mr
.
args
(
mr
.
argsSkip
(),
true
,
[]
string
{
"ctx context.Context"
,
...
...
@@ -232,6 +240,7 @@ func (mr *Method) FcnArgs() string {
return
fmt
.
Sprintf
(
"%v(%v) (*%v.%v, error)"
,
mr
.
m
.
Name
,
strings
.
Join
(
args
,
", "
),
mr
.
Version
(),
mr
.
ReturnType
)
}
// InterfaceFunc is the function declaration of the method in the interface.
func
(
mr
*
Method
)
InterfaceFunc
()
string
{
args
:=
mr
.
args
(
mr
.
argsSkip
(),
false
,
[]
string
{
"context.Context"
,
"meta.Key"
})
if
mr
.
ReturnType
==
"Operation"
{
...
...
pkg/cloudprovider/providers/gce/cloud/meta/service.go
View file @
2aaf8b47
...
...
@@ -220,6 +220,7 @@ type ServiceGroup struct {
GA
*
ServiceInfo
}
// Service returns any ServiceInfo object belonging to the ServiceGroup.
func
(
sg
*
ServiceGroup
)
Service
()
string
{
switch
{
case
sg
.
GA
!=
nil
:
...
...
@@ -233,14 +234,17 @@ func (sg *ServiceGroup) Service() string {
}
}
// HasGA returns true if this object has a GA representation.
func
(
sg
*
ServiceGroup
)
HasGA
()
bool
{
return
sg
.
GA
!=
nil
}
// HasAlpha returns true if this object has a Alpha representation.
func
(
sg
*
ServiceGroup
)
HasAlpha
()
bool
{
return
sg
.
Alpha
!=
nil
}
// HasBeta returns true if this object has a Beta representation.
func
(
sg
*
ServiceGroup
)
HasBeta
()
bool
{
return
sg
.
Beta
!=
nil
}
...
...
pkg/cloudprovider/providers/gce/cloud/project.go
View file @
2aaf8b47
...
...
@@ -39,6 +39,7 @@ type SingleProjectRouter struct {
ID
string
}
// ProjectID returns the project ID to be used for a call to the API.
func
(
r
*
SingleProjectRouter
)
ProjectID
(
ctx
context
.
Context
,
version
meta
.
Version
,
service
string
)
string
{
return
r
.
ID
}
pkg/cloudprovider/providers/gce/cloud/ratelimit.go
View file @
2aaf8b47
...
...
@@ -51,6 +51,7 @@ type RateLimiter interface {
type
NopRateLimiter
struct
{
}
// Accept the operation to be rate limited.
func
(
*
NopRateLimiter
)
Accept
(
ctx
context
.
Context
,
key
*
RateLimitKey
)
error
{
// Rate limit polling of the Operation status to avoid hammering GCE
// for the status of an operation.
...
...
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