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
3f09fecb
Unverified
Commit
3f09fecb
authored
Jul 09, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop sorting downward api file lines
parent
f7041095
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
16 deletions
+14
-16
BUILD
pkg/fieldpath/BUILD
+1
-0
fieldpath.go
pkg/fieldpath/fieldpath.go
+8
-2
downwardapi.go
pkg/volume/downwardapi/downwardapi.go
+2
-12
downwardapi_test.go
pkg/volume/downwardapi/downwardapi_test.go
+3
-2
No files found.
pkg/fieldpath/BUILD
View file @
3f09fecb
...
@@ -15,6 +15,7 @@ go_library(
...
@@ -15,6 +15,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/fieldpath",
importpath = "k8s.io/kubernetes/pkg/fieldpath",
deps = [
deps = [
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
],
],
)
)
...
...
pkg/fieldpath/fieldpath.go
View file @
3f09fecb
...
@@ -21,13 +21,19 @@ import (
...
@@ -21,13 +21,19 @@ import (
"strings"
"strings"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation"
)
)
// FormatMap formats map[string]string to a string.
// FormatMap formats map[string]string to a string.
func
FormatMap
(
m
map
[
string
]
string
)
(
fmtStr
string
)
{
func
FormatMap
(
m
map
[
string
]
string
)
(
fmtStr
string
)
{
for
key
,
value
:=
range
m
{
// output with keys in sorted order to provide stable output
fmtStr
+=
fmt
.
Sprintf
(
"%v=%q
\n
"
,
key
,
value
)
keys
:=
sets
.
NewString
()
for
key
:=
range
m
{
keys
.
Insert
(
key
)
}
for
_
,
key
:=
range
keys
.
List
()
{
fmtStr
+=
fmt
.
Sprintf
(
"%v=%q
\n
"
,
key
,
m
[
key
])
}
}
fmtStr
=
strings
.
TrimSuffix
(
fmtStr
,
"
\n
"
)
fmtStr
=
strings
.
TrimSuffix
(
fmtStr
,
"
\n
"
)
...
...
pkg/volume/downwardapi/downwardapi.go
View file @
3f09fecb
...
@@ -20,8 +20,6 @@ import (
...
@@ -20,8 +20,6 @@ import (
"fmt"
"fmt"
"path"
"path"
"path/filepath"
"path/filepath"
"sort"
"strings"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -244,7 +242,7 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
...
@@ -244,7 +242,7 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
glog
.
Errorf
(
"Unable to extract field %s: %s"
,
fileInfo
.
FieldRef
.
FieldPath
,
err
.
Error
())
glog
.
Errorf
(
"Unable to extract field %s: %s"
,
fileInfo
.
FieldRef
.
FieldPath
,
err
.
Error
())
errlist
=
append
(
errlist
,
err
)
errlist
=
append
(
errlist
,
err
)
}
else
{
}
else
{
fileProjection
.
Data
=
[]
byte
(
sortLines
(
values
)
)
fileProjection
.
Data
=
[]
byte
(
values
)
}
}
}
else
if
fileInfo
.
ResourceFieldRef
!=
nil
{
}
else
if
fileInfo
.
ResourceFieldRef
!=
nil
{
containerName
:=
fileInfo
.
ResourceFieldRef
.
ContainerName
containerName
:=
fileInfo
.
ResourceFieldRef
.
ContainerName
...
@@ -255,7 +253,7 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
...
@@ -255,7 +253,7 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
glog
.
Errorf
(
"Unable to extract field %s: %s"
,
fileInfo
.
ResourceFieldRef
.
Resource
,
err
.
Error
())
glog
.
Errorf
(
"Unable to extract field %s: %s"
,
fileInfo
.
ResourceFieldRef
.
Resource
,
err
.
Error
())
errlist
=
append
(
errlist
,
err
)
errlist
=
append
(
errlist
,
err
)
}
else
{
}
else
{
fileProjection
.
Data
=
[]
byte
(
sortLines
(
values
)
)
fileProjection
.
Data
=
[]
byte
(
values
)
}
}
}
}
...
@@ -264,14 +262,6 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
...
@@ -264,14 +262,6 @@ func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.Volu
return
data
,
utilerrors
.
NewAggregate
(
errlist
)
return
data
,
utilerrors
.
NewAggregate
(
errlist
)
}
}
// sortLines sorts the strings generated from map based data
// (annotations and labels)
func
sortLines
(
values
string
)
string
{
splitted
:=
strings
.
Split
(
values
,
"
\n
"
)
sort
.
Strings
(
splitted
)
return
strings
.
Join
(
splitted
,
"
\n
"
)
}
func
(
d
*
downwardAPIVolume
)
GetPath
()
string
{
func
(
d
*
downwardAPIVolume
)
GetPath
()
string
{
return
d
.
plugin
.
host
.
GetPodVolumeDir
(
d
.
podUID
,
utilstrings
.
EscapeQualifiedNameForDisk
(
downwardAPIPluginName
),
d
.
volName
)
return
d
.
plugin
.
host
.
GetPodVolumeDir
(
d
.
podUID
,
utilstrings
.
EscapeQualifiedNameForDisk
(
downwardAPIPluginName
),
d
.
volName
)
}
}
...
...
pkg/volume/downwardapi/downwardapi_test.go
View file @
3f09fecb
...
@@ -84,6 +84,7 @@ func TestDownwardAPI(t *testing.T) {
...
@@ -84,6 +84,7 @@ func TestDownwardAPI(t *testing.T) {
annotations
:=
map
[
string
]
string
{
annotations
:=
map
[
string
]
string
{
"a1"
:
"value1"
,
"a1"
:
"value1"
,
"a2"
:
"value2"
,
"a2"
:
"value2"
,
"multiline"
:
"c
\n
b
\n
a"
,
}
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
name
string
name
string
...
@@ -318,8 +319,8 @@ func doVerifyLinesInFile(t *testing.T, volumePath, filename string, expected str
...
@@ -318,8 +319,8 @@ func doVerifyLinesInFile(t *testing.T, volumePath, filename string, expected str
t
.
Errorf
(
err
.
Error
())
t
.
Errorf
(
err
.
Error
())
return
return
}
}
actualStr
:=
s
ortLines
(
string
(
data
)
)
actualStr
:=
s
tring
(
data
)
expectedStr
:=
sortLines
(
expected
)
expectedStr
:=
expected
if
actualStr
!=
expectedStr
{
if
actualStr
!=
expectedStr
{
t
.
Errorf
(
"Found `%s`, expected `%s`"
,
actualStr
,
expectedStr
)
t
.
Errorf
(
"Found `%s`, expected `%s`"
,
actualStr
,
expectedStr
)
}
}
...
...
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