wmedvede commented on code in PR #2763:
URL:
https://github.com/apache/incubator-kie-tools/pull/2763#discussion_r1919812411
##########
packages/sonataflow-operator/workflowproj/workflowproj.go:
##########
@@ -338,3 +406,18 @@ func isProfile(workflow *operatorapi.SonataFlow,
profileType metadata.ProfileTyp
}
return metadata.ProfileType(profile) == profileType
}
+
+func normalizeEnvName(name string) (string, error) {
+ name = strings.TrimSpace(name)
+
+ replacer := strings.NewReplacer(" ", "_", "-", "_", ".", "_")
+ name = replacer.Replace(name)
+ name = strings.ToUpper(name)
+
+ validName := regexp.MustCompile(`^[A-Z0-9_]+$`)
+ if !validName.MatchString(name) || name == "_" {
+ return "", fmt.Errorf("invalid environment variable name: %s
(must only contain A-Z, 0-9, and _)", name)
Review Comment:
I think it could be helpful for future error tracing, to print which was the
original property name, and which was the resulting normalized env var name.
Also I believe there are property name cases not covered by the algorithm,
example:
quarkus."myProperty".value
should be normalized into:
QUARKUS__MYPROPERTY__VALUE
Double check please, I think it's a potential valid use cases with quarkus
properties.
see: https://quarkus.io/guides/config-reference#environment-variables
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]