Skip to content
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

Maven properties in image name not replaced (Zero-Config mode) #1858

Closed
kuhhpid opened this issue Oct 18, 2022 · 3 comments · Fixed by #1913
Closed

Maven properties in image name not replaced (Zero-Config mode) #1858

kuhhpid opened this issue Oct 18, 2022 · 3 comments · Fixed by #1913
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kuhhpid
Copy link

kuhhpid commented Oct 18, 2022

Describe the bug

In a Zero-Config mode it is currently not possible to use ${git.commit.id.abbrev} in the jkube.generator.name property or other properties defined by the git-commit-id-plugin. @rohanKanojia made the assumption that https://github.com/eclipse/jkube/blob/master/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/helper/ImageNameFormatter.java does not handle this.

Here is the public demo project to reproduce this issue: https://github.com/kuhhpid/jkube-git-commit-id

Eclipse JKube version

1.9.1

Component

Kubernetes Maven Plugin

Apache Maven version

No response

Gradle version

No response

Steps to reproduce

  1. git clone https://github.com/kuhhpid/jkube-git-commit-id
  2. cd jkube-git-commit-id
  3. run mvn package
  4. See described error that ${git.commit.id.abbrev} was not replaced and violates the validation pattern

Expected behavior

The property ${git.commit.id.abbrev} should be replaced with the current git commit id abbrev.

Runtime

other (please specify in additional context)

Kubernetes API Server version

1.24.1

Environment

Linux

Eclipse JKube Logs

[INFO] ----------------< eu.awag.examples:jkube-git-commit-id >----------------
[INFO] Building jkube-git-commit-id 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- git-commit-id-plugin:4.9.10:revision (default) @ jkube-git-commit-id ---
[INFO] 
...
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.9.1:resource (default) @ jkube-git-commit-id ---
[INFO] k8s: Running generator wildfly-jar
[INFO] k8s: wildfly-jar: Using Docker image quay.io/jkube/jkube-java:0.0.16 as base / builder
[INFO] k8s: Using resource templates from /home/alexander/IdeaProjects/jkube-git-commit-id/src/main/jkube
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.168 s
[INFO] Finished at: 2022-10-18T08:51:47+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.9.1:resource (default) on project jkube-git-commit-id: Execution default of goal org.eclipse.jkube:kubernetes-maven-plugin:1.9.1:resource failed: Given Docker name 'registry.gitlab.com/myproject/myrepo/mycontainer:${git.commit.id.abbrev}' is invalid:
[ERROR]    * tag part '${git.commit.id.abbrev}' doesn't match allowed pattern '^[\w][\w.-]{0,127}$'

Sample Reproducer Project

https://github.com/kuhhpid/jkube-git-commit-id

Additional context

My Kubernates flavor is microk8s (https://microk8s.io)

@kuhhpid kuhhpid added the bug Something isn't working label Oct 18, 2022
@kuhhpid
Copy link
Author

kuhhpid commented Oct 18, 2022

I tried to reproduce the fact that ${project.version} is correctly replaced in org.eclipse.jkube.kit.build.service.docker.helperImageNameFormatterTest and enhanced the tag test, but it fails:

assertThat(formatter.format("%g/%a:${project.version}")).isEqualTo("fabric8/docker-maven-plugin:1.2.3-SNAPSHOT");

For me this looks like it have to be another part in the code which do this replacement.

@manusa
Copy link
Member

manusa commented Oct 19, 2022

Might be related to #697

@manusa manusa moved this to Planned in Eclipse JKube Nov 2, 2022
@rohanKanojia rohanKanojia self-assigned this Nov 15, 2022
@rohanKanojia rohanKanojia moved this from Planned to In Progress in Eclipse JKube Nov 15, 2022
@rohanKanojia
Copy link
Member

It's slightly different from #697 . In #697, maven-related properties were not getting replaced. In this case author is setting property via git-commit-id-plugin and is available in project.getProperties()

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 15, 2022
…eclipse-jkube#1858)

Interpolate image name while formatting in ImageNameFormatter.

Signed-off-by: Rohan Kumar <[email protected]>
@rohanKanojia rohanKanojia moved this from In Progress to Review in Eclipse JKube Nov 16, 2022
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 25, 2022
…eclipse-jkube#1858)

Interpolate image name while formatting in ImageNameFormatter.

Signed-off-by: Rohan Kumar <[email protected]>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Dec 8, 2022
…eclipse-jkube#1858)

Interpolate image name while formatting in ImageNameFormatter.

Signed-off-by: Rohan Kumar <[email protected]>
@manusa manusa added this to the 1.11.0 milestone Dec 14, 2022
manusa pushed a commit that referenced this issue Dec 14, 2022
…#1858)

Interpolate image name while formatting in ImageNameFormatter.

Signed-off-by: Rohan Kumar <[email protected]>
Repository owner moved this from Review to Done in Eclipse JKube Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants