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
d5e5caba
Commit
d5e5caba
authored
Oct 31, 2017
by
zhengjiajin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dependency from service generator
parent
d118e443
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
service.go
pkg/kubectl/service.go
+14
-14
service_test.go
pkg/kubectl/service_test.go
+0
-0
No files found.
pkg/kubectl/service.go
View file @
d5e5caba
...
@@ -21,10 +21,10 @@ import (
...
@@ -21,10 +21,10 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api"
)
)
// The only difference between ServiceGeneratorV1 and V2 is that the service port is named "default" in V1, while it is left unnamed in V2.
// The only difference between ServiceGeneratorV1 and V2 is that the service port is named "default" in V1, while it is left unnamed in V2.
...
@@ -113,7 +113,7 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
...
@@ -113,7 +113,7 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
isHeadlessService
:=
params
[
"cluster-ip"
]
==
"None"
isHeadlessService
:=
params
[
"cluster-ip"
]
==
"None"
ports
:=
[]
api
.
ServicePort
{}
ports
:=
[]
v1
.
ServicePort
{}
servicePortName
,
found
:=
params
[
"port-name"
]
servicePortName
,
found
:=
params
[
"port-name"
]
if
!
found
{
if
!
found
{
// Leave the port unnamed.
// Leave the port unnamed.
...
@@ -168,20 +168,20 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
...
@@ -168,20 +168,20 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
protocol
=
exposeProtocol
protocol
=
exposeProtocol
}
}
}
}
ports
=
append
(
ports
,
api
.
ServicePort
{
ports
=
append
(
ports
,
v1
.
ServicePort
{
Name
:
name
,
Name
:
name
,
Port
:
int32
(
port
),
Port
:
int32
(
port
),
Protocol
:
api
.
Protocol
(
protocol
),
Protocol
:
v1
.
Protocol
(
protocol
),
})
})
}
}
}
}
service
:=
api
.
Service
{
service
:=
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
Name
:
name
,
Labels
:
labels
,
Labels
:
labels
,
},
},
Spec
:
api
.
ServiceSpec
{
Spec
:
v1
.
ServiceSpec
{
Selector
:
selector
,
Selector
:
selector
,
Ports
:
ports
,
Ports
:
ports
,
},
},
...
@@ -213,24 +213,24 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
...
@@ -213,24 +213,24 @@ func generate(genericParams map[string]interface{}) (runtime.Object, error) {
service
.
Spec
.
ExternalIPs
=
[]
string
{
params
[
"external-ip"
]}
service
.
Spec
.
ExternalIPs
=
[]
string
{
params
[
"external-ip"
]}
}
}
if
len
(
params
[
"type"
])
!=
0
{
if
len
(
params
[
"type"
])
!=
0
{
service
.
Spec
.
Type
=
api
.
ServiceType
(
params
[
"type"
])
service
.
Spec
.
Type
=
v1
.
ServiceType
(
params
[
"type"
])
}
}
if
service
.
Spec
.
Type
==
api
.
ServiceTypeLoadBalancer
{
if
service
.
Spec
.
Type
==
v1
.
ServiceTypeLoadBalancer
{
service
.
Spec
.
LoadBalancerIP
=
params
[
"load-balancer-ip"
]
service
.
Spec
.
LoadBalancerIP
=
params
[
"load-balancer-ip"
]
}
}
if
len
(
params
[
"session-affinity"
])
!=
0
{
if
len
(
params
[
"session-affinity"
])
!=
0
{
switch
api
.
ServiceAffinity
(
params
[
"session-affinity"
])
{
switch
v1
.
ServiceAffinity
(
params
[
"session-affinity"
])
{
case
api
.
ServiceAffinityNone
:
case
v1
.
ServiceAffinityNone
:
service
.
Spec
.
SessionAffinity
=
api
.
ServiceAffinityNone
service
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityNone
case
api
.
ServiceAffinityClientIP
:
case
v1
.
ServiceAffinityClientIP
:
service
.
Spec
.
SessionAffinity
=
api
.
ServiceAffinityClientIP
service
.
Spec
.
SessionAffinity
=
v1
.
ServiceAffinityClientIP
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"unknown session affinity: %s"
,
params
[
"session-affinity"
])
return
nil
,
fmt
.
Errorf
(
"unknown session affinity: %s"
,
params
[
"session-affinity"
])
}
}
}
}
if
len
(
params
[
"cluster-ip"
])
!=
0
{
if
len
(
params
[
"cluster-ip"
])
!=
0
{
if
params
[
"cluster-ip"
]
==
"None"
{
if
params
[
"cluster-ip"
]
==
"None"
{
service
.
Spec
.
ClusterIP
=
api
.
ClusterIPNone
service
.
Spec
.
ClusterIP
=
v1
.
ClusterIPNone
}
else
{
}
else
{
service
.
Spec
.
ClusterIP
=
params
[
"cluster-ip"
]
service
.
Spec
.
ClusterIP
=
params
[
"cluster-ip"
]
}
}
...
...
pkg/kubectl/service_test.go
View file @
d5e5caba
This diff is collapsed.
Click to expand it.
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