mirror of https://github.com/portainer/portainer
fix(libcompose): fix an issue with TLS enabled endpoints (#2071)
parent
4de83f793f
commit
1cf77bf9e9
|
@ -27,17 +27,27 @@ func NewComposeStackManager(dataPath string) *ComposeStackManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createClient(endpoint *portainer.Endpoint) (client.Factory, error) {
|
||||||
|
clientOpts := client.Options{
|
||||||
|
Host: endpoint.URL,
|
||||||
|
APIVersion: portainer.SupportedDockerAPIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
if endpoint.TLSConfig.TLS {
|
||||||
|
clientOpts.TLS = endpoint.TLSConfig.TLS
|
||||||
|
clientOpts.TLSVerify = !endpoint.TLSConfig.TLSSkipVerify
|
||||||
|
clientOpts.TLSCAFile = endpoint.TLSConfig.TLSCACertPath
|
||||||
|
clientOpts.TLSCertFile = endpoint.TLSConfig.TLSCertPath
|
||||||
|
clientOpts.TLSKeyFile = endpoint.TLSConfig.TLSKeyPath
|
||||||
|
}
|
||||||
|
|
||||||
|
return client.NewDefaultFactory(clientOpts)
|
||||||
|
}
|
||||||
|
|
||||||
// Up will deploy a compose stack (equivalent of docker-compose up)
|
// Up will deploy a compose stack (equivalent of docker-compose up)
|
||||||
func (manager *ComposeStackManager) Up(stack *portainer.Stack, endpoint *portainer.Endpoint) error {
|
func (manager *ComposeStackManager) Up(stack *portainer.Stack, endpoint *portainer.Endpoint) error {
|
||||||
clientFactory, err := client.NewDefaultFactory(client.Options{
|
|
||||||
TLS: endpoint.TLSConfig.TLS,
|
clientFactory, err := createClient(endpoint)
|
||||||
TLSVerify: endpoint.TLSConfig.TLSSkipVerify,
|
|
||||||
Host: endpoint.URL,
|
|
||||||
TLSCAFile: endpoint.TLSCACertPath,
|
|
||||||
TLSCertFile: endpoint.TLSCertPath,
|
|
||||||
TLSKeyFile: endpoint.TLSKeyPath,
|
|
||||||
APIVersion: portainer.SupportedDockerAPIVersion,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -75,15 +85,7 @@ func (manager *ComposeStackManager) Up(stack *portainer.Stack, endpoint *portain
|
||||||
|
|
||||||
// Down will shutdown a compose stack (equivalent of docker-compose down)
|
// Down will shutdown a compose stack (equivalent of docker-compose down)
|
||||||
func (manager *ComposeStackManager) Down(stack *portainer.Stack, endpoint *portainer.Endpoint) error {
|
func (manager *ComposeStackManager) Down(stack *portainer.Stack, endpoint *portainer.Endpoint) error {
|
||||||
clientFactory, err := client.NewDefaultFactory(client.Options{
|
clientFactory, err := createClient(endpoint)
|
||||||
TLS: endpoint.TLSConfig.TLS,
|
|
||||||
TLSVerify: endpoint.TLSConfig.TLSSkipVerify,
|
|
||||||
Host: endpoint.URL,
|
|
||||||
TLSCAFile: endpoint.TLSCACertPath,
|
|
||||||
TLSCertFile: endpoint.TLSCertPath,
|
|
||||||
TLSKeyFile: endpoint.TLSKeyPath,
|
|
||||||
APIVersion: portainer.SupportedDockerAPIVersion,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue