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
5fa8702a
Commit
5fa8702a
authored
Oct 23, 2017
by
Antoine Pelisse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix govet in pkg/kubectl/apply
parent
067f2db3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
8 deletions
+41
-8
factory.go
pkg/kubectl/apply/parse/factory.go
+21
-3
list_element.go
pkg/kubectl/apply/parse/list_element.go
+5
-1
map_element.go
pkg/kubectl/apply/parse/map_element.go
+5
-1
primitive_element.go
pkg/kubectl/apply/parse/primitive_element.go
+4
-1
type_element.go
pkg/kubectl/apply/parse/type_element.go
+5
-1
utils_test.go
pkg/kubectl/apply/strategy/utils_test.go
+1
-1
No files found.
pkg/kubectl/apply/parse/factory.go
View file @
5fa8702a
...
...
@@ -86,17 +86,35 @@ func (v *ElementBuildingVisitor) getItem(s proto.Schema, name string, data apply
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"expected openapi Array, was %T for %v"
,
s
,
kind
)
}
return
&
listItem
{
name
,
a
,
apply
.
ListElementData
{
data
}},
nil
return
&
listItem
{
Name
:
name
,
Array
:
a
,
ListElementData
:
apply
.
ListElementData
{
RawElementData
:
data
,
},
},
nil
case
reflect
.
Map
:
if
k
,
err
:=
getKind
(
s
);
err
==
nil
{
return
&
typeItem
{
name
,
k
,
apply
.
MapElementData
{
data
}},
nil
return
&
typeItem
{
Name
:
name
,
Type
:
k
,
MapElementData
:
apply
.
MapElementData
{
RawElementData
:
data
,
},
},
nil
}
// If it looks like a map, and no openapi type is found, default to mapItem
m
,
err
:=
getMap
(
s
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"expected openapi Kind or Map, was %T for %v"
,
s
,
kind
)
}
return
&
mapItem
{
name
,
m
,
apply
.
MapElementData
{
data
}},
nil
return
&
mapItem
{
Name
:
name
,
Map
:
m
,
MapElementData
:
apply
.
MapElementData
{
RawElementData
:
data
,
},
},
nil
}
return
nil
,
fmt
.
Errorf
(
"unsupported type type %v"
,
kind
)
}
pkg/kubectl/apply/parse/list_element.go
View file @
5fa8702a
...
...
@@ -154,7 +154,11 @@ func (v ElementBuildingVisitor) doMapList(meta apply.FieldMetaImpl, item *listIt
// Uses the "replace" strategy and identify "same" elements across lists by their index
func
(
v
ElementBuildingVisitor
)
replaceListElement
(
meta
apply
.
FieldMetaImpl
,
item
*
listItem
)
(
*
apply
.
ListElement
,
error
)
{
meta
.
Name
=
item
.
Name
result
:=
&
apply
.
ListElement
{
meta
,
item
.
ListElementData
,
[]
apply
.
Element
{}}
result
:=
&
apply
.
ListElement
{
FieldMetaImpl
:
meta
,
ListElementData
:
item
.
ListElementData
,
Values
:
[]
apply
.
Element
{},
}
// Use the max length to iterate over the slices
for
i
:=
0
;
i
<
max
(
len
(
item
.
GetRecordedList
()),
len
(
item
.
GetLocalList
()),
len
(
item
.
GetRemoteList
()));
i
++
{
...
...
pkg/kubectl/apply/parse/map_element.go
View file @
5fa8702a
...
...
@@ -39,7 +39,11 @@ func (v ElementBuildingVisitor) mapElement(meta apply.FieldMetaImpl, item *mapIt
}
// Return the result
return
&
apply
.
MapElement
{
meta
,
item
.
MapElementData
,
values
},
nil
return
&
apply
.
MapElement
{
FieldMetaImpl
:
meta
,
MapElementData
:
item
.
MapElementData
,
Values
:
values
,
},
nil
}
// schemaFn returns the schema for a field or map value based on its name or key
...
...
pkg/kubectl/apply/parse/primitive_element.go
View file @
5fa8702a
...
...
@@ -21,5 +21,8 @@ import "k8s.io/kubernetes/pkg/kubectl/apply"
// primitiveElement builds a new primitiveElement from a PrimitiveItem
func
(
v
ElementBuildingVisitor
)
primitiveElement
(
item
*
primitiveItem
)
(
*
apply
.
PrimitiveElement
,
error
)
{
meta
:=
apply
.
FieldMetaImpl
{
Name
:
item
.
Name
}
return
&
apply
.
PrimitiveElement
{
meta
,
item
.
RawElementData
},
nil
return
&
apply
.
PrimitiveElement
{
FieldMetaImpl
:
meta
,
RawElementData
:
item
.
RawElementData
,
},
nil
}
pkg/kubectl/apply/parse/type_element.go
View file @
5fa8702a
...
...
@@ -38,5 +38,9 @@ func (v ElementBuildingVisitor) typeElement(meta apply.FieldMetaImpl, item *type
}
// Return the result
return
&
apply
.
TypeElement
{
meta
,
item
.
MapElementData
,
values
},
nil
return
&
apply
.
TypeElement
{
FieldMetaImpl
:
meta
,
MapElementData
:
item
.
MapElementData
,
Values
:
values
,
},
nil
}
pkg/kubectl/apply/strategy/utils_test.go
View file @
5fa8702a
...
...
@@ -44,7 +44,7 @@ func runWith(instance apply.Strategy, recorded, local, remote, expected map[stri
Expect
(
err
)
.
To
(
BeNil
())
resources
,
err
:=
openapi
.
NewOpenAPIData
(
s
)
Expect
(
err
)
.
To
(
BeNil
())
parseFactory
:=
parse
.
Factory
{
resources
}
parseFactory
:=
parse
.
Factory
{
Resources
:
resources
}
parsed
,
err
:=
parseFactory
.
CreateElement
(
recorded
,
local
,
remote
)
Expect
(
err
)
.
Should
(
Not
(
HaveOccurred
()))
...
...
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