-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add the possibility to give secret to buildx build (#1798)
Signed-off-by: Kevin Leturc <[email protected]>
- Loading branch information
1 parent
e980189
commit dc7a0d7
Showing
11 changed files
with
259 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.fabric8.dmp.itests</groupId> | ||
<artifactId>dmp-it-parent</artifactId> | ||
<version>0.45-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dmp-it-buildx-dockerfile-secret</artifactId> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<configuration> | ||
<images> | ||
<image> | ||
<name>dmp/alpine:${project.version}</name> | ||
<build> | ||
<dockerFile>${project.basedir}/src/main/docker/Dockerfile</dockerFile> | ||
<buildx> | ||
<secret> | ||
<envs> | ||
<myEnvVar>something</myEnvVar> | ||
</envs> | ||
<files> | ||
<myFile>${project.basedir}/../README.md</myFile> | ||
</files> | ||
</secret> | ||
</buildx> | ||
</build> | ||
</image> | ||
</images> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>default</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<phase>package</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM alpine | ||
|
||
RUN --mount=type=secret,id=myEnvVar cat /run/secrets/myEnvVar | ||
RUN --mount=type=secret,id=myFile cat /run/secrets/myFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/io/fabric8/maven/docker/config/SecretConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.fabric8.maven.docker.config; | ||
|
||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
/** | ||
* @since 15/07/24 | ||
*/ | ||
public class SecretConfiguration implements Serializable { | ||
|
||
@Parameter | ||
private Map<String, String> envs; | ||
|
||
@Parameter | ||
private Map<String, String> files; | ||
|
||
public Map<String, String> getEnvs() { | ||
return envs; | ||
} | ||
|
||
public Map<String, String> getFiles() { | ||
return files; | ||
} | ||
|
||
public static class Builder { | ||
|
||
private final SecretConfiguration config = new SecretConfiguration(); | ||
private boolean isEmpty = true; | ||
|
||
public SecretConfiguration build() { | ||
return isEmpty ? null : config; | ||
} | ||
|
||
public SecretConfiguration.Builder envs(Map<String, String> envs) { | ||
config.envs = envs; | ||
if (envs != null && !envs.isEmpty()) { | ||
isEmpty = false; | ||
} | ||
return this; | ||
} | ||
|
||
public SecretConfiguration.Builder files(Map<String, String> files) { | ||
config.files = files; | ||
if (files != null && !files.isEmpty()) { | ||
isEmpty = false; | ||
} | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.