context.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package context
  14. import (
  15. "github.com/docker/compose-cli/cli/mobycli"
  16. "github.com/spf13/cobra"
  17. )
  18. // Command manages contexts
  19. func Command() *cobra.Command {
  20. cmd := &cobra.Command{
  21. Use: "context",
  22. Short: "Manage contexts",
  23. }
  24. cmd.AddCommand(
  25. createCommand(),
  26. listCommand(),
  27. removeCommand(),
  28. showCommand(),
  29. useCommand(),
  30. inspectCommand(),
  31. updateCommand(),
  32. exportCommand(),
  33. importCommand(),
  34. )
  35. return cmd
  36. }
  37. func exportCommand() *cobra.Command {
  38. cmd := &cobra.Command{
  39. Use: "export",
  40. Short: "Export a context to a tar or kubeconfig file",
  41. Run: func(cmd *cobra.Command, args []string) {
  42. mobycli.Exec(cmd.Root())
  43. },
  44. }
  45. cmd.Flags().Bool("kubeconfig", false, "Export as a kubeconfig file")
  46. return cmd
  47. }
  48. func importCommand() *cobra.Command {
  49. cmd := &cobra.Command{
  50. Use: "import",
  51. Short: "Import a context from a tar or zip file",
  52. Run: func(cmd *cobra.Command, args []string) {
  53. mobycli.Exec(cmd.Root())
  54. },
  55. }
  56. return cmd
  57. }