mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #57908 from rpothier/proxy-prefix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubeadm: clean up MarshalToYamlForCodecs Proxy will use PrintBytesWithLinePrefix to indent. **What this PR does / why we need it**: This removed the function MarshalToYamlForCodecsWithShift() and the proxy code will use PrintBytesWithLinePrefix() to shift over the yaml lines. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #57907 **Special notes for your reviewer**: **Release note**: ```release-note-none ```
This commit is contained in:
commit
a7e398819c
@ -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
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyBytes, err := kubeadmutil.MarshalToYamlForCodecsWithShift(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
|
|||||||
ProxyConfig string
|
ProxyConfig string
|
||||||
}{
|
}{
|
||||||
MasterEndpoint: masterEndpoint,
|
MasterEndpoint: masterEndpoint,
|
||||||
ProxyConfig: proxyBytes,
|
ProxyConfig: prefixBytes.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)
|
||||||
|
@ -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
|
|||||||
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user