cli

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOrganization = "workspace"
)

Variables

View Source
var CmdApp = &cobra.Command{
	Use:           "app",
	Aliases:       []string{"apps"},
	Short:         "Epinio application features",
	Long:          `Manage epinio application`,
	Args:          cobra.ExactArgs(0),
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdApp implements the epinio -app command

View Source
var CmdAppList = &cobra.Command{
	Use:   "list",
	Short: "Lists all applications",
	Args:  cobra.ExactArgs(0),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.Apps()
		if err != nil {
			return errors.Wrap(err, "error listing apps")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdAppList implements the epinio `apps list` command

View Source
var CmdAppShow = &cobra.Command{
	Use:   "show NAME",
	Short: "Describe the named application",
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())

		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.AppShow(args[0])
		if err != nil {
			return errors.Wrap(err, "error listing apps")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.AppsMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdAppShow implements the epinio `apps show` command

View Source
var CmdCompletion = &cobra.Command{
	Use:   "completion [bash|zsh|fish|powershell]",
	Short: "Generate completion script for a shell",
	Long: `To load completions:

Bash:

$ source <(epinio completion bash)

# To load completions for each session, execute once:
Linux:
  $ epinio completion bash > /etc/bash_completion.d/epinio
MacOS:
  $ epinio completion bash > /usr/local/etc/bash_completion.d/epinio

ATTENTION:
    The generated script requires the bash-completion package.
    See https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion
    for information on how to install and activate it.

Zsh:

# If shell completion is not already enabled in your environment you will need
# to enable it.  You can execute the following once:

$ echo "autoload -U compinit; compinit" >> ~/.zshrc

# To load completions for each session, execute once:
$ epinio completion zsh > "${fpath[1]}/_epinio"

# You will need to start a new shell for this setup to take effect.

Fish:

$ epinio completion fish | source

# To load completions for each session, execute once:
$ epinio completion fish > ~/.config/fish/completions/epinio.fish

Powershell:

PS> epinio completion powershell | Out-String | Invoke-Expression

# To load completions for every new session, run:
PS> epinio completion powershell > epinio.ps1
# and source this file from your powershell profile.
`,
	DisableFlagsInUseLine: true,
	ValidArgs:             []string{"bash", "zsh", "fish", "powershell"},
	Args:                  cobra.ExactValidArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		switch args[0] {
		case "bash":
			cmd.Root().GenBashCompletion(os.Stdout)
		case "zsh":
			cmd.Root().GenZshCompletion(os.Stdout)
		case "fish":
			cmd.Root().GenFishCompletion(os.Stdout, true)
		case "powershell":
			cmd.Root().GenPowerShellCompletion(os.Stdout)
		}
	},
}

CmdCompletion represents the completion command

View Source
var CmdDeleteApp = &cobra.Command{
	Use:   "delete NAME",
	Short: "Deletes an application",
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.Delete(args[0])
		if err != nil {
			return errors.Wrap(err, "error deleting app")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}
		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.AppsMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdDeleteApp implements the epinio delete command

View Source
var CmdDisable = &cobra.Command{
	Use:           "disable",
	Short:         "disable Epinio features",
	Long:          `disable Epinio features which where enabled with "epinio enable"`,
	Args:          cobra.ExactArgs(0),
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdDisableGoogle = &cobra.Command{
	Use:           "services-google",
	Short:         "disable Google Cloud service in Epinio",
	Long:          `disable Google Cloud services in Epinio which will disable the provisioning of those services. Doesn't delete already provisioned services by default.`,
	Args:          cobra.ExactArgs(0),
	RunE:          DisableGoogle,
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdDisableInCluster = &cobra.Command{
	Use:           "services-incluster",
	Short:         "disable in-cluster services in Epinio",
	Long:          `disable in-cluster services in Epinio which will disable provisioning services on the same cluster as Epinio. Doesn't delete already provisioned services by default.`,
	Args:          cobra.ExactArgs(0),
	RunE:          DisableInCluster,
	SilenceErrors: true,
	SilenceUsage:  true,
}

TODO: Implement a flag to also delete provisioned services [TBD]

View Source
var CmdEnable = &cobra.Command{
	Use:           "enable",
	Short:         "enable Epinio features",
	Long:          `enable Epinio features that are not enabled by default`,
	Args:          cobra.ExactArgs(0),
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdEnableGoogle = &cobra.Command{
	Use:           "services-google",
	Short:         "enable Google Cloud services in Epinio",
	Long:          `enable Google Cloud services in Epinio which allows provisioning those kind of services.`,
	Args:          cobra.ExactArgs(0),
	RunE:          EnableGoogle,
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdEnableInCluster = &cobra.Command{
	Use:           "services-incluster",
	Short:         "enable in-cluster services in Epinio",
	Long:          `enable in-cluster services in Epinio which allows provisioning services which run on the same cluster as Epinio. Should be used mostly for development.`,
	Args:          cobra.ExactArgs(0),
	RunE:          EnableInCluster,
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdInfo = &cobra.Command{
	Use:   "info",
	Short: "Shows information about the Epinio environment",
	Long:  `Shows status and version for Kubernetes, Gitea, Tekton, Quarks and Eirini.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.Info()
		if err != nil {
			return errors.Wrap(err, "error retrieving Epinio environment information")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdInfo implements the epinio info command

View Source
var CmdInstall = &cobra.Command{
	Use:           "install",
	Short:         "install Epinio in your configured kubernetes cluster",
	Long:          `install Epinio PaaS in your configured kubernetes cluster`,
	Args:          cobra.ExactArgs(0),
	RunE:          Install,
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var CmdOrg = &cobra.Command{
	Use:           "org",
	Aliases:       []string{"orgs"},
	Short:         "Epinio organizations",
	Long:          `Manage epinio organizations`,
	Args:          cobra.ExactArgs(0),
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdOrg implements the epinio -app command

View Source
var CmdOrgCreate = &cobra.Command{
	Use:   "create NAME",
	Short: "Creates an organization",
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.CreateOrg(args[0])
		if err != nil {
			return errors.Wrap(err, "error creating org")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdOrgCreate implements the epinio `orgs create` command

View Source
var CmdOrgList = &cobra.Command{
	Use:   "list",
	Short: "Lists all organizations",
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		err = client.Orgs()
		if err != nil {
			return errors.Wrap(err, "error listing orgs")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdOrgs implements the epinio `orgs list` command

View Source
var CmdPush = &cobra.Command{
	Use:   "push NAME [PATH_TO_APPLICATION_SOURCES]",
	Short: "Push an application from the specified directory, or the current working directory",
	Args:  cobra.RangeArgs(1, 2),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		var path string
		if len(args) == 1 {
			path, err = os.Getwd()
			if err != nil {
				return errors.Wrap(err, "error pushing app")
			}
		} else {
			path = args[1]
		}

		err = client.Push(args[0], path)
		if err != nil {
			return errors.Wrap(err, "error pushing app")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdPush implements the epinio orgs command

View Source
var CmdServer = &cobra.Command{
	Use:   "server",
	Short: "starts the Epinio server. You can connect to it using either your browser or the Epinio client.",
	RunE: func(cmd *cobra.Command, args []string) error {
		httpServerWg := &sync.WaitGroup{}
		httpServerWg.Add(1)
		port := viper.GetInt("port")
		ui := termui.NewUI()
		_, listeningPort, err := startEpinioServer(httpServerWg, port, ui)
		if err != nil {
			return err
		}
		fmt.Println("listening on localhost on port " + listeningPort)
		httpServerWg.Wait()

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdServer implements the epinio server command

View Source
var CmdService = &cobra.Command{
	Use:           "service",
	Aliases:       []string{"services"},
	Short:         "Epinio service features",
	Long:          `Handle service features with Epinio`,
	Args:          cobra.ExactArgs(0),
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdService implements the epinio service command

View Source
var CmdServiceBind = &cobra.Command{
	Use:           "bind NAME APP",
	Short:         "Bind a service to an application",
	Long:          `Bind service by name, to named application.`,
	Args:          cobra.ExactArgs(2),
	RunE:          ServiceBind,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) > 1 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		if len(args) == 1 {

			matches := app.AppsMatching(toComplete)
			return matches, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceBind implements the epinio service bind command

View Source
var CmdServiceCreate = &cobra.Command{
	Use:   "create NAME CLASS PLAN ?(KEY VALUE)...?",
	Short: "Create a service",
	Long:  `Create service by name, class, plan, and optional key/value dictionary.`,
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 3 {
			return errors.New("Not enough arguments, expected name, class, plan, key, and value")
		}
		if len(args)%2 == 0 {
			return errors.New("Last Key has no value")
		}
		return nil
	},
	RunE:          ServiceCreate,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) > 2 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		if len(args) == 0 {

			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		if len(args) == 2 {

			matches := app.ServicePlanMatching(args[1], toComplete)
			return matches, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceClassMatching(toComplete)
		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceCreate implements the epinio service create command

View Source
var CmdServiceCreateCustom = &cobra.Command{
	Use:   "create-custom NAME (KEY VALUE)...",
	Short: "Create a custom service",
	Long:  `Create custom service by name and key/value dictionary.`,
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 3 {
			return errors.New("Not enough arguments, expected name, key, and value")
		}
		if len(args)%2 == 0 {
			return errors.New("Last Key has no value")
		}
		return nil
	},
	RunE:          ServiceCreateCustom,
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdServiceCreateCustom implements the epinio service create-custom command

View Source
var CmdServiceDelete = &cobra.Command{
	Use:           "delete NAME",
	Short:         "Delete a service",
	Long:          `Delete service by name.`,
	Args:          cobra.ExactArgs(1),
	RunE:          ServiceDelete,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceDelete implements the epinio service delete command

View Source
var CmdServiceList = &cobra.Command{
	Use:           "list",
	Short:         "Lists all services",
	RunE:          ServiceList,
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdServiceList implements the epinio service list command

View Source
var CmdServiceListClasses = &cobra.Command{
	Use:           "list-classes",
	Short:         "Lists the available service classes",
	RunE:          ServiceListClasses,
	SilenceErrors: true,
	SilenceUsage:  true,
}

CmdServiceListClasses implements the epinio service classes command

View Source
var CmdServiceListPlans = &cobra.Command{
	Use:           "list-plans CLASS",
	Short:         "Lists all plans provided by the named service class",
	Args:          cobra.ExactArgs(1),
	RunE:          ServiceListPlans,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceClassMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceListPlans implements the epinio service plans command

View Source
var CmdServiceShow = &cobra.Command{
	Use:           "show NAME",
	Short:         "Service information",
	Long:          `Show detailed information of the named service.`,
	Args:          cobra.ExactArgs(1),
	RunE:          ServiceShow,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceShow implements the epinio service show command

View Source
var CmdServiceUnbind = &cobra.Command{
	Use:           "unbind NAME APP",
	Short:         "Unbind service from an application",
	Long:          `Unbind service by name, from named application.`,
	Args:          cobra.ExactArgs(2),
	RunE:          ServiceUnbind,
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) > 1 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		if len(args) == 1 {

			matches := app.AppsMatching(toComplete)
			return matches, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.ServiceMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdServiceUnbind implements the epinio service unbind command

View Source
var CmdTarget = &cobra.Command{
	Use:   "target [org]",
	Short: "Targets an organization in Epinio.",
	Args:  cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return errors.Wrap(err, "error initializing cli")
		}

		org := ""
		if len(args) > 0 {
			org = args[0]
		}

		err = client.Target(org)
		if err != nil {
			return errors.Wrap(err, "failed to set target")
		}

		return nil
	},
	SilenceErrors: true,
	SilenceUsage:  true,
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) != 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		app, err := clients.NewEpinioClient(cmd.Flags())
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}

		matches := app.OrgsMatching(toComplete)

		return matches, cobra.ShellCompDirectiveNoFileComp
	},
}

CmdTarget implements the epinio target command

View Source
var CmdUninstall = &cobra.Command{
	Use:           "uninstall",
	Short:         "uninstall Epinio from your configured kubernetes cluster",
	Long:          `uninstall Epinio PaaS from your configured kubernetes cluster`,
	Args:          cobra.ExactArgs(0),
	RunE:          Uninstall,
	SilenceErrors: true,
	SilenceUsage:  true,
}
View Source
var NeededOptions = kubernetes.InstallationOptions{
	{
		Name:        "system_domain",
		Description: "The domain you are planning to use for Epinio. Should be pointing to the traefik public IP (Leave empty to use a omg.howdoi.website domain).",
		Type:        kubernetes.StringType,
		Default:     "",
		Value:       "",
	},
	{
		Name:        "email_address",
		Description: "The email address you are planning to use for getting notifications about your certificates",
		Type:        kubernetes.StringType,
		Default:     "epinio@suse.com",
		Value:       "",
	},
}

Functions

func CreateKubeClient

func CreateKubeClient(configPath string) kubernetes.Interface

func DisableGoogle

func DisableGoogle(cmd *cobra.Command, args []string) error

func DisableInCluster

func DisableInCluster(cmd *cobra.Command, args []string) error

func EnableGoogle

func EnableGoogle(cmd *cobra.Command, args []string) error

func EnableInCluster

func EnableInCluster(cmd *cobra.Command, args []string) error

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ExitIfError

func ExitIfError(err error)

func ExitfIfError

func ExitfIfError(err error, message string)

func ExitfWithMessage

func ExitfWithMessage(message string, args ...interface{})

func Install

func Install(cmd *cobra.Command, args []string) error

Install command installs epinio on a configured cluster

func InstallDeployment

func InstallDeployment(cmd *cobra.Command, deployment kubernetes.Deployment, opts kubernetes.InstallationOptions, successMessage string) error

func ServiceBind

func ServiceBind(cmd *cobra.Command, args []string) error

ServiceBind implements the epinio service bind command

func ServiceCreate

func ServiceCreate(cmd *cobra.Command, args []string) error

ServiceCreate implements the epinio service create command

func ServiceCreateCustom

func ServiceCreateCustom(cmd *cobra.Command, args []string) error

ServiceCreateCustom implements the epinio service create-custom command

func ServiceDelete

func ServiceDelete(cmd *cobra.Command, args []string) error

ServiceDelete implements the epinio service delete command

func ServiceList

func ServiceList(cmd *cobra.Command, args []string) error

ServiceList implements the epinio service list command

func ServiceListClasses

func ServiceListClasses(cmd *cobra.Command, args []string) error

ServiceListClasses implements the epinio service list-classes command

func ServiceListPlans

func ServiceListPlans(cmd *cobra.Command, args []string) error

ServiceListPlans implements the epinio service list-plans command

func ServiceShow

func ServiceShow(cmd *cobra.Command, args []string) error

ServiceShow implements the epinio service show command

func ServiceUnbind

func ServiceUnbind(cmd *cobra.Command, args []string) error

ServiceUnbind implements the epinio service unbind command

func Uninstall

func Uninstall(cmd *cobra.Command, args []string) error

Uninstall command removes epinio from a configured cluster

func UninstallDeployment

func UninstallDeployment(cmd *cobra.Command, deployment kubernetes.Deployment, successMessage string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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