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
9b29f42f
Commit
9b29f42f
authored
Jul 15, 2017
by
Nick Sardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further removal of Gets from Creates
parent
e1ba93f2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
78 deletions
+34
-78
gce_forwardingrule.go
pkg/cloudprovider/providers/gce/gce_forwardingrule.go
+4
-17
gce_instancegroup.go
pkg/cloudprovider/providers/gce/gce_instancegroup.go
+4
-10
gce_loadbalancer_external.go
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
+1
-1
gce_loadbalancer_internal.go
pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go
+6
-1
gce_targetpool.go
pkg/cloudprovider/providers/gce/gce_targetpool.go
+3
-7
gce_targetproxy.go
pkg/cloudprovider/providers/gce/gce_targetproxy.go
+8
-24
gce_urlmap.go
pkg/cloudprovider/providers/gce/gce_urlmap.go
+8
-18
No files found.
pkg/cloudprovider/providers/gce/gce_forwardingrule.go
View file @
9b29f42f
...
@@ -29,27 +29,14 @@ func newForwardingRuleMetricContext(request, region string) *metricContext {
...
@@ -29,27 +29,14 @@ func newForwardingRuleMetricContext(request, region string) *metricContext {
}
}
}
}
// CreateGlobalForwardingRule creates and returns a
// CreateGlobalForwardingRule creates the passed GlobalForwardingRule
// GlobalForwardingRule that points to the given TargetHttp(s)Proxy.
func
(
gce
*
GCECloud
)
CreateGlobalForwardingRule
(
rule
*
compute
.
ForwardingRule
)
error
{
// targetProxyLink is the SelfLink of a TargetHttp(s)Proxy.
func
(
gce
*
GCECloud
)
CreateGlobalForwardingRule
(
targetProxyLink
,
ip
,
name
,
portRange
string
)
(
*
compute
.
ForwardingRule
,
error
)
{
mc
:=
newForwardingRuleMetricContext
(
"create"
,
""
)
mc
:=
newForwardingRuleMetricContext
(
"create"
,
""
)
rule
:=
&
compute
.
ForwardingRule
{
Name
:
name
,
IPAddress
:
ip
,
Target
:
targetProxyLink
,
PortRange
:
portRange
,
IPProtocol
:
"TCP"
,
}
op
,
err
:=
gce
.
service
.
GlobalForwardingRules
.
Insert
(
gce
.
projectID
,
rule
)
.
Do
()
op
,
err
:=
gce
.
service
.
GlobalForwardingRules
.
Insert
(
gce
.
projectID
,
rule
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
=
gce
.
waitForGlobalOp
(
op
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
waitForGlobalOp
(
op
,
mc
)
return
gce
.
GetGlobalForwardingRule
(
name
)
}
}
// SetProxyForGlobalForwardingRule links the given TargetHttp(s)Proxy with the given GlobalForwardingRule.
// SetProxyForGlobalForwardingRule links the given TargetHttp(s)Proxy with the given GlobalForwardingRule.
...
...
pkg/cloudprovider/providers/gce/gce_instancegroup.go
View file @
9b29f42f
...
@@ -31,20 +31,14 @@ func newInstanceGroupMetricContext(request string, zone string) *metricContext {
...
@@ -31,20 +31,14 @@ func newInstanceGroupMetricContext(request string, zone string) *metricContext {
// CreateInstanceGroup creates an instance group with the given
// CreateInstanceGroup creates an instance group with the given
// instances. It is the callers responsibility to add named ports.
// instances. It is the callers responsibility to add named ports.
func
(
gce
*
GCECloud
)
CreateInstanceGroup
(
name
string
,
zone
string
)
(
*
compute
.
InstanceGroup
,
error
)
{
func
(
gce
*
GCECloud
)
CreateInstanceGroup
(
ig
*
compute
.
InstanceGroup
,
zone
string
)
error
{
mc
:=
newInstanceGroupMetricContext
(
"create"
,
zone
)
mc
:=
newInstanceGroupMetricContext
(
"create"
,
zone
)
op
,
err
:=
gce
.
service
.
InstanceGroups
.
Insert
(
op
,
err
:=
gce
.
service
.
InstanceGroups
.
Insert
(
gce
.
projectID
,
zone
,
ig
)
.
Do
()
gce
.
projectID
,
zone
,
&
compute
.
InstanceGroup
{
Name
:
name
})
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
return
nil
,
err
}
if
err
=
gce
.
waitForZoneOp
(
op
,
zone
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
GetInstanceGroup
(
name
,
zone
)
return
gce
.
waitForZoneOp
(
op
,
zone
,
mc
)
}
}
// DeleteInstanceGroup deletes an instance group.
// DeleteInstanceGroup deletes an instance group.
...
...
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
View file @
9b29f42f
...
@@ -494,7 +494,7 @@ func (gce *GCECloud) createTargetPool(name, serviceName, ipAddress, region, clus
...
@@ -494,7 +494,7 @@ func (gce *GCECloud) createTargetPool(name, serviceName, ipAddress, region, clus
HealthChecks
:
hcLinks
,
HealthChecks
:
hcLinks
,
}
}
if
_
,
err
:=
gce
.
CreateTargetPool
(
pool
,
region
);
err
!=
nil
&&
!
isHTTPErrorCode
(
err
,
http
.
StatusConflict
)
{
if
err
:=
gce
.
CreateTargetPool
(
pool
,
region
);
err
!=
nil
&&
!
isHTTPErrorCode
(
err
,
http
.
StatusConflict
)
{
return
err
return
err
}
}
return
nil
return
nil
...
...
pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go
View file @
9b29f42f
...
@@ -376,7 +376,12 @@ func (gce *GCECloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.
...
@@ -376,7 +376,12 @@ func (gce *GCECloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.
gceNodes
:=
sets
.
NewString
()
gceNodes
:=
sets
.
NewString
()
if
ig
==
nil
{
if
ig
==
nil
{
glog
.
V
(
2
)
.
Infof
(
"ensureInternalInstanceGroup(%v, %v): creating instance group"
,
name
,
zone
)
glog
.
V
(
2
)
.
Infof
(
"ensureInternalInstanceGroup(%v, %v): creating instance group"
,
name
,
zone
)
ig
,
err
=
gce
.
CreateInstanceGroup
(
name
,
zone
)
newIG
:=
&
compute
.
InstanceGroup
{
Name
:
name
}
if
err
=
gce
.
CreateInstanceGroup
(
newIG
,
zone
);
err
!=
nil
{
return
""
,
err
}
ig
,
err
=
gce
.
GetInstanceGroup
(
name
,
zone
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
...
pkg/cloudprovider/providers/gce/gce_targetpool.go
View file @
9b29f42f
...
@@ -37,18 +37,14 @@ func (gce *GCECloud) GetTargetPool(name, region string) (*compute.TargetPool, er
...
@@ -37,18 +37,14 @@ func (gce *GCECloud) GetTargetPool(name, region string) (*compute.TargetPool, er
}
}
// CreateTargetPool creates the passed TargetPool
// CreateTargetPool creates the passed TargetPool
func
(
gce
*
GCECloud
)
CreateTargetPool
(
tp
*
compute
.
TargetPool
,
region
string
)
(
*
compute
.
TargetPool
,
error
)
{
func
(
gce
*
GCECloud
)
CreateTargetPool
(
tp
*
compute
.
TargetPool
,
region
string
)
error
{
mc
:=
newTargetPoolMetricContext
(
"create"
,
region
)
mc
:=
newTargetPoolMetricContext
(
"create"
,
region
)
op
,
err
:=
gce
.
service
.
TargetPools
.
Insert
(
gce
.
projectID
,
region
,
tp
)
.
Do
()
op
,
err
:=
gce
.
service
.
TargetPools
.
Insert
(
gce
.
projectID
,
region
,
tp
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
:=
gce
.
waitForRegionOp
(
op
,
region
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
GetTargetPool
(
tp
.
Name
,
region
)
return
gce
.
waitForRegionOp
(
op
,
region
,
mc
)
}
}
// DeleteTargetPool deletes TargetPool by name.
// DeleteTargetPool deletes TargetPool by name.
...
...
pkg/cloudprovider/providers/gce/gce_targetproxy.go
View file @
9b29f42f
...
@@ -37,22 +37,14 @@ func (gce *GCECloud) GetTargetHttpProxy(name string) (*compute.TargetHttpProxy,
...
@@ -37,22 +37,14 @@ func (gce *GCECloud) GetTargetHttpProxy(name string) (*compute.TargetHttpProxy,
return
v
,
mc
.
Observe
(
err
)
return
v
,
mc
.
Observe
(
err
)
}
}
// CreateTargetHttpProxy creates and returns a TargetHttpProxy with the given UrlMap.
// CreateTargetHttpProxy creates a TargetHttpProxy
func
(
gce
*
GCECloud
)
CreateTargetHttpProxy
(
urlMap
*
compute
.
UrlMap
,
name
string
)
(
*
compute
.
TargetHttpProxy
,
error
)
{
func
(
gce
*
GCECloud
)
CreateTargetHttpProxy
(
proxy
*
compute
.
TargetHttpProxy
)
error
{
proxy
:=
&
compute
.
TargetHttpProxy
{
Name
:
name
,
UrlMap
:
urlMap
.
SelfLink
,
}
mc
:=
newTargetProxyMetricContext
(
"create"
)
mc
:=
newTargetProxyMetricContext
(
"create"
)
op
,
err
:=
gce
.
service
.
TargetHttpProxies
.
Insert
(
gce
.
projectID
,
proxy
)
.
Do
()
op
,
err
:=
gce
.
service
.
TargetHttpProxies
.
Insert
(
gce
.
projectID
,
proxy
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
=
gce
.
waitForGlobalOp
(
op
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
GetTargetHttpProxy
(
name
)
return
gce
.
waitForGlobalOp
(
op
,
mc
)
}
}
// SetUrlMapForTargetHttpProxy sets the given UrlMap for the given TargetHttpProxy.
// SetUrlMapForTargetHttpProxy sets the given UrlMap for the given TargetHttpProxy.
...
@@ -96,22 +88,14 @@ func (gce *GCECloud) GetTargetHttpsProxy(name string) (*compute.TargetHttpsProxy
...
@@ -96,22 +88,14 @@ func (gce *GCECloud) GetTargetHttpsProxy(name string) (*compute.TargetHttpsProxy
return
v
,
mc
.
Observe
(
err
)
return
v
,
mc
.
Observe
(
err
)
}
}
// CreateTargetHttpsProxy creates a
nd returns a TargetHttpsProxy with the given UrlMap and SslCertificate.
// CreateTargetHttpsProxy creates a
TargetHttpsProxy
func
(
gce
*
GCECloud
)
CreateTargetHttpsProxy
(
urlMap
*
compute
.
UrlMap
,
sslCert
*
compute
.
SslCertificate
,
name
string
)
(
*
compute
.
TargetHttpsProxy
,
error
)
{
func
(
gce
*
GCECloud
)
CreateTargetHttpsProxy
(
proxy
*
compute
.
TargetHttpsProxy
)
error
{
mc
:=
newTargetProxyMetricContext
(
"create"
)
mc
:=
newTargetProxyMetricContext
(
"create"
)
proxy
:=
&
compute
.
TargetHttpsProxy
{
Name
:
name
,
UrlMap
:
urlMap
.
SelfLink
,
SslCertificates
:
[]
string
{
sslCert
.
SelfLink
},
}
op
,
err
:=
gce
.
service
.
TargetHttpsProxies
.
Insert
(
gce
.
projectID
,
proxy
)
.
Do
()
op
,
err
:=
gce
.
service
.
TargetHttpsProxies
.
Insert
(
gce
.
projectID
,
proxy
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
=
gce
.
waitForGlobalOp
(
op
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
GetTargetHttpsProxy
(
name
)
return
gce
.
waitForGlobalOp
(
op
,
mc
)
}
}
// SetUrlMapForTargetHttpsProxy sets the given UrlMap for the given TargetHttpsProxy.
// SetUrlMapForTargetHttpsProxy sets the given UrlMap for the given TargetHttpsProxy.
...
...
pkg/cloudprovider/providers/gce/gce_urlmap.go
View file @
9b29f42f
...
@@ -37,34 +37,24 @@ func (gce *GCECloud) GetUrlMap(name string) (*compute.UrlMap, error) {
...
@@ -37,34 +37,24 @@ func (gce *GCECloud) GetUrlMap(name string) (*compute.UrlMap, error) {
return
v
,
mc
.
Observe
(
err
)
return
v
,
mc
.
Observe
(
err
)
}
}
// CreateUrlMap creates an url map, using the given backend service as the default service.
// CreateUrlMap creates a url map
func
(
gce
*
GCECloud
)
CreateUrlMap
(
backend
*
compute
.
BackendService
,
name
string
)
(
*
compute
.
UrlMap
,
error
)
{
func
(
gce
*
GCECloud
)
CreateUrlMap
(
urlMap
*
compute
.
UrlMap
)
error
{
urlMap
:=
&
compute
.
UrlMap
{
Name
:
name
,
DefaultService
:
backend
.
SelfLink
,
}
mc
:=
newUrlMapMetricContext
(
"create"
)
mc
:=
newUrlMapMetricContext
(
"create"
)
op
,
err
:=
gce
.
service
.
UrlMaps
.
Insert
(
gce
.
projectID
,
urlMap
)
.
Do
()
op
,
err
:=
gce
.
service
.
UrlMaps
.
Insert
(
gce
.
projectID
,
urlMap
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
=
gce
.
waitForGlobalOp
(
op
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
GetUrlMap
(
name
)
return
gce
.
waitForGlobalOp
(
op
,
mc
)
}
}
// UpdateUrlMap applies the given UrlMap as an update
, and returns the new UrlMap.
// UpdateUrlMap applies the given UrlMap as an update
func
(
gce
*
GCECloud
)
UpdateUrlMap
(
urlMap
*
compute
.
UrlMap
)
(
*
compute
.
UrlMap
,
error
)
{
func
(
gce
*
GCECloud
)
UpdateUrlMap
(
urlMap
*
compute
.
UrlMap
)
error
{
mc
:=
newUrlMapMetricContext
(
"update"
)
mc
:=
newUrlMapMetricContext
(
"update"
)
op
,
err
:=
gce
.
service
.
UrlMaps
.
Update
(
gce
.
projectID
,
urlMap
.
Name
,
urlMap
)
.
Do
()
op
,
err
:=
gce
.
service
.
UrlMaps
.
Update
(
gce
.
projectID
,
urlMap
.
Name
,
urlMap
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
return
mc
.
Observe
(
err
)
}
if
err
=
gce
.
waitForGlobalOp
(
op
,
mc
);
err
!=
nil
{
return
nil
,
err
}
}
return
gce
.
service
.
UrlMaps
.
Get
(
gce
.
projectID
,
urlMap
.
Name
)
.
Do
(
)
return
gce
.
waitForGlobalOp
(
op
,
mc
)
}
}
// DeleteUrlMap deletes a url map by name.
// DeleteUrlMap deletes a url map by name.
...
...
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