mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-21 15:20:02 -05:00
feat: add parameter for SSH options (#335)
This commit is contained in:
parent
3fbe7d3a34
commit
24336bc89f
4 changed files with 24 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
* add container storage opts ([#258](https://github.com/kreuzwerker/terraform-provider-docker/issues/258))
|
* add container storage opts ([#258](https://github.com/kreuzwerker/terraform-provider-docker/issues/258))
|
||||||
|
* add ssh_opts parameter to provider config. Allows passing additional ssh arguments when connecting via ssh. ([#29](https://github.com/kreuzwerker/terraform-provider-docker/issues/29))
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
* add current timestamp for file upload to container ([#259](https://github.com/kreuzwerker/terraform-provider-docker/issues/259))
|
* add current timestamp for file upload to container ([#259](https://github.com/kreuzwerker/terraform-provider-docker/issues/259))
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ The configuration would look as follows:
|
||||||
```terraform
|
```terraform
|
||||||
provider "docker" {
|
provider "docker" {
|
||||||
host = "ssh://user@remote-host:22"
|
host = "ssh://user@remote-host:22"
|
||||||
|
ssh_opts = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
// Docker API compatible host.
|
// Docker API compatible host.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Host string
|
Host string
|
||||||
|
SSHOpts []string
|
||||||
Ca string
|
Ca string
|
||||||
Cert string
|
Cert string
|
||||||
Key string
|
Key string
|
||||||
|
|
@ -118,7 +119,7 @@ func (c *Config) NewClient() (*client.Client, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no cert information, then check for ssh://
|
// If there is no cert information, then check for ssh://
|
||||||
helper, err := connhelper.GetConnectionHelper(c.Host)
|
helper, err := connhelper.GetConnectionHelperWithSSHOpts(c.Host, c.SSHOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,19 @@ func New(version string) func() *schema.Provider {
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"),
|
DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"),
|
||||||
Description: "The Docker daemon address",
|
Description: "The Docker daemon address",
|
||||||
},
|
},
|
||||||
|
"ssh_opts": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
|
DefaultFunc: func() (interface{}, error) {
|
||||||
|
if v := os.Getenv("DOCKER_SSH_OPTS"); v != "" {
|
||||||
|
return strings.Fields(v), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
Description: "Addtional SSH option flags to be appended when using ssh:// protocol",
|
||||||
|
},
|
||||||
"ca_material": {
|
"ca_material": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|
@ -146,8 +158,14 @@ func New(version string) func() *schema.Provider {
|
||||||
|
|
||||||
func configure(version string, p *schema.Provider) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
func configure(version string, p *schema.Provider) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
||||||
return func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
return func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
||||||
|
SSHOptsI := d.Get("ssh_opts").([]interface{})
|
||||||
|
SSHOpts := make([]string, len(SSHOptsI))
|
||||||
|
for i, s := range SSHOptsI {
|
||||||
|
SSHOpts[i] = s.(string)
|
||||||
|
}
|
||||||
config := Config{
|
config := Config{
|
||||||
Host: d.Get("host").(string),
|
Host: d.Get("host").(string),
|
||||||
|
SSHOpts: SSHOpts,
|
||||||
Ca: d.Get("ca_material").(string),
|
Ca: d.Get("ca_material").(string),
|
||||||
Cert: d.Get("cert_material").(string),
|
Cert: d.Get("cert_material").(string),
|
||||||
Key: d.Get("key_material").(string),
|
Key: d.Get("key_material").(string),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue