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
12301ae3
Commit
12301ae3
authored
Jan 05, 2018
by
Robert Pothier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kubeadm: clean up MarshalToYamlForCodecs
Proxy will use PrintBytesWithLinePrefix to indent.
parent
d61eff6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
18 deletions
+5
-18
proxy.go
cmd/kubeadm/app/phases/addons/proxy/proxy.go
+5
-2
marshal.go
cmd/kubeadm/app/util/marshal.go
+0
-16
No files found.
cmd/kubeadm/app/phases/addons/proxy/proxy.go
View file @
12301ae3
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
proxy
package
proxy
import
(
import
(
"bytes"
"fmt"
"fmt"
"runtime"
"runtime"
...
@@ -57,11 +58,13 @@ func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Inte
...
@@ -57,11 +58,13 @@ func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Inte
return
err
return
err
}
}
proxyBytes
,
err
:=
kubeadmutil
.
MarshalToYamlForCodecs
WithShift
(
cfg
.
KubeProxy
.
Config
,
kubeproxyconfigv1alpha1
.
SchemeGroupVersion
,
proxyBytes
,
err
:=
kubeadmutil
.
MarshalToYamlForCodecs
(
cfg
.
KubeProxy
.
Config
,
kubeproxyconfigv1alpha1
.
SchemeGroupVersion
,
kubeproxyconfigscheme
.
Codecs
)
kubeproxyconfigscheme
.
Codecs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error when marshaling: %v"
,
err
)
return
fmt
.
Errorf
(
"error when marshaling: %v"
,
err
)
}
}
var
prefixBytes
bytes
.
Buffer
apiclient
.
PrintBytesWithLinePrefix
(
&
prefixBytes
,
proxyBytes
,
" "
)
var
proxyConfigMapBytes
,
proxyDaemonSetBytes
[]
byte
var
proxyConfigMapBytes
,
proxyDaemonSetBytes
[]
byte
proxyConfigMapBytes
,
err
=
kubeadmutil
.
ParseTemplate
(
KubeProxyConfigMap19
,
proxyConfigMapBytes
,
err
=
kubeadmutil
.
ParseTemplate
(
KubeProxyConfigMap19
,
struct
{
struct
{
...
@@ -69,7 +72,7 @@ func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Inte
...
@@ -69,7 +72,7 @@ func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Inte
ProxyConfig
string
ProxyConfig
string
}{
}{
MasterEndpoint
:
masterEndpoint
,
MasterEndpoint
:
masterEndpoint
,
ProxyConfig
:
pr
oxyBytes
,
ProxyConfig
:
pr
efixBytes
.
String
()
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error when parsing kube-proxy configmap template: %v"
,
err
)
return
fmt
.
Errorf
(
"error when parsing kube-proxy configmap template: %v"
,
err
)
...
...
cmd/kubeadm/app/util/marshal.go
View file @
12301ae3
...
@@ -18,7 +18,6 @@ package util
...
@@ -18,7 +18,6 @@ package util
import
(
import
(
"fmt"
"fmt"
"strings"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -42,18 +41,3 @@ func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs s
...
@@ -42,18 +41,3 @@ func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs s
encoder
:=
codecs
.
EncoderForVersion
(
info
.
Serializer
,
gv
)
encoder
:=
codecs
.
EncoderForVersion
(
info
.
Serializer
,
gv
)
return
runtime
.
Encode
(
encoder
,
obj
)
return
runtime
.
Encode
(
encoder
,
obj
)
}
}
// MarshalToYamlForCodecsWithShift adds spaces in front of each line so the indents line up
// correctly in the manifest
func
MarshalToYamlForCodecsWithShift
(
obj
runtime
.
Object
,
gv
schema
.
GroupVersion
,
codecs
serializer
.
CodecFactory
)
(
string
,
error
)
{
serial
,
err
:=
MarshalToYamlForCodecs
(
obj
,
gv
,
codecs
)
if
err
!=
nil
{
return
""
,
err
}
lines
:=
strings
.
Split
(
string
(
serial
),
"
\n
"
)
var
newSerial
string
for
_
,
line
:=
range
lines
{
newSerial
=
newSerial
+
" "
+
line
+
"
\n
"
}
return
newSerial
,
err
}
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