-
Notifications
You must be signed in to change notification settings - Fork 50
/
deployment.go
54 lines (43 loc) · 1.7 KB
/
deployment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package azuretest
import (
"encoding/json"
"fmt"
"os"
"github.com/osbuild/images/cmd/osbuild-image-tests/constants"
)
// loadDeploymentTemplate loads the deployment template from the specified
// path and return it as a "dynamically" typed object
func loadDeploymentTemplate() (interface{}, error) {
f, err := os.Open(constants.TestPaths.AzureDeploymentTemplate)
if err != nil {
return nil, fmt.Errorf("cannot open the deployment file: %v", err)
}
defer f.Close()
var result interface{}
err = json.NewDecoder(f).Decode(&result)
if err != nil {
return nil, fmt.Errorf("cannot decode the deployment file: %v", err)
}
return result, nil
}
// struct for encoding a deployment parameter
type deploymentParameter struct {
Value string `json:"value"`
}
func newDeploymentParameter(value string) deploymentParameter {
return deploymentParameter{Value: value}
}
// struct for encoding deployment parameters
type DeploymentParameters struct {
NetworkInterfaceName deploymentParameter `json:"networkInterfaceName"`
NetworkSecurityGroupName deploymentParameter `json:"networkSecurityGroupName"`
VirtualNetworkName deploymentParameter `json:"virtualNetworkName"`
PublicIPAddressName deploymentParameter `json:"publicIPAddressName"`
VirtualMachineName deploymentParameter `json:"virtualMachineName"`
DiskName deploymentParameter `json:"diskName"`
ImageName deploymentParameter `json:"imageName"`
Location deploymentParameter `json:"location"`
ImagePath deploymentParameter `json:"imagePath"`
AdminUsername deploymentParameter `json:"adminUsername"`
AdminPublicKey deploymentParameter `json:"adminPublicKey"`
}