Skip to content

Commit 66e6a23

Browse files
committed
Expose Configurer, add interface checks
1 parent e36b2b8 commit 66e6a23

File tree

19 files changed

+107
-58
lines changed

19 files changed

+107
-58
lines changed

configurer/interface.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package configurer
2+
3+
import (
4+
"time"
5+
6+
"github.com/k0sproject/rig/exec"
7+
"github.com/k0sproject/rig/os"
8+
)
9+
10+
// Configurer defines the per-host operations required for managing a host.
11+
type Configurer interface {
12+
Kind() string
13+
OSKind() string
14+
CheckPrivilege(os.Host) error
15+
StartService(os.Host, string) error
16+
StopService(os.Host, string) error
17+
RestartService(os.Host, string) error
18+
ServiceIsRunning(os.Host, string) bool
19+
Arch(os.Host) (string, error)
20+
K0sCmdf(string, ...interface{}) string
21+
K0sBinaryPath() string
22+
K0sConfigPath() string
23+
DataDirDefaultPath() string
24+
K0sJoinTokenPath() string
25+
WriteFile(os.Host, string, string, string) error
26+
UpdateEnvironment(os.Host, map[string]string) error
27+
DaemonReload(os.Host) error
28+
ReplaceK0sTokenPath(os.Host, string) error
29+
ServiceScriptPath(os.Host, string) (string, error)
30+
ReadFile(os.Host, string) (string, error)
31+
FileExist(os.Host, string) bool
32+
Chmod(os.Host, string, string, ...exec.Option) error
33+
Chown(os.Host, string, string, ...exec.Option) error
34+
DownloadURL(os.Host, string, string, ...exec.Option) error
35+
InstallPackage(os.Host, ...string) error
36+
FileContains(os.Host, string, string) bool
37+
MoveFile(os.Host, string, string) error
38+
MkDir(os.Host, string, ...exec.Option) error
39+
DeleteFile(os.Host, string) error
40+
CommandExist(os.Host, string) bool
41+
Hostname(os.Host) string
42+
KubectlCmdf(os.Host, string, string, ...interface{}) string
43+
KubeconfigPath(os.Host, string) string
44+
IsContainer(os.Host) bool
45+
FixContainer(os.Host) error
46+
HTTPStatus(os.Host, string) (int, error)
47+
PrivateInterface(os.Host) (string, error)
48+
PrivateAddress(os.Host, string, string) (string, error)
49+
TempDir(os.Host) (string, error)
50+
TempFile(os.Host) (string, error)
51+
UpdateServiceEnvironment(os.Host, string, map[string]string) error
52+
CleanupServiceEnvironment(os.Host, string) error
53+
Stat(os.Host, string, ...exec.Option) (*os.FileInfo, error)
54+
DeleteDir(os.Host, string, ...exec.Option) error
55+
K0sctlLockFilePath(os.Host) string
56+
UpsertFile(os.Host, string, string) error
57+
MachineID(os.Host) (string, error)
58+
SetPath(string, string)
59+
SystemTime(os.Host) (time.Time, error)
60+
Touch(os.Host, string, time.Time, ...exec.Option) error
61+
}

configurer/linux/alpine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type Alpine struct {
2121
BaseLinux
2222
}
2323

24+
var _ configurer.Configurer = (*Alpine)(nil)
25+
2426
func init() {
2527
registry.RegisterOSModule(
2628
func(os rig.OSVersion) bool {

configurer/linux/archlinux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Archlinux struct {
1313
configurer.Linux
1414
}
1515

16+
var _ configurer.Configurer = (*Archlinux)(nil)
17+
1618
func init() {
1719
registry.RegisterOSModule(
1820
func(os rig.OSVersion) bool {

configurer/linux/coreos.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"strings"
66

7+
"github.com/k0sproject/k0sctl/configurer"
78
"github.com/k0sproject/rig"
89
"github.com/k0sproject/rig/os"
910
"github.com/k0sproject/rig/os/registry"
@@ -15,6 +16,8 @@ type CoreOS struct {
1516
BaseLinux
1617
}
1718

19+
var _ configurer.Configurer = (*CoreOS)(nil)
20+
1821
func init() {
1922
registry.RegisterOSModule(
2023
func(os rig.OSVersion) bool {

configurer/linux/debian.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Debian struct {
1313
configurer.Linux
1414
}
1515

16+
var _ configurer.Configurer = (*Debian)(nil)
17+
1618
func init() {
1719
registry.RegisterOSModule(
1820
func(os rig.OSVersion) bool {

configurer/linux/enterpriselinux/almalinux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type AlmaLinux struct {
1313
configurer.Linux
1414
}
1515

16+
var _ configurer.Configurer = (*AlmaLinux)(nil)
17+
1618
func init() {
1719
registry.RegisterOSModule(
1820
func(os rig.OSVersion) bool {

configurer/linux/enterpriselinux/amazon.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type AmazonLinux struct {
1414
configurer.Linux
1515
}
1616

17+
var _ configurer.Configurer = (*AmazonLinux)(nil)
18+
1719
// Hostname on amazon linux will return the full hostname
1820
func (l *AmazonLinux) Hostname(h os.Host) string {
1921
hostname, _ := h.ExecOutput("hostname")

configurer/linux/enterpriselinux/centos.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type CentOS struct {
1313
configurer.Linux
1414
}
1515

16+
var _ configurer.Configurer = (*CentOS)(nil)
17+
1618
func init() {
1719
registry.RegisterOSModule(
1820
func(os rig.OSVersion) bool {

configurer/linux/enterpriselinux/fedora.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type Fedora struct {
1515
configurer.Linux
1616
}
1717

18+
var _ configurer.Configurer = (*Fedora)(nil)
19+
1820
func init() {
1921
registry.RegisterOSModule(
2022
func(os rig.OSVersion) bool {

configurer/linux/enterpriselinux/oracle.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type OracleLinux struct {
1313
configurer.Linux
1414
}
1515

16+
var _ configurer.Configurer = (*OracleLinux)(nil)
17+
1618
func init() {
1719
registry.RegisterOSModule(
1820
func(os rig.OSVersion) bool {

0 commit comments

Comments
 (0)