Compare commits

...

1 Commits

Author SHA1 Message Date
Shubham Agrawal af93afae8c Add support for custom platform 2021-12-01 17:08:49 +05:30
4 changed files with 23 additions and 0 deletions
+6
View File
@@ -145,6 +145,11 @@ func main() {
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.", Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY", EnvVar: "PLUGIN_VERBOSITY",
}, },
cli.StringFlag{
Name: "platform",
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
EnvVar: "PLUGIN_PLATFORM",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
@@ -181,6 +186,7 @@ func run(c *cli.Context) error {
DigestFile: defaultDigestFile, DigestFile: defaultDigestFile,
NoPush: noPush, NoPush: noPush,
Verbosity: c.String("verbosity"), Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
}, },
Artifact: kaniko.Artifact{ Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"), Tags: c.StringSlice("tags"),
+6
View File
@@ -174,6 +174,11 @@ func main() {
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.", Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY", EnvVar: "PLUGIN_VERBOSITY",
}, },
cli.StringFlag{
Name: "platform",
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
EnvVar: "PLUGIN_PLATFORM",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
@@ -252,6 +257,7 @@ func run(c *cli.Context) error {
DigestFile: defaultDigestFile, DigestFile: defaultDigestFile,
NoPush: noPush, NoPush: noPush,
Verbosity: c.String("verbosity"), Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
}, },
Artifact: kaniko.Artifact{ Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"), Tags: c.StringSlice("tags"),
+6
View File
@@ -130,6 +130,11 @@ func main() {
Usage: "Set this flag as --verbosity=<panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.", Usage: "Set this flag as --verbosity=<panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY", EnvVar: "PLUGIN_VERBOSITY",
}, },
cli.StringFlag{
Name: "platform",
Usage: "Allows to build with another default platform than the host, similarly to docker build --platform",
EnvVar: "PLUGIN_PLATFORM",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
@@ -167,6 +172,7 @@ func run(c *cli.Context) error {
DigestFile: defaultDigestFile, DigestFile: defaultDigestFile,
NoPush: noPush, NoPush: noPush,
Verbosity: c.String("verbosity"), Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
}, },
Artifact: kaniko.Artifact{ Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"), Tags: c.StringSlice("tags"),
+5
View File
@@ -30,6 +30,7 @@ type (
DigestFile string // Digest file location DigestFile string // Digest file location
NoPush bool // Set this flag if you only want to build the image, without pushing to a registry NoPush bool // Set this flag if you only want to build the image, without pushing to a registry
Verbosity string // Log level Verbosity string // Log level
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
} }
// Artifact defines content of artifact file // Artifact defines content of artifact file
@@ -157,6 +158,10 @@ func (p Plugin) Exec() error {
cmdArgs = append(cmdArgs, fmt.Sprintf("--verbosity=%s", p.Build.Verbosity)) cmdArgs = append(cmdArgs, fmt.Sprintf("--verbosity=%s", p.Build.Verbosity))
} }
if p.Build.Platform != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--customPlatform=%s", p.Build.Platform))
}
cmd := exec.Command("/kaniko/executor", cmdArgs...) cmd := exec.Command("/kaniko/executor", cmdArgs...)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr