Skip to content

Initial test #1

@gbraad

Description

@gbraad
package main

import (
    "fmt"
    "github.com/crc-org/macadam/pkg/machine"
    "github.com/crc-org/macadam/pkg/vmconfigs"
    "github.com/machinefile/machinefile/executor"
)

func main() {
    // Create/init and start VM
    vmName := "fedora-output"
    baseImage := "fedora-cloud.qcow2"
    macadamVM, err := machine.InitVM(vmName, baseImage, /*...options*/)
    if err != nil {
        panic(err)
    }
    err = macadamVM.Start()
    if err != nil {
        panic(err)
    }

    // Extract SSH config
    sshConfig := macadamVM.SSH // type: vmconfigs.SSHConfig

    // Use machinefile executor
    mf := executor.New(machinefilePath)
    err = mf.RunOverSSH(sshConfig.RemoteUsername, "localhost", sshConfig.Port, sshConfig.IdentityPath)
    if err != nil {
        panic(err)
    }

    fmt.Println("VM built and provisioned successfully!")
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions