Skip to content

Commit

Permalink
Set maximum constraint name length to 63
Browse files Browse the repository at this point in the history
Signed-off-by: Max Smythe <smythe@google.com>
  • Loading branch information
maxsmythe committed Jun 9, 2020
1 parent 5bae203 commit b745ff7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions constraint/pkg/client/crd_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func (h *crdHelper) createSchema(templ *templates.ConstraintTemplate, target Mat
}
schema := &apiextensions.JSONSchemaProps{
Properties: map[string]apiextensions.JSONSchemaProps{
"metadata": apiextensions.JSONSchemaProps{
Properties: map[string]apiextensions.JSONSchemaProps{
"name": apiextensions.JSONSchemaProps{
Type: "string",
MaxLength: func(i int64) *int64 { return &i }(63),
},
},
},
"spec": apiextensions.JSONSchemaProps{
Properties: props,
},
Expand Down
12 changes: 11 additions & 1 deletion constraint/pkg/client/crd_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ func tProp(t string) apiextensions.JSONSchemaProps {

func expectedSchema(pm propMap) *apiextensions.JSONSchemaProps {
pm["enforcementAction"] = apiextensions.JSONSchemaProps{Type: "string"}
p := prop(propMap{"spec": prop(pm)})
p := prop(
propMap{
"metadata": prop(propMap{
"name": apiextensions.JSONSchemaProps{
Type: "string",
MaxLength: func(i int64) *int64 { return &i }(63),
},
}),
"spec": prop(pm),
},
)
return &p
}

Expand Down

0 comments on commit b745ff7

Please sign in to comment.