summaryrefslogtreecommitdiff
path: root/sd_login/machined_machine.go
diff options
context:
space:
mode:
Diffstat (limited to 'sd_login/machined_machine.go')
-rw-r--r--sd_login/machined_machine.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/sd_login/machined_machine.go b/sd_login/machined_machine.go
index d89eaad..f9fb771 100644
--- a/sd_login/machined_machine.go
+++ b/sd_login/machined_machine.go
@@ -21,12 +21,11 @@ import (
"golang.org/x/sys/unix"
)
-// A Machine is a name representing a locally running container or
+// A MachineName is a name representing a locally running container or
// virtual machine that is registerd with (systemd-)machined.
-type Machine string
+type MachineName string
-// isValid returns whether the Machine name is valid.
-func (m Machine) isValid() bool {
+func (m MachineName) isValid() bool {
if len(m) > host_name_max {
// Note that Linux HOST_NAME_MAX is 64, but DNS allows
// 255, so names from DNS might be invalid.
@@ -59,18 +58,18 @@ func (m Machine) isValid() bool {
// GetMachines returns a list of currently running containers/virtual
// machines.
-func GetMachines() ([]Machine, error) {
+func GetMachines() ([]MachineName, error) {
strs, err := get_files_in_directory("/run/systemd/machines/")
if err != nil {
return nil, err
}
- var machines []Machine
+ var machines []MachineName
for _, str := range strs {
- machine := Machine(str)
+ machine := MachineName(str)
if strings.HasPrefix(str, "unit:") || machine.isValid() {
continue
}
- machines = append(machines, Machine(str))
+ machines = append(machines, machine)
}
return machines, nil
}
@@ -78,7 +77,7 @@ func GetMachines() ([]Machine, error) {
// GetClass returns the class of a locally running machine. The class
// is either "vm" or "container", depending on if the machine is an
// virtual machine or a container.
-func (m Machine) GetClass() (string, error) {
+func (m MachineName) GetClass() (string, error) {
if !m.isValid() {
return "", unix.EINVAL
}
@@ -96,7 +95,7 @@ func (m Machine) GetClass() (string, error) {
// GetIfIndices returns the numeric indices of the network interfaces
// on the host that are pointing toward this machine.
-func (m Machine) GetIfIndices() ([]int, error) {
+func (m MachineName) GetIfIndices() ([]int, error) {
if !m.isValid() {
return nil, unix.EINVAL
}