mirror of https://github.com/kubernetes/kops.git
go fmt fixes and apimachinery run
This commit is contained in:
parent
c3b6733b08
commit
7a1792e7cb
|
@ -18,12 +18,12 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
"encoding/csv"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -789,12 +789,12 @@ func trimCommonPrefix(names []string) []string {
|
|||
|
||||
// parseCloudLabels takes a CSV list of key=value records and parses them into a map. Nested '='s are supported via
|
||||
// quoted strings (eg `foo="bar=baz"` parses to map[string]string{"foo":"bar=baz"}. Nested commas are not supported.
|
||||
func parseCloudLabels (s string) (map[string]string, error) {
|
||||
func parseCloudLabels(s string) (map[string]string, error) {
|
||||
|
||||
// Replace commas with newlines to allow a single pass with csv.Reader.
|
||||
// We can't use csv.Reader for the initial split because it would see each key=value record as a single field
|
||||
// and significantly complicates using quoted fields as keys or values.
|
||||
records := strings.Replace(s,",","\n",-1)
|
||||
records := strings.Replace(s, ",", "\n", -1)
|
||||
|
||||
// Let the CSV library do the heavy-lifting in handling nested ='s
|
||||
r := csv.NewReader(strings.NewReader(records))
|
||||
|
|
|
@ -21,12 +21,12 @@ import (
|
|||
)
|
||||
|
||||
func TestParseCloudLabels(t *testing.T) {
|
||||
expect := map[string]string{"foo":"bar", "fib":"baz"}
|
||||
expect := map[string]string{"foo": "bar", "fib": "baz"}
|
||||
checkParse(t, "", map[string]string{}, false)
|
||||
checkParse(t, "foo=bar,fib=baz", expect, false)
|
||||
checkParse(t, `foo=bar,"fib"="baz"`, expect, false)
|
||||
checkParse(t, `"fo\""o"=bar,"fi\b"="baz"`,
|
||||
map[string]string{`fo\"o`:"bar", `fi\b`:"baz"}, false)
|
||||
map[string]string{`fo\"o`: "bar", `fi\b`: "baz"}, false)
|
||||
checkParse(t, `fo"o=bar,fib=baz`, expect, true)
|
||||
checkParse(t, `fo,o=bar,fib=baz`, expect, true)
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ type ClusterSpec struct {
|
|||
Networking *NetworkingSpec `json:"networking,omitempty"`
|
||||
|
||||
// API field controls how the API is exposed outside the cluster
|
||||
API *AccessSpec `json:"api,omitempty"`
|
||||
API *AccessSpec `json:"api,omitempty"`
|
||||
|
||||
// Tags for AWS resources
|
||||
CloudLabels map[string]string `json:"cloudLabels,omitempty"`
|
||||
|
|
|
@ -472,6 +472,7 @@ func autoConvert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out *
|
|||
} else {
|
||||
out.API = nil
|
||||
}
|
||||
out.CloudLabels = in.CloudLabels
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -623,6 +624,7 @@ func autoConvert_kops_ClusterSpec_To_v1alpha2_ClusterSpec(in *kops.ClusterSpec,
|
|||
} else {
|
||||
out.API = nil
|
||||
}
|
||||
out.CloudLabels = in.CloudLabels
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ func BuildCloud(cluster *api.Cluster) (fi.Cloud, error) {
|
|||
|
||||
cloudTags := map[string]string{awsup.TagClusterName: cluster.ObjectMeta.Name}
|
||||
for k, v := range cluster.Spec.CloudLabels {
|
||||
if _,exists := cloudTags[k]; !exists {
|
||||
if _, exists := cloudTags[k]; !exists {
|
||||
cloudTags[k] = v
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue