mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-20 22:59:42 -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
|
||||
* 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
|
||||
* add current timestamp for file upload to container ([#259](https://github.com/kreuzwerker/terraform-provider-docker/issues/259))
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ The configuration would look as follows:
|
|||
|
||||
```terraform
|
||||
provider "docker" {
|
||||
host = "ssh://user@remote-host:22"
|
||||
host = "ssh://user@remote-host:22"
|
||||
ssh_opts = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"]
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -178,4 +179,4 @@ Optional:
|
|||
- **config_file** (String) Path to docker json file for registry auth
|
||||
- **config_file_content** (String) Plain content of the docker json file for registry auth
|
||||
- **password** (String, Sensitive) Password for the registry
|
||||
- **username** (String) Username for the registry
|
||||
- **username** (String) Username for the registry
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
// Docker API compatible host.
|
||||
type Config struct {
|
||||
Host string
|
||||
SSHOpts []string
|
||||
Ca string
|
||||
Cert string
|
||||
Key string
|
||||
|
|
@ -118,7 +119,7 @@ func (c *Config) NewClient() (*client.Client, error) {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,19 @@ func New(version string) func() *schema.Provider {
|
|||
DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"),
|
||||
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": {
|
||||
Type: schema.TypeString,
|
||||
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) {
|
||||
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{
|
||||
Host: d.Get("host").(string),
|
||||
SSHOpts: SSHOpts,
|
||||
Ca: d.Get("ca_material").(string),
|
||||
Cert: d.Get("cert_material").(string),
|
||||
Key: d.Get("key_material").(string),
|
||||
|
|
|
|||
Loading…
Reference in a new issue