Comments (13)
This way it works
but I am wondering what's the best way to support dynamic values for the labels
i.e. setting the value from a property or an env variable
from jkube.
@davidecavestro : Would it be possible for you to work on this? I'm happy to provide you code pointers if interested.
from jkube.
@davidecavestro : Could you please open a pull request with your current changes that is covering the simple scenario? Maybe we can iterate over it to add more complex expressions?
from jkube.
After some issues with GPG signature (ssh keys were not an option on this network)
I sketched #2956
I saw some issues on tests and licenses check: if they are not false positives I can look at them
from jkube.
i.e. setting the value from a property or an env variable
Not 100% sure how to do it. Maybe adding a map/property configuration option in Mojos/ Gradle tasks can help achieve this. But then maybe we would need to align that configuration option with both generators (zero configuration) and explicit image configuration.
from jkube.
I see, not sure if filter support could help someway... should investigate.
Another aspect to refine would be the escaping of commas and equals chars.
from jkube.
i.e. setting the value from a property or an env variable
I think the easiest way right now would be to control that from Maven by computing the value as a property first:
<properties>
<prop>pre</prop>
<jkube.generator.labels>${prop}-${env.ENV_PROP}</jkube.generator.labels>
<!-- ... -->
</properties>
Another aspect to refine would be the escaping of commas and equals chars.
Not sure of how we're doing that for tags now, but both features should follow the same approach for sanitizing inputs.
from jkube.
the easiest way right now would be to control that from Maven by computing the value as a property first
so I see the interpolation is done by maven both defining a property and directly using expressions such as <labels>${my.prop}=${env.GIT_COMMIT}</labels>
I expect the same would stand for gradle, but I've not checked
Not sure of how we're doing that for tags now, but both features should follow the same approach for sanitizing inputs
I see no sanitization for tags at addTagsFromConfig
OTOH EnvUtils.splitOnSpaceWithEscape could be replicated into separate methods to extract lists (tags use case) and maps (labels use case) supporting the escape of both comma chars (entries separators) and equal chars (key/value separators).
Both chars could be included into resulting data this way.
That said, it may seem too complicated, as it reduces code readability increasing complexity.
On my own I don't have yet a real-world use case for escaping.
from jkube.
so I see the interpolation is done by maven both defining a property and directly using expressions such as ${my.prop}=${env.GIT_COMMIT}
Yes, that should work too.
I expect the same would stand for gradle, but I've not checked
For Gradle it should be done differently, but would be achievable too.
What I mean, in general, is that for dynamic values instead of reinventing the wheel downstream, it's better to leverage the tools that the build system offers.
That said, it may seem too complicated, as it reduces code readability increasing complexity.
Maybe in this case (it seems to be far more complex than for tags) it's better to try and see what Docker or other tools are doing to ensure a consistent behavior.
https://docs.docker.com/config/labels-custom-metadata/#label-keys-and-values
from jkube.
Please note that the complexity of parsing and escaping separators is clearly related to the choice of setting labels via a CSV (of key value pairs).
IMHO apart from the escape of separators, there's no strong need of specific sanitization (probably enforced by underlying layers if really needed).
Also consider that in case we opt instead for shaping labels with nested config elements, we would end up with something simpler; but this approach would differ from tags one (that's why I started with the former).
That is (for maven)
<labels>foo=abc,bar=123</labels>
VS
<labels>
<foo>abc</foo>
<bar>123</bar>
</labels>
from jkube.
OK, note that we would likely want to support the label setting via configuration elements (regardless of the nesting choice), but also through the use of a property jkube.generator.labels
. That's why I was mostly concerned about the parsing and its complexity.
from jkube.
also through the use of a property
jkube.generator.labels
. That's why I was mostly concerned about the parsing and its complexity
makes sense
so given the mandate to support decoding a map from a one-liner - possibly passed from CLI - a certain degree of complexity for parsing seems acceptable to me
from jkube.
What about json?
from jkube.
Related Issues (20)
- GoTimeUtil 'duration.length() == 0' can be replaced with 'duration.isEmpty()' HOT 3
- ImageChangeTriggerEnricher 'containerToImageMap.size() != 0' can be replaced with '!containerToImageMap.isEmpty()' HOT 5
- Remove duplicate dependency from `quickstarts/maven/micronaut4` `pom.xml` HOT 1
- `KubernetesHelperTest.exportKubernetesClientConfigToFile_worksWithKubernetesMockServer` is failing on windows HOT 5
- fix failing unit tests in `gradle-plugin/openshift` module HOT 1
- org.eclipse.jkube.enricher.generic.ImageEnricher#mergeEnvVariables causes error for empty env variables
- `JibImageBuildServicePushTest` failing intermittently on Eclipse Jenkins HOT 1
- Springboot 3.3.1 breaks jkube openshift plugin HOT 6
- ImageName 'registry.length() > 0' can be replaced with '!registry.isEmpty()' HOT 1
- JKubeProjectUtil 'suffix.length() > 0' can be replaced with '!suffix.isEmpty()' HOT 2
- KubernetesResourceUtilTest 'initContainersInSpec.size() == 0' can be replaced with 'initContainersInSpec.isEmpty()' HOT 1
- MappingConfig 'filenameTypes.length() > 0' can be replaced with '!filenameTypes.isEmpty()' HOT 3
- MojoExecutionService 'goal.length() > 0' can be replaced with '!goal.isEmpty()' HOT 3
- OpenShiftBuildServiceUtils 'nocache.length() == 0' can be replaced with 'nocache.isEmpty()' HOT 3
- RegistryConfigTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 3
- JKubeConfigurationTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 3
- ControllerResourceConfigTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 4
- KubernetesSshServiceForwarderTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 1
- JibServiceUtilTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 2
- Replace `maven-failsafe-plugin`'s deprecated `systemProperties` configuration field with `systemPropertyVariables` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jkube.