Skip to content

Commit

Permalink
fix with parameters to update values
Browse files Browse the repository at this point in the history
  • Loading branch information
Devtools committed Jan 26, 2025
1 parent 033039b commit ab66034
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
3 changes: 1 addition & 2 deletions test/e2e/parallel/nstemplatetier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ func TestTierTemplateRevision(t *testing.T) {
// when
// we update a parameter in the NSTemplateTier
// by increasing the deployment quota
customTier.NSTemplateTier.Spec.Parameters = []toolchainv1alpha1.Parameter{{Name: "DEPLOYMENT_QUOTA", Value: "100"}}
customTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, customTier)
customTier = tiers.UpdateCustomNSTemplateTier(t, hostAwait, customTier, tiers.WithParameter("DEPLOYMENT_QUOTA", "100"))
require.NoError(t, err)

// then
Expand Down
28 changes: 22 additions & 6 deletions testsupport/tiers/tier_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,28 @@ func WithParameter(name, value string) CustomNSTemplateTierModifier {
if tier.Spec.Parameters == nil {
tier.Spec.Parameters = []toolchainv1alpha1.Parameter{}
}
tier.Spec.Parameters = append(tier.Spec.Parameters,
toolchainv1alpha1.Parameter{
Name: name,
Value: value,
},
)

newParams := make([]toolchainv1alpha1.Parameter, len(tier.Spec.Parameters))
// search for the param, in case it already exists, we need only to change its value
found := false
for _, param := range tier.Spec.Parameters {
if param.Name == name {
// if the param already exists, let's set the new value
param.Value = value
found = true
}
newParams = append(newParams, param)

Check failure on line 99 in testsupport/tiers/tier_setup.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

append to slice `newParams` with non-zero initialized length (makezero)
}
// if it's a new parameter, let's append it to the existing ones
if !found {
newParams = append(newParams,

Check failure on line 103 in testsupport/tiers/tier_setup.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

append to slice `newParams` with non-zero initialized length (makezero)
toolchainv1alpha1.Parameter{
Name: name,
Value: value,
},
)
}
tier.Spec.Parameters = newParams
return nil
}
}
Expand Down

0 comments on commit ab66034

Please sign in to comment.