File: console.go

package info (click to toggle)
golang-github-crc-org-crc 2.34.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,548 kB
  • sloc: sh: 398; makefile: 326; javascript: 40
file content (39 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download
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
package machine

import (
	"fmt"

	"github.com/crc-org/crc/v2/pkg/crc/machine/types"
	"github.com/pkg/errors"
)

// Return console URL if the VM is present.
func (client *client) GetConsoleURL() (*types.ConsoleResult, error) {
	// Here we are only checking if the VM exist and not the status of the VM.
	// We might need to improve and use crc status logic, only
	// return if the Openshift is running as part of status.
	vm, err := loadVirtualMachine(client.name, client.useVSock())
	if err != nil {
		return nil, errors.Wrap(err, "Cannot load machine")
	}
	defer vm.Close()

	if vm.bundle.IsPodman() {
		return nil, fmt.Errorf("Only supported with OpenShift bundles")
	}

	vmState, err := vm.State()
	if err != nil {
		return nil, errors.Wrap(err, "Error getting the state for virtual machine")
	}

	clusterConfig, err := getClusterConfig(vm.bundle)
	if err != nil {
		return nil, errors.Wrap(err, "Error loading cluster configuration")
	}

	return &types.ConsoleResult{
		ClusterConfig: *clusterConfig,
		State:         vmState,
	}, nil
}