Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetes_persistent_volume resource should support storage_class_name #72

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kubernetes/resource_kubernetes_persistent_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func resourceKubernetesPersistentVolume() *schema.Resource {
MaxItems: 1,
Elem: persistentVolumeSourceSchema(),
},
"storage_class_name": {
Type: schema.TypeString,
Description: "A description of the persistent volume's class. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class",
Optional: true,
},
},
},
},
Expand Down
13 changes: 13 additions & 0 deletions kubernetes/structure_persistent_volume_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ func flattenPersistentVolumeSpec(in v1.PersistentVolumeSpec) []interface{} {
if in.PersistentVolumeReclaimPolicy != "" {
att["persistent_volume_reclaim_policy"] = in.PersistentVolumeReclaimPolicy
}
if in.StorageClassName != "" {
att["storage_class_name"] = in.StorageClassName
}
return []interface{}{att}
}

Expand Down Expand Up @@ -653,6 +656,9 @@ func expandPersistentVolumeSpec(l []interface{}) (v1.PersistentVolumeSpec, error
if v, ok := in["persistent_volume_reclaim_policy"].(string); ok {
obj.PersistentVolumeReclaimPolicy = v1.PersistentVolumeReclaimPolicy(v)
}
if v, ok := in["storage_class_name"].(string); ok {
obj.StorageClassName = v
}
return obj, nil
}

Expand Down Expand Up @@ -773,6 +779,13 @@ func patchPersistentVolumeSpec(pathPrefix, prefix string, d *schema.ResourceData
Value: v1.PersistentVolumeReclaimPolicy(v),
})
}
if d.HasChange(prefix + "storage_class_name") {
v := d.Get(prefix + "storage_class_name").(string)
ops = append(ops, &ReplaceOperation{
Path: pathPrefix + "/storageClassName",
Value: v1.StorageClassName(v),
})
}

return ops, nil
}
Expand Down
3 changes: 3 additions & 0 deletions vendor/k8s.io/kubernetes/pkg/api/v1/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions website/docs/r/persistent_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ resource "kubernetes_persistent_volume" "example" {
volume_path = "/absolute/path"
}
}
storage_class_name = "standard"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be left out of the example resource, because it should be left empty by default.

}
}
```
Expand All @@ -50,6 +51,7 @@ The following arguments are supported:
* `capacity` - (Required) A description of the persistent volume's resources and capacity. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#capacity
* `persistent_volume_reclaim_policy` - (Optional) What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this persistent volume. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#recycling-policy
* `persistent_volume_source` - (Required) The specification of a persistent volume.
* `storage_class_name` - (Optional) A description of the persistent volume's class. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class

### `persistent_volume_source`

Expand Down