Skip to content

Commit

Permalink
Merge branch '8-host-path-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickschuch committed Apr 3, 2019
2 parents ed5a099 + 47ce96f commit a49c1f6
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 178 deletions.
11 changes: 6 additions & 5 deletions internal/kubernetes/core/v1/pod/volume/expand.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package volume

import (
"github.com/previousnext/terraform-provider-k8s/internal/kubernetes/core/v1/pod/volume/nfs"
corev1 "k8s.io/api/core/v1"
)

Expand Down Expand Up @@ -34,15 +33,17 @@ func Expand(in []interface{}) ([]corev1.Volume, error) {
}
}

if hp, ok := value[FieldHostPath]; ok && hp != "" {
volumes[key].HostPath = &corev1.HostPathVolumeSource{
Path: hp.(string),
}
}

if dir, ok := value[FieldEmptyDir]; ok && dir != "" {
volumes[key].EmptyDir = &corev1.EmptyDirVolumeSource{
Medium: dir.(corev1.StorageMedium),
}
}

if val, ok := value[FieldNFS]; ok {
volumes[key].NFS = nfs.Expand(val.([]interface{}))
}
}

return volumes, nil
Expand Down
9 changes: 4 additions & 5 deletions internal/kubernetes/core/v1/pod/volume/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package volume

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/previousnext/terraform-provider-k8s/internal/kubernetes/core/v1/pod/volume/nfs"
"github.com/previousnext/terraform-provider-k8s/internal/kubernetes/core/v1/pod/volume/hostpath"
)

const (
Expand All @@ -19,7 +17,6 @@ const (
FieldNFS = "nfs"
// FieldHostPath is a field identifier.
FieldHostPath = "host_path"

)

// Fields returns the fields for this package.
Expand All @@ -46,8 +43,10 @@ func Fields() *schema.Schema {
Type: schema.TypeString,
Optional: true,
},
FieldNFS: nfs.Fields(),
FieldHostPath: hostpath.Fields(),
FieldHostPath: {
Type: schema.TypeString,
Optional: true,
},
},
},
}
Expand Down
9 changes: 4 additions & 5 deletions internal/kubernetes/core/v1/pod/volume/flatten.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package volume

import (
"github.com/previousnext/terraform-provider-k8s/internal/kubernetes/core/v1/pod/volume/nfs"
corev1 "k8s.io/api/core/v1"
)

Expand All @@ -24,12 +23,12 @@ func Flatten(in []corev1.Volume) []interface{} {
row[FieldConfigMap] = value.ConfigMap.LocalObjectReference.Name
}

if value.EmptyDir != nil {
row[FieldEmptyDir] = value.EmptyDir.Medium
if value.HostPath != nil && value.HostPath.Path != "" {
row[FieldHostPath] = value.HostPath.Path
}

if value.NFS != nil {
row[FieldNFS] = nfs.Flatten(value.NFS)
if value.EmptyDir != nil {
row[FieldEmptyDir] = value.EmptyDir.Medium
}

flattened[key] = row
Expand Down
26 changes: 0 additions & 26 deletions internal/kubernetes/core/v1/pod/volume/hostpath/expand.go

This file was deleted.

32 changes: 0 additions & 32 deletions internal/kubernetes/core/v1/pod/volume/hostpath/fields.go

This file was deleted.

23 changes: 0 additions & 23 deletions internal/kubernetes/core/v1/pod/volume/hostpath/flatten.go

This file was deleted.

26 changes: 0 additions & 26 deletions internal/kubernetes/core/v1/pod/volume/nfs/expand.go

This file was deleted.

32 changes: 0 additions & 32 deletions internal/kubernetes/core/v1/pod/volume/nfs/fields.go

This file was deleted.

24 changes: 0 additions & 24 deletions internal/kubernetes/core/v1/pod/volume/nfs/flatten.go

This file was deleted.

0 comments on commit a49c1f6

Please sign in to comment.