Documentation ¶
Index ¶
Constants ¶
View Source
const VERSION = "2023.11.24"
Variables ¶
View Source
var BuildCmd = &cobra.Command{ Use: "build", Short: "Build the fishler Docker image", Long: `If the fishler Docker image is not yet built, build it. Use --force to rebuild.`, PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { forceBuild, _ := cmd.Flags().GetBool("force") dockerClient, err := client.NewClientWithOpts( client.FromEnv, client.WithAPIVersionNegotiation(), ) if err != nil { util.Logger.Error(err) } ctx := context.Background() err = util.BuildFishler(dockerClient, ctx, forceBuild) if err != nil { util.Logger.Error(err) } }, }
View Source
var DocCmd = &cobra.Command{ Use: "doc", Short: fmt.Sprintf("Build documentation under %s", documentationBasepath), Long: fmt.Sprintf(`Generate documentation for command line usage under %s`, documentationBasepath), PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { err := os.MkdirAll(documentationBasepath, 0750) if err != nil { log.Fatal(err) } err = doc.GenMarkdownTree(cmd.Root(), documentationBasepath) if err != nil { log.Fatal(err) } }, }
View Source
var ImageCmd = &cobra.Command{ Use: "image", Short: "Build, list, delete fishler Docker image", Long: `Manage the fishler images`, PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() if err != nil { log.Fatal(err) os.Exit(1) } dockerClient, err := client.NewClientWithOpts( client.FromEnv, client.WithAPIVersionNegotiation(), ) if err != nil { util.Logger.Error(err) } ctx := context.Background() images, err := util.GetDockerImage(dockerClient, ctx) if err != nil { util.Logger.Error(err) return } if len(images) == 0 { util.Logger.Info("No image's found - try building one!") } for _, image := range images { util.Logger.Infof("Size: %s Image: %v ID: %s", util.ByteCountDecimal(image.Size), image.RepoTags, image.ID) } }, }
View Source
var RootCmd = &cobra.Command{ Version: VERSION, Use: "fishler", Short: "SSH to Docker container", Long: "Leverage SSH and Docker to create containers on-the-fly!", PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) config.Load() logger := util.SetLogger(fmt.Sprintf("%s/system.log", config.Setting.LogBasepath)) if logger == nil { logger := util.SetLogger("./system.log") if logger == nil { fmt.Printf("[!] Failed to setup logger - bailing\n") err := cmd.Help() if err != nil { log.Fatal(err) os.Exit(1) } os.Exit(0) } fmt.Printf("[!] Failed to setup default logger - using ./system.log instead\n") } if config.Setting.Debug { config.Setting.Print() } }, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { err := cmd.Help() if err != nil { util.Logger.Error(err) os.Exit(1) } os.Exit(0) } version, _ := cmd.Flags().GetBool("version") if version { util.Logger.Infof("Version %s\n", VERSION) os.Exit(0) } }, }
View Source
var RootImageRemoveCmd = &cobra.Command{ Use: "rm", Short: "Remove the fishler Docker image", Long: `If the fishler Docker image is not yet built, build it. Use --force to rebuild.`, PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) }, Run: func(cmd *cobra.Command, args []string) { forceRemove, _ := cmd.Flags().GetBool("force") dockerClient, err := client.NewClientWithOpts( client.FromEnv, client.WithAPIVersionNegotiation(), ) if err != nil { util.Logger.Error(err) return } ctx := context.Background() images, err := util.GetDockerImage(dockerClient, ctx) if err != nil { util.Logger.Error(err) return } if len(images) == 0 { util.Logger.Info("No fishler image's found for removal") return } for _, image := range images { _, err = dockerClient.ImageRemove(ctx, image.ID, types.ImageRemoveOptions{ Force: forceRemove, PruneChildren: true, }) if err != nil { util.Logger.Errorf("Failed to remove image %s %v", image.ID, err) continue } util.Logger.Infof("Image Removed %s", image.ID) } }, }
View Source
var ServeCmd = &cobra.Command{ Use: "serve", Short: "Start an SSH server on --port configured to as desired; serving a docker container on authentication success.", Long: `Leveraging the goodness of Golang, Docker, and SSH - create a container for any user that authenticates with success to the SSH server - recording the session and credentials used.`, PersistentPreRun: func(cmd *cobra.Command, args []string) { CallPersistentPreRun(cmd, args) config.Load() if rootConfig.Setting.Debug { util.Logger.SetReportCaller(true) config.Setting.Print() } config.Setting.SetupAuthentication() }, Run: func(cmd *cobra.Command, args []string) { err := app.NewApplication().Start() if err != nil { util.Logger.Error(err) } }, }
Functions ¶
func CallPersistentPreRun ¶
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.