mirror of
https://github.com/drone/drone-cli.git
synced 2024-11-23 09:21:56 +01:00
fix registry encryption
This commit is contained in:
parent
24f514ea36
commit
739d6ea9e6
@ -28,6 +28,7 @@ var encryptRegistryCommand = cli.Command{
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "server",
|
Name: "server",
|
||||||
Usage: "registry server",
|
Usage: "registry server",
|
||||||
|
Value: "docker.io",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -44,20 +45,30 @@ func encryptRegistry(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
plaintext := c.Args().Get(1)
|
password := c.String("password")
|
||||||
if strings.HasPrefix(plaintext, "@") {
|
if strings.HasPrefix(password, "@") {
|
||||||
data, err := ioutil.ReadFile(plaintext)
|
data, err := ioutil.ReadFile(password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
plaintext = string(data)
|
password = string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
secret := &drone.Secret{
|
policy := "pull"
|
||||||
Data: plaintext,
|
switch {
|
||||||
Pull: c.Bool("allow-pull-request"),
|
case c.Bool("push"):
|
||||||
|
policy = "push"
|
||||||
|
case c.Bool("push-pull-request"):
|
||||||
|
policy = "push-pull-request"
|
||||||
}
|
}
|
||||||
encrypted, err := client.EncryptSecret(owner, name, secret)
|
|
||||||
|
registry := &drone.Registry{
|
||||||
|
Address: c.String("server"),
|
||||||
|
Username: c.String("username"),
|
||||||
|
Password: password,
|
||||||
|
Policy: policy,
|
||||||
|
}
|
||||||
|
encrypted, err := client.EncryptRegistry(owner, name, registry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user