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
0f65df66
Commit
0f65df66
authored
Mar 22, 2017
by
Avesh Agarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto generated stuff.
parent
eccbd992
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
helpers.go
staging/src/k8s.io/client-go/pkg/api/helpers.go
+55
-0
No files found.
staging/src/k8s.io/client-go/pkg/api/helpers.go
View file @
0f65df66
...
@@ -18,6 +18,7 @@ package api
...
@@ -18,6 +18,7 @@ package api
import
(
import
(
"crypto/md5"
"crypto/md5"
"encoding/json"
"fmt"
"fmt"
"reflect"
"reflect"
"strings"
"strings"
...
@@ -429,6 +430,14 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
...
@@ -429,6 +430,14 @@ func NodeSelectorRequirementsAsSelector(nsm []NodeSelectorRequirement) (labels.S
}
}
const
(
const
(
// TolerationsAnnotationKey represents the key of tolerations data (json serialized)
// in the Annotations of a Pod.
TolerationsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/tolerations"
// TaintsAnnotationKey represents the key of taints data (json serialized)
// in the Annotations of a Node.
TaintsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/taints"
// SeccompPodAnnotationKey represents the key of a seccomp profile applied
// SeccompPodAnnotationKey represents the key of a seccomp profile applied
// to all containers of a pod.
// to all containers of a pod.
SeccompPodAnnotationKey
string
=
"seccomp.security.alpha.kubernetes.io/pod"
SeccompPodAnnotationKey
string
=
"seccomp.security.alpha.kubernetes.io/pod"
...
@@ -463,8 +472,26 @@ const (
...
@@ -463,8 +472,26 @@ const (
// an object (e.g. secret, config map) before fetching it again from apiserver.
// an object (e.g. secret, config map) before fetching it again from apiserver.
// This annotation can be attached to node.
// This annotation can be attached to node.
ObjectTTLAnnotationKey
string
=
"node.alpha.kubernetes.io/ttl"
ObjectTTLAnnotationKey
string
=
"node.alpha.kubernetes.io/ttl"
// AffinityAnnotationKey represents the key of affinity data (json serialized)
// in the Annotations of a Pod.
// TODO: remove when alpha support for affinity is removed
AffinityAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/affinity"
)
)
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// and converts it to the []Toleration type in api.
func
GetTolerationsFromPodAnnotations
(
annotations
map
[
string
]
string
)
([]
Toleration
,
error
)
{
var
tolerations
[]
Toleration
if
len
(
annotations
)
>
0
&&
annotations
[
TolerationsAnnotationKey
]
!=
""
{
err
:=
json
.
Unmarshal
([]
byte
(
annotations
[
TolerationsAnnotationKey
]),
&
tolerations
)
if
err
!=
nil
{
return
tolerations
,
err
}
}
return
tolerations
,
nil
}
// AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list.
// AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list.
// Returns true if something was updated, false otherwise.
// Returns true if something was updated, false otherwise.
func
AddOrUpdateTolerationInPod
(
pod
*
Pod
,
toleration
*
Toleration
)
(
bool
,
error
)
{
func
AddOrUpdateTolerationInPod
(
pod
*
Pod
,
toleration
*
Toleration
)
(
bool
,
error
)
{
...
@@ -548,6 +575,19 @@ func (t *Taint) ToString() string {
...
@@ -548,6 +575,19 @@ func (t *Taint) ToString() string {
return
fmt
.
Sprintf
(
"%v=%v:%v"
,
t
.
Key
,
t
.
Value
,
t
.
Effect
)
return
fmt
.
Sprintf
(
"%v=%v:%v"
,
t
.
Key
,
t
.
Value
,
t
.
Effect
)
}
}
// GetTaintsFromNodeAnnotations gets the json serialized taints data from Pod.Annotations
// and converts it to the []Taint type in api.
func
GetTaintsFromNodeAnnotations
(
annotations
map
[
string
]
string
)
([]
Taint
,
error
)
{
var
taints
[]
Taint
if
len
(
annotations
)
>
0
&&
annotations
[
TaintsAnnotationKey
]
!=
""
{
err
:=
json
.
Unmarshal
([]
byte
(
annotations
[
TaintsAnnotationKey
]),
&
taints
)
if
err
!=
nil
{
return
[]
Taint
{},
err
}
}
return
taints
,
nil
}
// SysctlsFromPodAnnotations parses the sysctl annotations into a slice of safe Sysctls
// SysctlsFromPodAnnotations parses the sysctl annotations into a slice of safe Sysctls
// and a slice of unsafe Sysctls. This is only a convenience wrapper around
// and a slice of unsafe Sysctls. This is only a convenience wrapper around
// SysctlsFromPodAnnotation.
// SysctlsFromPodAnnotation.
...
@@ -596,6 +636,21 @@ func PodAnnotationsFromSysctls(sysctls []Sysctl) string {
...
@@ -596,6 +636,21 @@ func PodAnnotationsFromSysctls(sysctls []Sysctl) string {
return
strings
.
Join
(
kvs
,
","
)
return
strings
.
Join
(
kvs
,
","
)
}
}
// GetAffinityFromPodAnnotations gets the json serialized affinity data from Pod.Annotations
// and converts it to the Affinity type in api.
// TODO: remove when alpha support for affinity is removed
func
GetAffinityFromPodAnnotations
(
annotations
map
[
string
]
string
)
(
*
Affinity
,
error
)
{
if
len
(
annotations
)
>
0
&&
annotations
[
AffinityAnnotationKey
]
!=
""
{
var
affinity
Affinity
err
:=
json
.
Unmarshal
([]
byte
(
annotations
[
AffinityAnnotationKey
]),
&
affinity
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
affinity
,
nil
}
return
nil
,
nil
}
// GetPersistentVolumeClass returns StorageClassName.
// GetPersistentVolumeClass returns StorageClassName.
func
GetPersistentVolumeClass
(
volume
*
PersistentVolume
)
string
{
func
GetPersistentVolumeClass
(
volume
*
PersistentVolume
)
string
{
// Use beta annotation first
// Use beta annotation first
...
...
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