internal/boot: introduce package for booting images
The package takes the existing code from /cmd/osbuild-image-tests and makes it available for other executables.
This commit is contained in:
parent
7e0711b805
commit
ec6ce8387d
9 changed files with 8 additions and 8 deletions
56
internal/boot/azuretest/deployment.go
Normal file
56
internal/boot/azuretest/deployment.go
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// +build integration
|
||||
|
||||
package azuretest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/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"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue