Skip to content

Commit

Permalink
Merge pull request Telmate#75 from Telmate/pm_otp_prompt
Browse files Browse the repository at this point in the history
support PM_OTP_PROMPT for ondemand interactive OTP
  • Loading branch information
ggongaware committed Aug 14, 2019
2 parents 8084bb9 + 2ac1ecd commit a974251
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions proxmox/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package proxmox
import (
"crypto/tls"
"fmt"
"os"
"regexp"
"strconv"
"sync"
Expand All @@ -22,6 +23,20 @@ type providerConfiguration struct {

// Provider - Terrafrom properties for proxmox
func Provider() *schema.Provider {
pmOTPprompt := schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("PM_OTP", ""),
Description: "OTP 2FA code (if required)",
}
if os.Getenv("PM_OTP_PROMPT") == "1" {
pmOTPprompt = schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("PM_OTP", nil),
Description: "OTP 2FA code (if required)",
}
}
return &schema.Provider{

Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -54,12 +69,7 @@ func Provider() *schema.Provider {
Optional: true,
Default: false,
},
"pm_otp": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("PM_OTP", ""),
Description: "OTP 2FA code (if required)",
},
"pm_otp": &pmOTPprompt,
},

ResourcesMap: map[string]*schema.Resource{
Expand Down

0 comments on commit a974251

Please sign in to comment.