mirror of https://github.com/docker/cli.git
Add the CACert parameter to the ExternalCA object in order to match
swarmkit's API type. Make sure this parameter gets propagated to swarmkit, and also add an extra option to the CLI when providing external CAs to parse the CA cert from a file. Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
6665c9c747
commit
81f87595fe
|
@ -2,7 +2,9 @@ package swarm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -154,6 +156,15 @@ func parseExternalCA(caSpec string) (*swarm.ExternalCA, error) {
|
||||||
case "url":
|
case "url":
|
||||||
hasURL = true
|
hasURL = true
|
||||||
externalCA.URL = value
|
externalCA.URL = value
|
||||||
|
case "cacert":
|
||||||
|
cacontents, err := ioutil.ReadFile(value)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "unable to read CA cert for external CA")
|
||||||
|
}
|
||||||
|
if pemBlock, _ := pem.Decode(cacontents); pemBlock == nil {
|
||||||
|
return nil, errors.New("CA cert for external CA must be in PEM format")
|
||||||
|
}
|
||||||
|
externalCA.CACert = string(cacontents)
|
||||||
default:
|
default:
|
||||||
externalCA.Options[key] = value
|
externalCA.Options[key] = value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue