dr

package
v0.1.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const CascTemplateString = `` /* 250-byte string literal not displayed */
View Source
const RunScript = `` /* 321-byte string literal not displayed */
View Source
const SolutionsListPermissionsError = `` /* 364-byte string literal not displayed */

SolutionsListPermissionsError is the permissions error printed by the doctor check.

Variables

View Source
var ActionChecks = []Check{

	NewCmdActionCheck("setting clock on podman machine", PodmanMachineExists(), UpdatePodmanMachineDate()),
}
View Source
var AllConfigChecks = []Check{
	NewConfigCheck("backstage.api.url", "", Static("https://catalog.techzone.ibm.com")),

	NewConfigCheck("techzone.api.url", "", Static("https://api.techzone.ibm.com/api")),
	NewConfigCheck("reservations.api.path", "", Static("my/reservations/all")),
	NewConfigCheck("reservation.api.path", "", Static("reservation/ibmcloud-2")),

	NewConfigCheck("execute.workspace.ocpinstaller", "", IifStatic(Linux, DefaultOCPInstallerLinuxConfig, DefaultOCPInstallerConfig)),
	NewConfigCheck("execute.workspace.pipelinecreator", "", IifStatic(Linux, DefaultPipelineConfigLinuxConfig, DefaultPipelineCreatorConfig)),
}

AllConfigChecks checks for configuration values on the system and defines defaulters for fixing the missing values if the user specifies --auto-fix.

View Source
var DefaultOCPInstallerConfig = &pkg.ServiceConfig{
	Name:  "ocp-installer",
	Local: true,
	Type:  "interactive",
	Image: "quay.io/ibmtz/ocpinstaller:stable",
	Volumes: []string{
		strings.Join([]string{filepath.Join(pkg.MustITZHomeDir(), "save"), "/usr/src/ocpnow/save"}, ":"),
	},
}
View Source
var DefaultOCPInstallerLinuxConfig = &pkg.ServiceConfig{
	Name:  "ocp-installer",
	Local: true,
	Type:  "interactive",
	Image: "quay.io/ibmtz/ocpinstaller:stable",
	Volumes: []string{
		strings.Join([]string{filepath.Join(pkg.MustITZHomeDir(), "save"), "/usr/src/ocpnow/save", "Z"}, ":"),
	},
}
View Source
var DefaultPipelineConfigLinuxConfig = &pkg.ServiceConfig{
	Name:  "pipeline-creator",
	Local: true,
	Type:  "interactive",
	Image: "quay.io/ibmtz/pipeline-creator:main",
	Volumes: []string{
		strings.Join([]string{filepath.Join(pkg.MustITZHomeDir(), "projects"), "/workspace", "Z"}, ":"),
	},
}
View Source
var DefaultPipelineCreatorConfig = &pkg.ServiceConfig{
	Name:  "pipeline-creator",
	Local: true,
	Type:  "interactive",
	Image: "quay.io/ibmtz/pipeline-creator:main",
	Volumes: []string{
		strings.Join([]string{filepath.Join(pkg.MustITZHomeDir(), "projects"), "/workspace"}, ":"),
	},
}
View Source
var FileChecks = []Check{

	NewReqConfigDirCheck("save"),
	NewReqConfigDirCheck("build_home"),
	NewReqConfigDirCheck("cache"),
	NewReqConfigDirCheck("projects"),

	NewFixableConfigFileCheck("cli-config.yaml", EmptyFileCreator),
	NewResourceFileCheck(OneExistsOnPath("podman", "docker"), "%s was not found on your path", UpdateConfig("podman.path")),
}

FileChecks defines the checks that are done for files on the system.

Functions

func CreateDir

func CreateDir(name string) (string, error)

CreateDir creates a directory if it does not exist

func DoChecks

func DoChecks(checks []Check, tryFix bool) []error

DoChecks performs the configured file checks and return a list of errors, if any, while checking for the files. If fix is set to true, then the file or directory is created if it can be.

func EmptyFileCreator

func EmptyFileCreator(path string) (string, error)

func Linux added in v0.1.26

func Linux() bool

Linux returns true if the current system is a Linux system.

Types

type ActionCheck added in v0.1.24

type ActionCheck struct {
	Message  string
	PreCheck PreChecker
	Cmd      ActionRunner
}

ActionCheck is

func (*ActionCheck) DoCheck added in v0.1.24

func (c *ActionCheck) DoCheck(tryFix bool) (string, error)

type ActionRunner added in v0.1.24

type ActionRunner func() (string, error)

