Skip to content

Commit

Permalink
Merge pull request #3 from previousnext/hostpid
Browse files Browse the repository at this point in the history
Adds host_pid to deployments, daemonsets and cronjobs
  • Loading branch information
nicksantamaria authored Mar 1, 2018
2 parents 95f9340 + a4f5ac7 commit e3fec56
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cronjob/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func Resource() *schema.Resource {
Description: "How often to run this CronJob.",
Required: true,
},
"host_pid": {
Type: schema.TypeBool,
Description: "Use the host’s pid namespace.",
Optional: true,
},
"service_account": {
Type: schema.TypeString,
Description: "ServiceAccount to associate with this CronJob.",
Expand All @@ -58,6 +63,7 @@ func generateCronJob(d *schema.ResourceData) (batchv1beta1.CronJob, error) {
namespace = d.Get("namespace").(string)
labels = d.Get("labels").(map[string]interface{})
schedule = d.Get("schedule").(string)
hostPid = d.Get("host_pid").(bool)
serviceaccount = d.Get("service_account").(string)
aliases = d.Get("hostaliases").([]interface{})
containers = d.Get("container").([]interface{})
Expand Down Expand Up @@ -94,6 +100,7 @@ func generateCronJob(d *schema.ResourceData) (batchv1beta1.CronJob, error) {
Volumes: volumeList,
ServiceAccountName: serviceaccount,
HostAliases: hostaliases.Expand(aliases),
HostPID: hostPid,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions cronjob/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func resourceRead(d *schema.ResourceData, m interface{}) error {
d.Set("namespace", cronJob.ObjectMeta.Namespace)
d.Set("labels", cronJob.ObjectMeta.Labels)
d.Set("schedule", cronJob.Spec.Schedule)
d.Set("host_pid", cronJob.Spec.JobTemplate.Spec.Template.Spec.HostPID)
d.Set("service_account", cronJob.Spec.JobTemplate.Spec.Template.Spec.ServiceAccountName)
d.Set("container", container.Flatten(cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers))
d.Set("hostaliases", hostaliases.Flatten(cronJob.Spec.JobTemplate.Spec.Template.Spec.HostAliases))
Expand Down
7 changes: 7 additions & 0 deletions daemonset/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func Resource() *schema.Resource {
Optional: true,
Default: false,
},
"host_pid": {
Type: schema.TypeBool,
Description: "Use the host’s pid namespace.",
Optional: true,
},
"service_account": {
Type: schema.TypeString,
Description: "ServiceAccount to associate with this DaemonSet.",
Expand All @@ -59,6 +64,7 @@ func generateDaemonSet(d *schema.ResourceData) (appsv1beta2.DaemonSet, error) {
namespace = d.Get("namespace").(string)
labels = d.Get("labels").(map[string]interface{})
hostNetwork = d.Get("host_network").(bool)
hostPid = d.Get("host_pid").(bool)
serviceAccount = d.Get("service_account").(string)
initContainer = d.Get("init_container").([]interface{})
aliases = d.Get("hostaliases").([]interface{})
Expand Down Expand Up @@ -101,6 +107,7 @@ func generateDaemonSet(d *schema.ResourceData) (appsv1beta2.DaemonSet, error) {
InitContainers: initContainerList,
Containers: containerList,
Volumes: volumeList,
HostPID: hostPid,
HostAliases: hostaliases.Expand(aliases),
},
},
Expand Down
1 change: 1 addition & 0 deletions daemonset/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func resourceRead(d *schema.ResourceData, m interface{}) error {

d.Set("name", daemonset.ObjectMeta.Name)
d.Set("namespace", daemonset.ObjectMeta.Namespace)
d.Set("host_pid", daemonset.Spec.Template.Spec.HostPID)
d.Set("service_account", daemonset.Spec.Template.Spec.ServiceAccountName)
d.Set("labels", daemonset.ObjectMeta.Labels)
d.Set("hostaliases", hostaliases.Flatten(daemonset.Spec.Template.Spec.HostAliases))
Expand Down
7 changes: 7 additions & 0 deletions deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func Resource() *schema.Resource {
Description: "ServiceAccount to associate with this Deployment.",
Optional: true,
},
"host_pid": {
Type: schema.TypeBool,
Description: "Use the host’s pid namespace.",
Optional: true,
},
"labels": label.Fields(),
"container": container.Fields(),
"hostaliases": hostaliases.Fields(),
Expand All @@ -49,6 +54,7 @@ func generateDeployment(d *schema.ResourceData) (appsv1beta2.Deployment, error)
var (
name = d.Get("name").(string)
namespace = d.Get("namespace").(string)
hostPid = d.Get("host_pid").(bool)
serviceaccount = d.Get("service_account").(string)
labels = d.Get("labels").(map[string]interface{})
aliases = d.Get("hostaliases").([]interface{})
Expand Down Expand Up @@ -85,6 +91,7 @@ func generateDeployment(d *schema.ResourceData) (appsv1beta2.Deployment, error)
Containers: containerList,
Volumes: volumeList,
HostAliases: hostaliases.Expand(aliases),
HostPID: hostPid,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions deployment/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func resourceRead(d *schema.ResourceData, m interface{}) error {

d.Set("name", deployment.ObjectMeta.Name)
d.Set("namespace", deployment.ObjectMeta.Namespace)
d.Set("host_pid", deployment.Spec.Template.Spec.HostPID)
d.Set("service_account", deployment.Spec.Template.Spec.ServiceAccountName)
d.Set("labels", deployment.ObjectMeta.Labels)
d.Set("image", deployment.Spec.Template.Spec.Containers[0].Image)
Expand Down

0 comments on commit e3fec56

Please sign in to comment.