Don't use Packer context as vSphere driver context (#9576)
This commit is contained in:
parent
eb5c3c3efb
commit
5a006f226a
|
@ -44,8 +44,8 @@ type StepConnect struct {
|
|||
Config *ConnectConfig
|
||||
}
|
||||
|
||||
func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
d, err := driver.NewDriver(ctx, &driver.ConnectConfig{
|
||||
func (s *StepConnect) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
d, err := driver.NewDriver(&driver.ConnectConfig{
|
||||
VCenterServer: s.Config.VCenterServer,
|
||||
Username: s.Config.Username,
|
||||
Password: s.Config.Password,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package testing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
@ -45,7 +44,7 @@ func TestConn(t *testing.T) *driver.Driver {
|
|||
password = "jetbrains"
|
||||
}
|
||||
|
||||
d, err := driver.NewDriver(context.TODO(), &driver.ConnectConfig{
|
||||
d, err := driver.NewDriver(&driver.ConnectConfig{
|
||||
VCenterServer: "vcenter.vsphere65.test",
|
||||
Username: username,
|
||||
Password: password,
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
)
|
||||
|
||||
type Driver struct {
|
||||
// context that controls the authenticated sessions used to run the VM commands
|
||||
ctx context.Context
|
||||
client *govmomi.Client
|
||||
restClient *rest.Client
|
||||
|
@ -31,7 +32,9 @@ type ConnectConfig struct {
|
|||
Datacenter string
|
||||
}
|
||||
|
||||
func NewDriver(ctx context.Context, config *ConnectConfig) (*Driver, error) {
|
||||
func NewDriver(config *ConnectConfig) (*Driver, error) {
|
||||
ctx := context.TODO()
|
||||
|
||||
vcenterUrl, err := url.Parse(fmt.Sprintf("https://%v/sdk", config.VCenterServer))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package driver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
@ -22,7 +21,7 @@ func newTestDriver(t *testing.T) *Driver {
|
|||
password = "jetbrains"
|
||||
}
|
||||
|
||||
d, err := NewDriver(context.TODO(), &ConnectConfig{
|
||||
d, err := NewDriver(&ConnectConfig{
|
||||
VCenterServer: "vcenter.vsphere65.test",
|
||||
Username: username,
|
||||
Password: password,
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/packer/builder/vsphere/driver"
|
||||
)
|
||||
|
||||
func main() {
|
||||
d, err := driver.NewDriver(context.TODO(), &driver.ConnectConfig{
|
||||
d, err := driver.NewDriver(&driver.ConnectConfig{
|
||||
VCenterServer: "vcenter.vsphere65.test",
|
||||
Username: "root",
|
||||
Password: "jetbrains",
|
||||
|
|
Loading…
Reference in New Issue