Jkube: helm goal configuration appends ${project.artifactId} to home and sources

Created on 24 Aug 2020  路  6Comments  路  Source: eclipse/jkube

Description

Documentation says:

home: The Chart URL for this project鈥檚 home page, which is ${project.url} if not provided.
sources: The Chart list of URLs to source code for this project, defaults to the list of ${project.scm.url} if not provided.

But reality is that home is set to: ${project.url}/${project.artifactId} and sources to ${project.scm.url}/${project.artifactId}

Info

  • Eclipse JKube version : 1.0.0-rc-1
  • Maven version (mvn -v) : 3.6.3
documentation

Most helpful comment

thanks @manusa for looking into this behaviour. Then it would be great to have some note about this (multi module project) in documentation.

All 6 comments

Hi @hlavki

I can't seem to reproduce your issue and apparently code looks well.

Tried the following in quickstarts/maven/spring-boot-helm
```shell script
$ mvn k8s:resource k8s:helm -Pkubernetes

$ cat target/jkube/helm/spring-boot-helm/kubernetes/Chart.yaml

name: spring-boot-helm
home: https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/spring-boot-helm
sources:

And for verification:
```shell script
$ mvn help:evaluate -Dexpression=project.url -q -DforceStdout 
https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/spring-boot-helm
$ mvn help:evaluate -Dexpression=project.scm -q -DforceStdout 
<scm>
  <tag>HEAD</tag>
  <url>https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/spring-boot-helm</url>
  <urlLocation>
    <lineNumber>25</lineNumber>
    <columnNumber>10</columnNumber>
    <source>
      <modelId>org.springframework.boot:spring-boot-dependencies:2.2.7.RELEASE</modelId>
      <location>/home/user/.m2/repository/org/springframework/boot/spring-boot-dependencies/2.2.7.RELEASE/spring-boot-dependencies-2.2.7.RELEASE.pom</location>
    </source>
  </urlLocation>
</scm>

Both values match.

Do you have a reproducer project we can check?

thanks @manusa for feedback. I think it occurs only in multi-module maven project. Of course I'll create reproducer project asap.

@manusa, prepared sample project https://github.com/hlavki/jkube-363

Chart.yaml after build is:

---
name: jkube-boot-multimodule-assembly
home: https://jkube.example.com/jkube-boot-multimodule-assembly
sources:
- https://github.com/hlavki/jkube-363/jkube-boot-multimodule-assembly
version: 1.0-SNAPSHOT
description: 'JKube #363'
maintainers:
- name: John Nhoj
  email: [email protected]

but ${project.url} is set to: https://jkube.example.com
also ${project.scm.url} is set to: https://github.com/hlavki/jkube-363

Ok, I see the problem now.

The thing is that HelmMojo is reading the values according to the assembly submodule project since k8s:helm is executed in the scope of that project:

shell script $ mvn help:evaluate -Dexpression=project.url -q -DforceStdout https://jkube.example.com $ cd assembly ./assembly/ $ mvn help:evaluate -Dexpression=project.url -q -DforceStdout https://jkube.example.com/jkube-boot-multimodule-assembly

I don't particularly see this as a JKube specific bug.

Solution 1

The first and easiest fix would be to complete your helm configuration:

<helm>
    <description>JKube #363</description>
    <home>https://jkube.example.com</home>
    <sources>
        <source>https://github.com/hlavki/jkube-363</source>
    </sources>
    <maintainers>
        <maintainer>
            <name>John Nhoj</name>
            <email>[email protected]</email>
        </maintainer>
    </maintainers>
</helm>

Solution 2

Maybe even with variables defined in the parent pom.xml

<properties>
    <java.version>11</java.version>
    <helm.home>${project.parent.url}</helm.home>
    <helm.source>${project.parent.scm.url}</helm.source>
</properties>

And configuration referencing those variables in assembly/pom.xml

<helm>
    <description>JKube #363</description>
    <home>${helm.home}</home>
    <sources>
        <source>${helm.source}</source>
    </sources>
    <maintainers>
        <maintainer>
            <name>John Nhoj</name>
            <email>[email protected]</email>
        </maintainer>
    </maintainers>
</helm>

Solution 3

Configure inheritance for URL and SCM elements as stated in MNG-6059 (requires newer Maven versions):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         child.project.url.inherit.append.path="false"
         >
<!-- ... -->
    <url>https://jkube.example.com</url>
    <scm child.scm.url.inherit.append.path="false">
        <connection>scm:git:ssh://[email protected]:hlavki/jkube-363.git</connection>
        <url>https://github.com/hlavki/jkube-363</url>
        <tag>HEAD</tag>
    </scm>
<!-- ... -->
</project>

All of the provided solutions will output the following Chart.yaml, just pick the one that suits you better :wink::

---
name: jkube-boot-multimodule-assembly
home: https://jkube.example.com
sources:
- https://github.com/hlavki/jkube-363
version: 1.0-SNAPSHOT
description: 'JKube #363'
maintainers:
- name: John Nhoj
  email: [email protected]

See also

thanks @manusa for looking into this behaviour. Then it would be great to have some note about this (multi module project) in documentation.

Was this page helpful?
0 / 5 - 0 ratings