agent

package
v0.0.0-...-f7536bd Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AgentCommand = &cobra.Command{
	Use:   "agent",
	Short: "agent",
	RunE: func(c *cobra.Command, args []string) error {
		if len(args) == 0 {
			c.Help()
		}
		return nil
	},
}
View Source
var AgentPackageCommand = &cobra.Command{
	Use:   "package",
	Short: "package agent into a tar.gz file",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			cmd.Help()
			return nil
		}
		path := args[0]
		command := exec.Command("tar", "-cf", path, "dist", ".env", "octopus", "config")
		out, err := command.CombinedOutput()
		fmt.Println(string(out))
		if err != nil {
			return err
		}
		return nil

	},
}
View Source
var AgentRegisterLocalCommand = &cobra.Command{
	Use:   "register",
	Short: "register to host as a service",
	RunE: func(cmd *cobra.Command, args []string) error {
		container := cmd.GetContainer()
		agentService := container.MustMake(agent.AgentKey).(agent.IService)
		if err := agentService.Register(); err != nil {
			return err
		}
		return nil
	},
}
View Source
var AgentRunScriptCommand = &cobra.Command{
	Use:   "script",
	Short: "run a specific script in exec.Command, ./yogo agent script ./demo.sh",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			cmd.Help()
			return nil
		}
		path := args[0]
		content, err := os.ReadFile(path)
		if err != nil {
			return err
		}
		container := cmd.GetContainer()
		writer := os.Stdout
		agentService := container.MustMake(agent.AgentKey).(agent.IService)
		if err := agentService.RunScript(content, writer); err != nil {
			return err
		}
		return nil
	},
}
View Source
var AgentStatusCommand = &cobra.Command{
	Use:   "status",
	Short: "status of octopus-agent.service",
	RunE: func(cmd *cobra.Command, args []string) error {
		container := cmd.GetContainer()
		agentService := container.MustMake(agent.AgentKey).(agent.IService)
		if err := agentService.Status(); err != nil {
			return err
		}
		return nil
	},
}

Functions

func InitAgentCommand

func InitAgentCommand() *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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