Skip to content

Commit

Permalink
Rollback to no pod spec tolerations commitment.
Browse files Browse the repository at this point in the history
  • Loading branch information
breeze7086 committed Aug 6, 2018
1 parent a7c59bf commit e0b73f3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 115 deletions.
3 changes: 1 addition & 2 deletions kubernetes/resource_kubernetes_daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ func resourceKubernetesDaemonSet() *schema.Resource {
"automount_service_account_token": relocatedAttribute("automount_service_account_token"),
"subdomain": relocatedAttribute("subdomain"),
"termination_grace_period_seconds": relocatedAttribute("termination_grace_period_seconds"),
"volume": relocatedAttribute("volume"),
"toleration": relocatedAttribute("toleration"),
"volume": relocatedAttribute("volume"),
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions kubernetes/resource_kubernetes_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ func resourceKubernetesDeployment() *schema.Resource {
"automount_service_account_token": relocatedAttribute("automount_service_account_token"),
"subdomain": relocatedAttribute("subdomain"),
"termination_grace_period_seconds": relocatedAttribute("termination_grace_period_seconds"),
"volume": relocatedAttribute("volume"),
"toleration": relocatedAttribute("toleration"),
"volume": relocatedAttribute("volume"),
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions kubernetes/resource_kubernetes_stateful_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ func resourceKubernetesStatefulSet() *schema.Resource {
"automount_service_account_token": relocatedAttribute("automount_service_account_token"),
"subdomain": relocatedAttribute("subdomain"),
"termination_grace_period_seconds": relocatedAttribute("termination_grace_period_seconds"),
"volume": relocatedAttribute("volume"),
"toleration": relocatedAttribute("toleration"),
"volume": relocatedAttribute("volume"),
},
},
},
Expand Down
35 changes: 0 additions & 35 deletions kubernetes/schema_pod_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,41 +181,6 @@ func podSpecFields(isUpdatable bool) map[string]*schema.Schema {
Description: "List of volumes that can be mounted by containers belonging to the pod. More info: http://kubernetes.io/docs/user-guide/volumes",
Elem: volumeSchema(),
},

"toleration": {
Type: schema.TypeList,
Optional: true,
Description: "If specified, the pod's tolerations",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Description: "Key is the taint key that the toleration applies to. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#toleration-v1-core",
Optional: true,
},
"operator": {
Type: schema.TypeString,
Description: "Operator represents a key's relationship to the value. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#toleration-v1-core",
Optional: true,
},
"effect": {
Type: schema.TypeString,
Description: "Effect indicates the taint effect to match. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#toleration-v1-core",
Optional: true,
},
"toleration_seconds": {
Type: schema.TypeInt,
Description: "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#toleration-v1-core",
Optional: true,
},
"value": {
Type: schema.TypeString,
Description: "Value is the taint value the toleration matches to. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#toleration-v1-core",
Optional: true,
},
},
},
},
}

if !isUpdatable {
Expand Down
74 changes: 0 additions & 74 deletions kubernetes/structures_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) {
}
att["volume"] = v
}

if len(in.Tolerations) > 0 {
v, err := flattenTolerations(in.Tolerations)
if err != nil {
return []interface{}{att}, err
}
att["toleration"] = v
}

return []interface{}{att}, nil
}

Expand Down Expand Up @@ -339,31 +330,6 @@ func flattenSecretVolumeSource(in *v1.SecretVolumeSource) []interface{} {
return []interface{}{att}
}

func flattenTolerations(tolerations []v1.Toleration) ([]interface{}, error) {
att := make([]interface{}, len(tolerations))
for i, v := range tolerations {
obj := map[string]interface{}{}

if v.Key != "" {
obj["key"] = v.Key
}
if v.Operator != "" {
obj["operator"] = v.Operator
}
if v.Value != "" {
obj["value"] = v.Value
}
if v.Effect != "" {
obj["effect"] = v.Effect
}
if v.TolerationSeconds != nil {
obj["toleration_seconds"] = *v.TolerationSeconds
}
att[i] = obj
}
return att, nil
}

// Expanders

func expandPodTemplateSpec(template map[string]interface{}) (v1.PodTemplateSpec, error) {
Expand Down Expand Up @@ -480,15 +446,6 @@ func expandPodSpec(p []interface{}) (v1.PodSpec, error) {
}
obj.Volumes = cs
}

if v, ok := in["toleration"].([]interface{}); ok && len(v) > 0 {
cs, err := expandTolerations(v)
if err != nil {
return obj, err
}
obj.Tolerations = cs
}

return obj, nil
}

Expand Down Expand Up @@ -780,37 +737,6 @@ func expandVolumes(volumes []interface{}) ([]v1.Volume, error) {
return vl, nil
}

func expandTolerations(tolerations []interface{}) ([]v1.Toleration, error) {
if len(tolerations) == 0 {
return []v1.Toleration{}, nil
}
vl := make([]v1.Toleration, len(tolerations))
for i, c := range tolerations {
m := c.(map[string]interface{})

if value, ok := m["key"]; ok {
vl[i].Key = value.(string)
}

if value, ok := m["effect"].(string); ok {
vl[i].Effect = v1.TaintEffect(value)
}

if value, ok := m["operator"].(string); ok {
vl[i].Operator = v1.TolerationOperator(value)
}

if value, ok := m["value"]; ok {
vl[i].Value = value.(string)
}

if value, ok := m["toleration_seconds"].(int64); ok {
vl[i].TolerationSeconds = ptrToInt64(int64(value))
}
}
return vl, nil
}

func patchPodSpec(pathPrefix, prefix string, d *schema.ResourceData) (PatchOperations, error) {
ops := make([]PatchOperation, 0)

Expand Down

0 comments on commit e0b73f3

Please sign in to comment.