func UpdatePodmanMachineDate added in v0.1.24

func UpdatePodmanMachineDate() ActionRunner

UpdatePodmanMachineDate updates the date on the podman machine to be the current date on the host.

type Check

type Check interface {
	DoCheck(tryFix bool) (string, error)
}

Check interface for itz doctor checks

func NewCmdActionCheck added in v0.1.24

func NewCmdActionCheck(msg string, preCheck PreChecker, cmd ActionRunner) Check

func NewConfigCheck

func NewConfigCheck(configKey string, help string, defaulter DefaultGetter) Check

NewConfigCheck creates a new ConfigCheck for the given key.

func NewConfigFileCheck

func NewConfigFileCheck(name string) Check

NewConfigFileCheck checks for files inside the ITZ home directory

func NewFixableConfigFileCheck

func NewFixableConfigFileCheck(name string, fixFunc FileAutoFixFunc) Check

func NewReqConfigDirCheck

func NewReqConfigDirCheck(name string) Check

NewReqConfigDirCheck checks for directories inside the ITZ home directory

func NewResourceFileCheck

func NewResourceFileCheck(c CheckerFunc, help string, f FileAutoFixFunc) Check

NewResourceFileCheck checks for any files, using the OS's PATH variable automatically as the path.

type CheckerFunc

type CheckerFunc func() (string, string, bool)

func ExistsOnPath

func ExistsOnPath(name string) CheckerFunc

ExistsOnPath checks if a binary file exists on the path, using the OS's PATH variable automatically as the path.

func OneExistsOnPath

func OneExistsOnPath(names ...string) CheckerFunc

OneExistsOnPath checks if one of the binary files in a list exists on the path, using the OS's PATH variable automatically as the path. It returns the first path that exists.

type ConfigCheck

type ConfigCheck struct {
	ConfigKey string
	Defaulter DefaultGetter
	Help      string
}

ConfigCheck a check for configuration

func (*ConfigCheck) DoCheck

func (c *ConfigCheck) DoCheck(tryFix bool) (string, error)

DoCheck performs a check of the configuration value and returns the value of the configuration, if it exists, with no error. If the configuration value does not exist

func (*ConfigCheck) String

func (c *ConfigCheck) String() string

String provides a human-readable version of the config check

type DefaultGetter

type DefaultGetter func() interface{}

DefaultGetter provides a function type for handling default values of the configuration.

func ConfigDir

func ConfigDir(value interface{}) DefaultGetter

ConfigDir returns the static value for the default.

func IifStatic added in v0.1.26

func IifStatic(iif func() bool, tVal interface{}, fVal interface{}) DefaultGetter

func Messager

func Messager(value interface{}) DefaultGetter

Messager asks the user a question and returns the answer to the getter.

func NoDefault

func NoDefault() DefaultGetter

NoDefault returns a default with no value.

func Prompter

func Prompter(value interface{}) DefaultGetter

Prompter asks the user a question and returns the answer to the getter.

func RandomVal

func RandomVal(value interface{}) DefaultGetter

RandomVal returns a random string value for the default.

func ServiceURL

func ServiceURL(scheme string, port int) DefaultGetter

ServiceURL returns the static value for the default.

func Static

func Static(value interface{}) DefaultGetter

Static returns the static value for the default.

type FileAutoFixFunc

type FileAutoFixFunc func(path string) (string, error)

func TemplatedFileCreator

func TemplatedFileCreator(template string) FileAutoFixFunc

func UpdateConfig

func UpdateConfig(configPath string) FileAutoFixFunc

func UpdateConfigIfMissing

func UpdateConfigIfMissing(configPath string) FileAutoFixFunc

type FileCheck

type FileCheck struct {
	PathCheckFunc CheckerFunc
	Path          string
	Name          string
	IsDir         bool
	Help          string
	FixerFunc     FileAutoFixFunc
	UpdaterFunc   FileAutoFixFunc
}

FileCheck is a check for a required file

func (*FileCheck) DoCheck

func (f *FileCheck) DoCheck(tryFix bool) (string, error)

DoCheck performs a file check and returns the name of the file, if it exists, with no error or returns a nil string with an error if the file does not exist.

func (*FileCheck) String

func (f *FileCheck) String() string

String provides for readable logging

type PodmanMachine added in v0.1.24

type PodmanMachine struct {
	MachineState string
}

type PreChecker added in v0.1.24

type PreChecker func() bool

func PodmanMachineExists added in v0.1.24

func PodmanMachineExists() PreChecker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL