|
|
@ -128,24 +128,28 @@ func generateLabels(labels map[string]string) map[string]string {
|
|
|
|
return labels
|
|
|
|
return labels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// parseNodeSelectors takes a comma delimited list of key=values pairs and returns a map
|
|
|
|
// parseNodeSelectors parses a comma delimited list of key=values pairs into a map
|
|
|
|
func parseNodeSelectors(labels string, m map[string]string) map[string]string {
|
|
|
|
func parseNodeSelectorsInto(labels string, m map[string]string) error {
|
|
|
|
kv := strings.Split(labels, ",")
|
|
|
|
kv := strings.Split(labels, ",")
|
|
|
|
for _, v := range kv {
|
|
|
|
for _, v := range kv {
|
|
|
|
el := strings.Split(v, "=")
|
|
|
|
el := strings.Split(v, "=")
|
|
|
|
if len(el) == 2 {
|
|
|
|
if len(el) == 2 {
|
|
|
|
m[el[0]] = el[1]
|
|
|
|
m[el[0]] = el[1]
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return fmt.Errorf("Invalid nodeSelector label: %s", kv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return m
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func generateDeployment(opts *Options) (*v1beta1.Deployment, error) {
|
|
|
|
func generateDeployment(opts *Options) (*v1beta1.Deployment, error) {
|
|
|
|
labels := generateLabels(map[string]string{"name": "tiller"})
|
|
|
|
labels := generateLabels(map[string]string{"name": "tiller"})
|
|
|
|
nodeSelectors := map[string]string{}
|
|
|
|
nodeSelectors := map[string]string{}
|
|
|
|
nodeSelectors["beta.kubernetes.io/os"] = "linux"
|
|
|
|
nodeSelectors["beta.kubernetes.io/os"] = "linux"
|
|
|
|
if len(opts.NodeSelectors) > 0 {
|
|
|
|
if len(opts.NodeSelectors) > 0 {
|
|
|
|
nodeSelectors = parseNodeSelectors(opts.NodeSelectors, nodeSelectors)
|
|
|
|
err := parseNodeSelectorsInto(opts.NodeSelectors, nodeSelectors)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d := &v1beta1.Deployment{
|
|
|
|
d := &v1beta1.Deployment{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|