Skip to content

Add NewRule constructor to secret package#714

Merged
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
zzzeek:add-newrule-constructor
Jul 13, 2026
Merged

Add NewRule constructor to secret package#714
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
zzzeek:add-newrule-constructor

Conversation

@zzzeek

@zzzeek zzzeek commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

we're looking to move this code to use lib-common:

https://github.com/openstack-k8s-operators/mariadb-operator/blob/66665ea51eed2025f566351a2aabd82b2f049fac/internal/controller/mariadbaccount_controller.go#L761-L785

however we need to be able to create a rule with that character whitelist.

Rule has unexported fields so external packages cannot construct one
directly. NewRule provides the standard Go constructor pattern, allowing
callers outside this package to build custom Requirements and Rejects
rules for PasswordValidator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@zzzeek
zzzeek requested review from dciabrin and fmount July 8, 2026 14:50
@zzzeek

zzzeek commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

there's another way to go here if we prefer, and it's to add a built-in rule that does the character whitelist we have which is allowedSpecialChars := "@#%^*-_=+:,.!~". this is the character list we've decided is "safe" for a database password that would be in an ALTER USER statement.

@fmount

fmount commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

there's another way to go here if we prefer, and it's to add a built-in rule that does the character whitelist we have which is allowedSpecialChars := "@#%^*-_=+:,.!~". this is the character list we've decided is "safe" for a database password that would be in an ALTER USER statement.

Hi @zzzeek sorry for being late here. The original idea was to have a set of common rules that might have been applied to all the operators. If this pattern applies to all services, I'm good w/ a generic/static rule.
I also see we might have per-service patterns based on the purpose of each component, so I'm not against exposing a NewRule that customizes the behavior to meet a given component expectations.

Based on the above (and your tests) we can land this one or add the pattern to the built-in rule.

@stuggi stuggi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@stuggi
stuggi merged commit ee669d5 into openstack-k8s-operators:main Jul 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants