Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavmpandey08 committed Jun 14, 2022
1 parent be81fa7 commit fed3ea3
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 65 deletions.
9 changes: 0 additions & 9 deletions pkg/executables/config/deploy-opts.json

This file was deleted.

39 changes: 35 additions & 4 deletions pkg/executables/govc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ const (
vSpherePasswordKey = "EKSA_VSPHERE_PASSWORD"
vSphereServerKey = "VSPHERE_SERVER"
byteToGiB = 1073741824.0
deployOptsFile = "deploy-opts.json"
DeployOptsFile = "deploy-opts.json"
)

var requiredEnvs = []string{govcUsernameKey, govcPasswordKey, govcURLKey, govcInsecure}

//go:embed config/deploy-opts.json
var deployOpts string
type NetworkMapping struct {
Name string
Network string
}

type DeployOption struct {
DiskProvisioning string
NetworkMapping []NetworkMapping
}

type FolderType string

Expand Down Expand Up @@ -354,7 +361,12 @@ func (g *Govc) deployTemplate(ctx context.Context, library, templateName, deploy
templateInLibraryPath = fmt.Sprintf("/%s", templateInLibraryPath)
}

deployOptsPath, err := g.writer.Write(deployOptsFile, []byte(fmt.Sprintf(deployOpts, network)), filewriter.PersistentFile)
deployOpts, err := GetDeployOptions(network)
if err != nil {
return err
}

deployOptsPath, err := g.writer.Write(DeployOptsFile, deployOpts, filewriter.PersistentFile)
if err != nil {
return fmt.Errorf("failed writing deploy options file to disk: %v", err)
}
Expand Down Expand Up @@ -897,3 +909,22 @@ func (g *Govc) createCategory(ctx context.Context, name string, objectTypes []ob
}
return nil
}

func GetDeployOptions(network string) ([]byte, error) {
deployOptsStruct := DeployOption{
DiskProvisioning: "thin",
NetworkMapping: []NetworkMapping{
{
Name: "nic0",
Network: network,
},
},
}

deployOpts, err := json.Marshal(deployOptsStruct)
if err != nil {
return nil, fmt.Errorf("marshalling template deployment options: %v", err)
}

return deployOpts, err
}
Loading

0 comments on commit fed3ea3

Please sign in to comment.