-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validation for Labels on Fleet and GS Template #1257
Conversation
Build Succeeded 👏 Build Id: 3a3c2e98-e767-4776-b082-e2f9b8a715e7 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
@aLekSer - is this ready for review or are you still working on it? |
Code is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you added the validation.go and validation_test.go files in the vendor_fixes directory. I diff'd them against what was vendored in and they seemed identical.
pkg/apis/agones/v1/common.go
Outdated
func validateGSSpec(gs gsSpec) []metav1.StatusCause { | ||
gsSpec := gs.GetGameServerSpec() | ||
gsSpec.ApplyDefaults() | ||
causes, _ := gsSpec.Validate("") | ||
|
||
return causes | ||
} | ||
|
||
// validateObjectMeta Check ObjectMeta specification | ||
// Used by Fleet, GameServerSet and Gameserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: GameServer (match case with elsewhere)
@@ -389,8 +389,12 @@ func (gss GameServerSpec) Validate(devAddress string) ([]metav1.StatusCause, boo | |||
}) | |||
} | |||
} | |||
return causes, len(causes) == 0 | |||
objMetaCauses := validateObjectMeta(gss.Template.ObjectMeta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the changes to this file (and gameserverset.go) have unit tests akin to what you added in fleet_test.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added similar test for gameserver .
test/e2e/fleet_test.go
Outdated
for i := 0; i < nameLen; i++ { | ||
key[i] = 'f' | ||
} | ||
flt.Spec.Template.ObjectMeta.Labels["label"] = string(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to just do
flt.Spec.Template.ObjectMeta.Labels["label"] = strings.Repeat("f", validation.LabelValueMaxLength + 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, applying this to all connected code parts
pkg/apis/agones/v1/fleet_test.go
Outdated
for i := 0; i < nameLen; i++ { | ||
key[i] = 'f' | ||
} | ||
f.Spec.Template.ObjectMeta.Labels["label"] = string(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to just do f.Spec.Template.ObjectMeta.Labels["label"] = strings.Repeat("f", validation.LabelValueMaxLength + 1)
test/e2e/fleet_test.go
Outdated
assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[0].Type) | ||
goodFlt := defaultFleet(defaultNs) | ||
goodFlt.Spec.Template.ObjectMeta.Labels = make(map[string]string) | ||
goodFlt.Spec.Template.ObjectMeta.Labels["label"] = string(key[0 : nameLen-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goodFlt.Spec.Template.ObjectMeta.Labels["label"] = strings.Repeat("f", validation.LabelValueMaxLength)
It seems that I did not configure local go properly.
|
951ee33
to
882aee5
Compare
Build Succeeded 👏 Build Id: 4eb39e22-af92-4c05-b623-3c37f4d887d3 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Now ObjectMeta in a Fleet Template and GameServerSpec Template are validated, as well as for GameServerSet Template field.
882aee5
to
3443da6
Compare
Removed unnecessary duplicate files out of |
Build Succeeded 👏 Build Id: d56975cd-5161-46b5-b221-706fe894f766 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aLekSer, roberthbailey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Now ObjectMeta in a Fleet Template and GameServerSpec Template are validated, as well as for GameServerSet Template field.
Now ObjectMeta Labels part in a Fleet Template and GameServerSpec Template are
validated, as well as for GameServerSet Template field.
Closes #1244 .