Skip to content

Commit 5915fe7

Browse files
authored
fix(policies): support camelcase in input names (#1490)
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
1 parent c78afb8 commit 5915fe7

File tree

4 files changed

+90
-90
lines changed

4 files changed

+90
-90
lines changed

app/controlplane/api/workflowcontract/v1/crafting_schema.pb.go

Lines changed: 82 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/workflowcontract/v1/crafting_schema.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ message PolicyInput {
240240
// NOTE: validations can not be shared yet https://github.com/bufbuild/protovalidate/issues/51
241241
cel: {
242242
message: "must contain only lowercase letters, numbers, and hyphens."
243-
expression: "this.matches('^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')"
244-
id: "name.dns-1123"
243+
expression: "this.matches('^[a-zA-Z][a-zA-Z0-9_]*$')"
244+
id: "name.go_map_variable"
245245
}
246246
}];
247247
string description = 2;

pkg/policies/policy_groups_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,17 @@ func (s *groupsTestSuite) TestGroupInputs() {
264264
}{
265265
{
266266
name: "group inputs with interpolation, default values",
267-
args: map[string]string{"username": "devel"},
267+
args: map[string]string{"user_name": "devel"},
268268
wanted: "the email is: devel@chainloop.dev",
269269
},
270270
{
271271
name: "missing username input",
272272
wantErr: true,
273-
errMsg: "missing required input \"username\"",
273+
errMsg: "missing required input \"user_name\"",
274274
},
275275
{
276276
name: "group inputs with interpolation, all values",
277-
args: map[string]string{"username": "foo", "domain": "bar.com"},
277+
args: map[string]string{"user_name": "foo", "domainName": "bar.com"},
278278
wanted: "the email is: foo@bar.com",
279279
},
280280
}

pkg/policies/testdata/group_with_inputs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ metadata:
77
category: test
88
spec:
99
inputs:
10-
- name: username
10+
- name: user_name
1111
required: true
12-
- name: domain
12+
- name: domainName
1313
required: false
1414
default: "chainloop.dev"
1515
policies:
@@ -19,5 +19,5 @@ spec:
1919
policies:
2020
- ref: file://testdata/policy_with_inputs.yaml
2121
with:
22-
email: "{{inputs.username}}@{{inputs.domain}}"
22+
email: "{{inputs.user_name}}@{{inputs.domainName}}"
2323

0 commit comments

Comments
 (0)