Some checks failed
Native Verification / Build Docs (pull_request) Successful in 1m12s
Native Verification / Build App-Service Native (pull_request) Successful in 1m27s
Native Verification / Build Daemon Native (pull_request) Successful in 42s
Lint and Test Charts / lint-test (pull_request_target) Failing after 19s
Lint and Test Charts / test-version (pull_request_target) Successful in 0s
Lint and Test Charts / push-image (pull_request_target) Failing after 15s
Lint and Test Charts / upload-cli (pull_request_target) Failing after 1m15s
Lint and Test Charts / upload-daemon (pull_request_target) Failing after 1m12s
Lint and Test Charts / push-deps (pull_request_target) Has been skipped
Lint and Test Charts / push-deps-arm64 (pull_request_target) Has been skipped
Lint and Test Charts / push-image-arm64 (pull_request_target) Has been cancelled
Lint and Test Charts / upload-package (pull_request_target) Has been cancelled
Lint and Test Charts / install-test (pull_request_target) Has been cancelled
134 lines
3.6 KiB
Go
134 lines
3.6 KiB
Go
package pipelines
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"path"
|
|
|
|
"github.com/beclab/beos/cli/pkg/core/logger"
|
|
"github.com/beclab/beos/cli/pkg/daemon"
|
|
|
|
bootstrapos "github.com/beclab/beos/cli/pkg/bootstrap/os"
|
|
"github.com/beclab/beos/cli/pkg/bootstrap/patch"
|
|
"github.com/beclab/beos/cli/pkg/common"
|
|
"github.com/beclab/beos/cli/pkg/container"
|
|
"github.com/beclab/beos/cli/pkg/core/module"
|
|
"github.com/beclab/beos/cli/pkg/core/pipeline"
|
|
"github.com/beclab/beos/cli/pkg/images"
|
|
"github.com/beclab/beos/cli/pkg/manifest"
|
|
"github.com/beclab/beos/cli/pkg/phase"
|
|
"github.com/beclab/beos/cli/pkg/phase/system"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func PrepareSystemPipeline(components []string) error {
|
|
var terminusVersion, _ = phase.GetBeOSVersion()
|
|
if terminusVersion != "" && len(components) == 0 {
|
|
return errors.New("beOS Pro is already installed; uninstall it first")
|
|
}
|
|
|
|
var arg = common.NewArgument()
|
|
arg.SetKubeVersion(viper.GetString(common.FlagKubeType))
|
|
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
|
arg.SetStorage(getStorageConfig())
|
|
arg.ClearMasterHostConfig()
|
|
|
|
runtime, err := common.NewKubeRuntime(*arg)
|
|
if err != nil {
|
|
return fmt.Errorf("error creating runtime: %w", err)
|
|
}
|
|
|
|
manifestPath := path.Join(runtime.GetInstallerDir(), "installation.manifest")
|
|
runtime.Arg.SetManifest(manifestPath)
|
|
|
|
manifestMap, err := manifest.ReadAll(manifestPath)
|
|
if err != nil {
|
|
return fmt.Errorf("error reading manifest: %w", err)
|
|
}
|
|
|
|
// if no components specified, run all
|
|
if len(components) == 0 {
|
|
var p = system.PrepareSystemPhase(runtime)
|
|
if err := p.Start(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
for _, component := range components {
|
|
switch component {
|
|
case "image", "images":
|
|
p := &pipeline.Pipeline{
|
|
Name: "Preload Container Images",
|
|
Modules: []module.Module{
|
|
&images.PreloadImagesModule{
|
|
ManifestModule: manifest.ManifestModule{
|
|
Manifest: manifestMap,
|
|
BaseDir: runtime.GetBaseDir(),
|
|
},
|
|
},
|
|
},
|
|
Runtime: runtime,
|
|
}
|
|
if err := p.Start(); err != nil {
|
|
return fmt.Errorf("error preparing images: %w", err)
|
|
}
|
|
case "olaresd", "beosd":
|
|
p := &pipeline.Pipeline{
|
|
Name: "Prepare beOS daemon",
|
|
Modules: []module.Module{
|
|
&daemon.ReplaceBeOSdBinaryModule{
|
|
ManifestModule: manifest.ManifestModule{
|
|
Manifest: manifestMap,
|
|
BaseDir: runtime.GetBaseDir(),
|
|
},
|
|
},
|
|
},
|
|
Runtime: runtime,
|
|
}
|
|
if err := p.Start(); err != nil {
|
|
return fmt.Errorf("error preparing os environment: %w", err)
|
|
}
|
|
case "os":
|
|
p := &pipeline.Pipeline{
|
|
Name: "Prepare OS environment",
|
|
Modules: []module.Module{
|
|
&bootstrapos.PvePatchModule{Skip: !runtime.GetSystemInfo().IsPveOrPveLxc()},
|
|
&patch.InstallDepsModule{
|
|
ManifestModule: manifest.ManifestModule{
|
|
Manifest: manifestMap,
|
|
BaseDir: runtime.GetBaseDir(),
|
|
},
|
|
},
|
|
&bootstrapos.ConfigSystemModule{},
|
|
},
|
|
Runtime: runtime,
|
|
}
|
|
if err := p.Start(); err != nil {
|
|
return fmt.Errorf("error preparing os environment: %w", err)
|
|
}
|
|
case "container":
|
|
p := &pipeline.Pipeline{
|
|
Name: "Install Container Runtime",
|
|
Modules: []module.Module{
|
|
&container.InstallContainerModule{
|
|
ManifestModule: manifest.ManifestModule{
|
|
Manifest: manifestMap,
|
|
BaseDir: runtime.GetBaseDir(),
|
|
},
|
|
},
|
|
},
|
|
Runtime: runtime,
|
|
}
|
|
if err := p.Start(); err != nil {
|
|
return fmt.Errorf("error setting up container runtime: %w", err)
|
|
}
|
|
default:
|
|
logger.Warnf("unkonwn component: %s", component)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|