Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/auth/machineid/workloadidentityv1/expression/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ func protoMessageVariables[TMessage proto.Message, TEnv messageEnv[TMessage]](ze
}
})
case protoreflect.Uint32Kind, protoreflect.Uint64Kind:
vars[name] = typical.DynamicVariable(func(env TEnv) (uint64, error) {
vars[name] = typical.DynamicVariable(func(env TEnv) (uint, error) {
if v, err := get(env); err == nil {
return v.Uint(), nil
return uint(v.Uint()), nil
} else {
return 0, err
}
Expand Down
4 changes: 3 additions & 1 deletion lib/auth/machineid/workloadidentityv1/expression/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ func (t *Template) Render(env *Environment) (string, error) {
_, _ = b.WriteString(strconv.FormatBool(t))
case int:
_, _ = b.WriteString(strconv.Itoa(t))
case uint:
_, _ = b.WriteString(strconv.Itoa(int(t)))
default:
return "", trace.Errorf("expression did not evaluate to a string: %s", frag.text)
return "", trace.Errorf("expression did not evaluate to a string: %q, %T", frag.text, result)
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions lib/auth/machineid/workloadidentityv1/expression/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ func TestTemplate_Success(t *testing.T) {
attrs: &workloadidentityv1.Attrs{},
output: "1234",
},
"int interpolation": {
tmpl: `{{ workload.unix.pid }}`,
attrs: &workloadidentityv1.Attrs{
Workload: &workloadidentityv1.WorkloadAttrs{
Unix: &workloadidentityv1.WorkloadAttrsUnix{
Pid: 1337,
},
},
},
output: "1337",
},
"uint interpolation": {
tmpl: `{{ workload.unix.uid }}`,
attrs: &workloadidentityv1.Attrs{
Workload: &workloadidentityv1.WorkloadAttrs{
Unix: &workloadidentityv1.WorkloadAttrsUnix{
Uid: 1337,
},
},
},
output: "1337",
},
"user traits": {
tmpl: `{{user.traits.skill}}`,
attrs: &workloadidentityv1.Attrs{
Expand Down
Loading