diff --git a/cmd/load/load.go b/cmd/load/load.go new file mode 100644 index 00000000..41969c8c --- /dev/null +++ b/cmd/load/load.go @@ -0,0 +1,52 @@ +/* +Copyright © 2019 Thorsten Klein + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package load + +import ( + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +// NewCmdLoad returns a new cobra command +func NewCmdLoad() *cobra.Command { + + // create new cobra command + cmd := &cobra.Command{ + Use: "load", + Short: "Load a resource [image].", + Long: `Load a resource [image].`, + Run: func(cmd *cobra.Command, args []string) { + if err := cmd.Help(); err != nil { + log.Errorln("Couldn't get help text") + log.Fatalln(err) + } + }, + } + + // add subcommands + cmd.AddCommand(NewCmdLoadImage()) + + // add flags + + // done + return cmd +} diff --git a/cmd/load/loadImage.go b/cmd/load/loadImage.go new file mode 100644 index 00000000..ca3d10d3 --- /dev/null +++ b/cmd/load/loadImage.go @@ -0,0 +1,60 @@ +/* +Copyright © 2019 Thorsten Klein + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package load + +import ( + "github.com/spf13/cobra" + + "github.com/rancher/k3d/pkg/runtimes" + k3d "github.com/rancher/k3d/pkg/types" + + log "github.com/sirupsen/logrus" +) + +// NewCmdLoadImage returns a new cobra command +func NewCmdLoadImage() *cobra.Command { + + // create new command + cmd := &cobra.Command{ + Use: "image", + Short: "Load an image from docker into a k3d cluster.", + Long: `Load an image from docker into a k3d cluster.`, + Run: func(cmd *cobra.Command, args []string) { + runtime, images, clusters := parseLoadImageCmd(cmd, args) + log.Debugln("Load Images not yet implemented: ", runtime, images, clusters) + }, + } + + /********* + * Flags * + *********/ + + /* Subcommands */ + + // done + return cmd +} + +// parseLoadImageCmd parses the command input into variables required to create a cluster +func parseLoadImageCmd(cmd *cobra.Command, args []string) (runtimes.Runtime, []string, []k3d.Cluster) { + return nil, nil, nil +} diff --git a/cmd/root.go b/cmd/root.go index 282dc771..bb3291e8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -31,6 +31,7 @@ import ( "github.com/rancher/k3d/cmd/create" "github.com/rancher/k3d/cmd/delete" "github.com/rancher/k3d/cmd/get" + "github.com/rancher/k3d/cmd/load" "github.com/rancher/k3d/cmd/start" "github.com/rancher/k3d/cmd/stop" @@ -83,6 +84,7 @@ func init() { rootCmd.AddCommand(get.NewCmdGet()) rootCmd.AddCommand(stop.NewCmdStop()) rootCmd.AddCommand(start.NewCmdStart()) + rootCmd.AddCommand(load.NewCmdLoad()) rootCmd.AddCommand(&cobra.Command{ Use: "version", diff --git a/thoughts.md b/thoughts.md index b7650168..6fdc84b6 100644 --- a/thoughts.md +++ b/thoughts.md @@ -95,16 +95,16 @@ Here's how k3d types should translate to a runtime type: - --shell - auto, bash, zsh - create - - --name - - --volume - - --port - - --api-port + - --name -> y + - --volume -> y + - --port -> y + - --api-port -> y - --wait - - --image - - --server-arg - - --agent-arg + - --image -> y + - --server-arg -> y + - --agent-arg -> y - --env - - --workers + - --workers -> y - --auto-restart - (add-node) - --role