Skip to content

Commit

Permalink
CoreOS support (#309)
Browse files Browse the repository at this point in the history
* supportos: fedora and rhel coreOS

* fix: add errors import to configurer/linux/coreos
  • Loading branch information
kaplan-michael committed Sep 9, 2022
1 parent 8eda284 commit 0cbfc47
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
37 changes: 37 additions & 0 deletions configurer/linux/coreos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package linux

import (
"errors"
"github.com/k0sproject/k0sctl/configurer"
"github.com/k0sproject/rig"
"github.com/k0sproject/rig/os"
"github.com/k0sproject/rig/os/registry"
"strings"
)

// CoreOS provides OS support for ostree based Fedora & RHEL systems
type CoreOS struct {
os.Linux
BaseLinux
}

func init() {
registry.RegisterOSModule(
func(os rig.OSVersion) bool {
return os.ID == "fedora" && strings.Contains(os.Name, "CoreOS") || os.ID == "rhel" && strings.Contains(os.Name, "CoreOS")
},
func() interface{} {
linuxType := &CoreOS{}
linuxType.PathFuncs = interface{}(linuxType).(configurer.PathFuncs)
return linuxType
},
)
}

func (l CoreOS) InstallPackage(h os.Host, pkg ...string) error {
return errors.New("CoreOS does not support installing packages manually")
}

func (l CoreOS) K0sBinaryPath() string {
return "/opt/bin/k0s"
}
3 changes: 2 additions & 1 deletion configurer/linux/enterpriselinux/fedora.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
k0slinux "github.com/k0sproject/k0sctl/configurer/linux"
"github.com/k0sproject/rig"
"github.com/k0sproject/rig/os/registry"
"strings"
)

// Fedora provides OS support for Fedora
Expand All @@ -16,7 +17,7 @@ type Fedora struct {
func init() {
registry.RegisterOSModule(
func(os rig.OSVersion) bool {
return os.ID == "fedora"
return os.ID == "fedora" && !strings.Contains(os.Name, "CoreOS")
},
func() interface{} {
linuxType := &Fedora{}
Expand Down
3 changes: 2 additions & 1 deletion configurer/linux/enterpriselinux/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
k0slinux "github.com/k0sproject/k0sctl/configurer/linux"
"github.com/k0sproject/rig"
"github.com/k0sproject/rig/os/registry"
"strings"
)

// RHEL provides OS support for RedHat Enterprise Linux
Expand All @@ -15,7 +16,7 @@ type RHEL struct {
func init() {
registry.RegisterOSModule(
func(os rig.OSVersion) bool {
return os.ID == "rhel"
return os.ID == "rhel" && !strings.Contains(os.Name, "CoreOS")
},
func() interface{} {
linuxType := &RHEL{}
Expand Down

0 comments on commit 0cbfc47

Please sign in to comment.