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
aaa3dfd6
Commit
aaa3dfd6
authored
Jan 19, 2018
by
Bowei Du
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GCE: Check that the key is valid for each call
parent
a2b222c9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
gen.go
pkg/cloudprovider/providers/gce/cloud/gen.go
+0
-0
main.go
pkg/cloudprovider/providers/gce/cloud/gen/main.go
+27
-0
No files found.
pkg/cloudprovider/providers/gce/cloud/gen.go
View file @
aaa3dfd6
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/gce/cloud/gen/main.go
View file @
aaa3dfd6
...
@@ -395,6 +395,9 @@ func (m *{{.MockWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjec
...
@@ -395,6 +395,9 @@ func (m *{{.MockWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjec
return obj, err
return obj, err
}
}
}
}
if ! key.Valid() {
return nil, fmt.Errorf("invalid GCE key (%+v)", key)
}
m.Lock.Lock()
m.Lock.Lock()
defer m.Lock.Unlock()
defer m.Lock.Unlock()
...
@@ -510,6 +513,9 @@ func (m *{{.MockWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.F
...
@@ -510,6 +513,9 @@ func (m *{{.MockWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.F
return err
return err
}
}
}
}
if ! key.Valid() {
return fmt.Errorf("invalid GCE key (%+v)", key)
}
m.Lock.Lock()
m.Lock.Lock()
defer m.Lock.Unlock()
defer m.Lock.Unlock()
...
@@ -547,6 +553,9 @@ func (m *{{.MockWrapType}}) Delete(ctx context.Context, key *meta.Key) error {
...
@@ -547,6 +553,9 @@ func (m *{{.MockWrapType}}) Delete(ctx context.Context, key *meta.Key) error {
return err
return err
}
}
}
}
if ! key.Valid() {
return fmt.Errorf("invalid GCE key (%+v)", key)
}
m.Lock.Lock()
m.Lock.Lock()
defer m.Lock.Unlock()
defer m.Lock.Unlock()
...
@@ -648,6 +657,9 @@ type {{.GCEWrapType}} struct {
...
@@ -648,6 +657,9 @@ type {{.GCEWrapType}} struct {
{{- if .GenerateGet}}
{{- if .GenerateGet}}
// Get the {{.Object}} named by key.
// Get the {{.Object}} named by key.
func (g *{{.GCEWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjectType}}, error) {
func (g *{{.GCEWrapType}}) Get(ctx context.Context, key *meta.Key) (*{{.FQObjectType}}, error) {
if ! key.Valid() {
return nil, fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
rk := &RateLimitKey{
rk := &RateLimitKey{
ProjectID: projectID,
ProjectID: projectID,
...
@@ -720,6 +732,9 @@ rk := &RateLimitKey{
...
@@ -720,6 +732,9 @@ rk := &RateLimitKey{
{{- if .GenerateInsert}}
{{- if .GenerateInsert}}
// Insert {{.Object}} with key of value obj.
// Insert {{.Object}} with key of value obj.
func (g *{{.GCEWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}) error {
func (g *{{.GCEWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQObjectType}}) error {
if ! key.Valid() {
return fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
rk := &RateLimitKey{
rk := &RateLimitKey{
ProjectID: projectID,
ProjectID: projectID,
...
@@ -753,6 +768,9 @@ func (g *{{.GCEWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQ
...
@@ -753,6 +768,9 @@ func (g *{{.GCEWrapType}}) Insert(ctx context.Context, key *meta.Key, obj *{{.FQ
{{- if .GenerateDelete}}
{{- if .GenerateDelete}}
// Delete the {{.Object}} referenced by key.
// Delete the {{.Object}} referenced by key.
func (g *{{.GCEWrapType}}) Delete(ctx context.Context, key *meta.Key) error {
func (g *{{.GCEWrapType}}) Delete(ctx context.Context, key *meta.Key) error {
if ! key.Valid() {
return fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
rk := &RateLimitKey{
rk := &RateLimitKey{
ProjectID: projectID,
ProjectID: projectID,
...
@@ -820,6 +838,15 @@ func (g *{{.GCEWrapType}}) AggregatedList(ctx context.Context, fl *filter.F) (ma
...
@@ -820,6 +838,15 @@ func (g *{{.GCEWrapType}}) AggregatedList(ctx context.Context, fl *filter.F) (ma
{{- range .}}
{{- range .}}
// {{.Name}} is a method on {{.GCEWrapType}}.
// {{.Name}} is a method on {{.GCEWrapType}}.
func (g *{{.GCEWrapType}}) {{.FcnArgs}} {
func (g *{{.GCEWrapType}}) {{.FcnArgs}} {
if ! key.Valid() {
{{- if .IsOperation}}
return fmt.Errorf("invalid GCE key (%+v)", key)
{{- else if .IsGet}}
return nil, fmt.Errorf("invalid GCE key (%+v)", key)
{{- else if .IsPaged}}
return nil, fmt.Errorf("invalid GCE key (%+v)", key)
{{- end}}
}
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
projectID := g.s.ProjectRouter.ProjectID(ctx, "{{.Version}}", "{{.Service}}")
rk := &RateLimitKey{
rk := &RateLimitKey{
ProjectID: projectID,
ProjectID: projectID,
...
...
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