Skip to content

Remove Generex dependency #6053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

andreaTP
Copy link
Member

Description

Fix #6052

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@andreaTP
Copy link
Member Author

Seems to be not used 🤞 let see if the CI confirms.

@andreaTP
Copy link
Member Author

Back to draft, but we have reproducers now.

@andreaTP andreaTP marked this pull request as draft June 14, 2024 10:49
@@ -185,8 +184,7 @@ public KubernetesList processLocally(Map<String, String> valuesMap) {
} else if (Utils.isNotNullOrEmpty(parameter.getValue())) {
parameterValue = parameter.getValue();
} else if (EXPRESSION.equals(parameter.getGenerate())) {
Generex generex = new Generex(parameter.getFrom());
parameterValue = generex.random();
parameterValue = parameter.getFrom();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not going to generate a valid template instance, at the same time:

  • generating a random string can easily lead to errors
  • the random string cannot be tracked

Alternatives are in:

  1. substitute with an alternative library, but I'm not convinced about any of those:
  2. Roll our own implementation, either as an external micro library or within this project: the code is not going to be much, but OpenShift Templates are deprecated, so, we can even deprecate/remove this feature

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This is not going to generate a valid template instance

Why is this?

  • generating a random string can easily lead to errors
  • the random string cannot be tracked

The purpose of this method is really to process locally the templates as if they were being processed by the OpenShift cluster.

It really doesn't matter if the string can't be tracked or if the random string is invalid (maybe because the provided expression is wrong).
In the end, this would be the user's responsibility.

parameters:
- description: Password used for Redis authentication
  from: '[A-Z0-9]{8}'
  generate: expression
  name: REDIS_PASSWORD

https://docs.openshift.com/container-platform/4.15/openshift_images/using-templates.html#templates-writing_using-templates

What we want is to be able to support this.

From the docs we can read the constraints for this expression:

generate specifies the generator to be used to generate random string from an input value specified by From field. The result string is stored into Value field. If empty, no generator is being used, leaving the result Value untouched. Optional.

The only supported generator is "expression", which accepts a "from" value in the form of a simple regular expression containing the range expression "[a-zA-Z0-9]", and the length expression "a{length}".

Examples:

from value
"test[0-9]{1}x" "test7x"
"[0-1]{8}" "01001100"
"0x[A-F0-9]{4}" "0xB3AF"
"[a-zA-Z0-9]{8}" "hW4yQU5i"

It seems that a simple library or maybe even rolling our own utility method should suffice to handle this.

@andreaTP andreaTP changed the title Remove unused Generex dependency Remove Generex dependency Jun 14, 2024
Copy link

@andreaTP
Copy link
Member Author

Superseded by #6060

@andreaTP andreaTP closed this Jun 18, 2024
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.

Remove no longer maintained dependency com.github.mifmif:generex
3 participants