Skip to content

Commit

Permalink
Rename option
Browse files Browse the repository at this point in the history
  • Loading branch information
aliksend committed Aug 2, 2024
1 parent c2de3a3 commit 46e5962
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ type dokkuProviderModel struct {
SshPort types.Int64 `tfsdk:"ssh_port"`
SshUser types.String `tfsdk:"ssh_user"`
SshCert types.String `tfsdk:"ssh_cert"`
SshSkipHostKeyCheck types.Bool `tfsdk:"ssh_skip_host_key_check"`
SshHostKey types.String `tfsdk:"ssh_host_key"`
LogSshCommands types.Bool `tfsdk:"log_ssh_commands"`
UploadAppName types.String `tfsdk:"upload_app_name"`
UploadSplitBytes types.Int64 `tfsdk:"upload_split_bytes"`
SkipKnownHostsCheck types.Bool `tfsdk:"skip_known_hosts_check"`
}

func (p *dokkuProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
Expand Down Expand Up @@ -93,6 +93,10 @@ func (p *dokkuProvider) Schema(ctx context.Context, req provider.SchemaRequest,
stringvalidator.LengthAtLeast(1),
},
},
"ssh_skip_host_key_check": schema.BoolAttribute{
Optional: true,
Description: "Skip the host key check. Insecure, should not be used in production. Default: false",
},
"ssh_host_key": schema.StringAttribute{
Optional: true,
Description: strings.Join([]string{
Expand Down Expand Up @@ -140,10 +144,6 @@ func (p *dokkuProvider) Schema(ctx context.Context, req provider.SchemaRequest,
int64validator.AtLeast(1),
},
},
"skip_known_hosts_check": schema.BoolAttribute{
Optional: true,
Description: "Skip the known hosts check. Default: false",
},
},
}
}
Expand Down Expand Up @@ -271,9 +271,9 @@ func (p *dokkuProvider) Configure(ctx context.Context, req provider.ConfigureReq

tflog.Debug(ctx, "ssh connection", map[string]any{"host": host, "port": port, "user": sshUsername})

skipKnownHostsCheck := false
if !config.SkipKnownHostsCheck.IsNull() {
skipKnownHostsCheck = config.SkipKnownHostsCheck.ValueBool()
skipHostKeyCheck := false
if !config.SshSkipHostKeyCheck.IsNull() {
skipHostKeyCheck = config.SshSkipHostKeyCheck.ValueBool()
}

sshConfig := &goph.Config{
Expand All @@ -284,7 +284,7 @@ func (p *dokkuProvider) Configure(ctx context.Context, req provider.ConfigureReq
Callback: verifyHost,
}

if skipKnownHostsCheck {
if skipHostKeyCheck {
sshConfig.Callback = ssh.InsecureIgnoreHostKey()
} else if !config.SshHostKey.IsNull() {
_, _, publicKey, _, _, err := ssh.ParseKnownHosts([]byte(config.SshHostKey.ValueString()))
Expand Down

0 comments on commit 46e5962

Please sign in to comment.