Skip to content

Commit

Permalink
Add validation of name length for naisjobs
Browse files Browse the repository at this point in the history
Co-authored-by: Trong Huu Nguyen <[email protected]>
Co-authored-by: Christer Edvartsen <[email protected]>
  • Loading branch information
3 people committed Dec 16, 2024
1 parent b6b740f commit 87471bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions charts/templates/nais.io_naisjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,9 @@ spec:
required:
- spec
type: object
x-kubernetes-validations:
- message: metadata.name must be no more than 63 characters
rule: self.metadata.name.size() <= 63
served: true
storage: true
subresources: {}
3 changes: 3 additions & 0 deletions config/crd/bases/nais.io_naisjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,9 @@ spec:
required:
- spec
type: object
x-kubernetes-validations:
- message: metadata.name must be no more than 63 characters
rule: self.metadata.name.size() <= 63
served: true
storage: true
subresources: {}
3 changes: 2 additions & 1 deletion pkg/apis/nais.io/v1/naisjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func init() {
// +kubebuilder:printcolumn:name="Team",type="string",JSONPath=".metadata.labels.team"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.synchronizationState"
// +kubebuilder:resource:path="naisjobs",shortName="nj",singular="naisjob"
// +kubebuilder:validation:XValidation:rule="self.metadata.name.size() <= 63", message="metadata.name must be no more than 63 characters"
type Naisjob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -314,4 +315,4 @@ func (in *Naisjob) SkipDeploymentMessage() bool {

func (in *Naisjob) ClientID(cluster string) string {
return fmt.Sprintf("%s:%s:%s", cluster, in.ObjectMeta.Namespace, in.ObjectMeta.Name)
}
}

0 comments on commit 87471bb

Please sign in to comment.