mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-04 18:23:50 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49309bfa42 | |||
| 428642719b | |||
| 33f15bdebe | |||
| 10df8f28b9 | |||
| 17072a25f1 | |||
| 26c93eccd1 |
+12
-15
@@ -109,7 +109,7 @@ func run(c *cli.Context) error {
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: c.String("repo"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
},
|
||||
}
|
||||
@@ -117,28 +117,25 @@ func run(c *cli.Context) error {
|
||||
}
|
||||
|
||||
func setupECRAuth(accessKey, secretKey, registry string) error {
|
||||
if accessKey == "" {
|
||||
return fmt.Errorf("Access key must be specified")
|
||||
}
|
||||
if secretKey == "" {
|
||||
return fmt.Errorf("Secret key must be specified")
|
||||
}
|
||||
if registry == "" {
|
||||
return fmt.Errorf("Registry must be specified")
|
||||
}
|
||||
|
||||
err := os.Setenv(accessKeyEnv, accessKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", accessKeyEnv))
|
||||
}
|
||||
// If IAM role is used, access key & secret key are not required
|
||||
if accessKey != "" && secretKey != "" {
|
||||
err := os.Setenv(accessKeyEnv, accessKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", accessKeyEnv))
|
||||
}
|
||||
|
||||
err = os.Setenv(secretKeyEnv, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", secretKeyEnv))
|
||||
err = os.Setenv(secretKeyEnv, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", secretKeyEnv))
|
||||
}
|
||||
}
|
||||
|
||||
jsonBytes := []byte(fmt.Sprintf(`{"credStore": "ecr-login", "credHelpers": {"%s": "ecr-login"}}`, registry))
|
||||
err = ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||
err := ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create docker config file")
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
// Set the labels
|
||||
for _, label := range p.Build.Labels {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--label %s", label))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--label=%s", label))
|
||||
}
|
||||
|
||||
if p.Build.Target != "" {
|
||||
|
||||
Regular → Executable
Reference in New Issue
Block a user