-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for FlatcarContainerLinux (#221)
* Provide string constant functions through dedicated interface Using a dedicated interface enables distro-specific structs to 'override' functions returning string constants such as config folders or paths. * Create path for k0s binary if it does not already exists * Add support for FlatcarContainerLinux * Rename struct holding path functions for linux * Add test for linux path functions Co-authored-by: Kimmo Lehto <[email protected]>
- Loading branch information
Showing
17 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package linux | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/k0sproject/k0sctl/configurer" | ||
"github.com/k0sproject/rig" | ||
"github.com/k0sproject/rig/os" | ||
"github.com/k0sproject/rig/os/registry" | ||
) | ||
|
||
type Flatcar struct { | ||
BaseLinux | ||
os.Linux | ||
} | ||
|
||
func init() { | ||
registry.RegisterOSModule( | ||
func(os rig.OSVersion) bool { | ||
return os.ID == "flatcar" | ||
}, | ||
func() interface{} { | ||
linuxType := &Flatcar{} | ||
linuxType.PathFuncs = interface{}(linuxType).(configurer.PathFuncs) | ||
return linuxType | ||
}, | ||
) | ||
} | ||
|
||
func (l Flatcar) InstallPackage(h os.Host, pkg ...string) error { | ||
return errors.New("FlatcarContainerLinux does not support installing packages manually") | ||
} | ||
|
||
func (l Flatcar) K0sBinaryPath() string { | ||
return "/opt/bin/k0s" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package linux | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/k0sproject/k0sctl/configurer" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestPaths tests the slightly weird way to perform function overloading | ||
func TestPaths(t *testing.T) { | ||
fc := &Flatcar{} | ||
fc.PathFuncs = interface{}(fc).(configurer.PathFuncs) | ||
|
||
ubuntu := &Ubuntu{} | ||
ubuntu.PathFuncs = interface{}(ubuntu).(configurer.PathFuncs) | ||
|
||
require.Equal(t, "/opt/bin/k0s", fc.K0sBinaryPath()) | ||
require.Equal(t, "/usr/local/bin/k0s", ubuntu.K0sBinaryPath()) | ||
|
||
require.Equal(t, "/opt/bin/k0s --help", fc.K0sCmdf("--help")) | ||
require.Equal(t, "/usr/local/bin/k0s --help", ubuntu.K0sCmdf("--help")) | ||
|
||
require.Equal(t, "/var/lib/k0s/pki/admin.conf", fc.KubeconfigPath()) | ||
require.Equal(t, "/var/lib/k0s/pki/admin.conf", ubuntu.KubeconfigPath()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters