Skip to content

Commit

Permalink
Adds field to pod: priority_class_name
Browse files Browse the repository at this point in the history
  • Loading branch information
nickschuch committed May 26, 2021
1 parent 97d611e commit f1947ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/kubernetes/core/v1/pod/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ func Expand(in []interface{}) (corev1.PodTemplateSpec, error) {
template.Spec.HostPID = val.(bool)
}

if val, ok := raw[FieldPriorityClassName]; ok {
template.Spec.PriorityClassName = val.(string)
}

return template, nil
}
11 changes: 9 additions & 2 deletions internal/kubernetes/core/v1/pod/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const (
FieldPullSecret = "pull_secret"
// FieldHostPID is a field identifier.
FieldHostPID = "host_pid"
// FieldPriorityClassName is a field identifier.
FieldPriorityClassName = "priority_class_name"
)

// Fields which define a Pod.
Expand All @@ -37,11 +39,11 @@ func Fields() *schema.Schema {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
FieldAnnotations: &schema.Schema{
FieldAnnotations: {
Type: schema.TypeMap,
Optional: true,
},
FieldLabels: &schema.Schema{
FieldLabels: {
Type: schema.TypeMap,
Optional: true,
},
Expand All @@ -65,6 +67,11 @@ func Fields() *schema.Schema {
Description: "Use the host’s pid namespace.",
Optional: true,
},
FieldPriorityClassName: {
Type: schema.TypeString,
Description: "Priority indicates the importance of a Pod relative to other Pods.",
Optional: true,
},
},
},
}
Expand Down
4 changes: 4 additions & 0 deletions internal/kubernetes/core/v1/pod/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func Flatten(template corev1.PodTemplateSpec) []interface{} {
row[FieldHostPID] = template.Spec.HostPID
}

if template.Spec.PriorityClassName != "" {
row[FieldPriorityClassName] = template.Spec.PriorityClassName
}

out[0] = row

return out
Expand Down

0 comments on commit f1947ad

Please sign in to comment.