|
@ -5,6 +5,7 @@ import ( |
|
|
"os" |
|
|
"os" |
|
|
"os/exec" |
|
|
"os/exec" |
|
|
"strings" |
|
|
"strings" |
|
|
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
|
"github.com/drone/drone-plugin-go/plugin" |
|
|
"github.com/drone/drone-plugin-go/plugin" |
|
|
) |
|
|
) |
|
@ -18,6 +19,7 @@ type terraform struct { |
|
|
type remote struct { |
|
|
type remote struct { |
|
|
Backend string `json:"backend"` |
|
|
Backend string `json:"backend"` |
|
|
Config map[string]string `json:"config"` |
|
|
Config map[string]string `json:"config"` |
|
|
|
|
|
Cacert string `json:"ca_cert"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
@ -31,6 +33,9 @@ func main() { |
|
|
|
|
|
|
|
|
var commands []*exec.Cmd |
|
|
var commands []*exec.Cmd |
|
|
remote := vargs.Remote |
|
|
remote := vargs.Remote |
|
|
|
|
|
if remote.Cacert != "" { |
|
|
|
|
|
commands = append(commands, installCaCert(remote.Cacert)) |
|
|
|
|
|
} |
|
|
if remote.Backend != "" { |
|
|
if remote.Backend != "" { |
|
|
commands = append(commands, remoteConfigCommand(remote)) |
|
|
commands = append(commands, remoteConfigCommand(remote)) |
|
|
} |
|
|
} |
|
@ -57,6 +62,13 @@ func main() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func installCaCert(cacert string) *exec.Cmd { |
|
|
|
|
|
ioutil.WriteFile("/usr/local/share/ca-certificates/ca_cert.crt", []byte(cacert), 0644) |
|
|
|
|
|
return exec.Command( |
|
|
|
|
|
"update-ca-certificates", |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func remoteConfigCommand(config remote) *exec.Cmd { |
|
|
func remoteConfigCommand(config remote) *exec.Cmd { |
|
|
args := []string{ |
|
|
args := []string{ |
|
|
"remote", |
|
|
"remote", |
|
|