agnhost.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright 2019 The Kubernetes 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 main
  14. import (
  15. "github.com/spf13/cobra"
  16. )
  17. func main() {
  18. cmdDNSSuffix := &cobra.Command{
  19. Use: "dns-suffix",
  20. Short: "Prints the host's DNS suffix list",
  21. Long: `Prints the DNS suffixes of this host.`,
  22. Args: cobra.MaximumNArgs(0),
  23. Run: printDNSSuffixList,
  24. }
  25. cmdDNSServerList := &cobra.Command{
  26. Use: "dns-server-list",
  27. Short: "Prints the host's DNS Server list",
  28. Long: `Prints the DNS Server list of this host.`,
  29. Args: cobra.MaximumNArgs(0),
  30. Run: printDNSServerList,
  31. }
  32. cmdEtcHosts := &cobra.Command{
  33. Use: "etc-hosts",
  34. Short: "Prints the host's /etc/hosts file",
  35. Long: `Prints the "hosts" file of this host."`,
  36. Args: cobra.MaximumNArgs(0),
  37. Run: printHostsFile,
  38. }
  39. cmdPause := &cobra.Command{
  40. Use: "pause",
  41. Short: "Pauses",
  42. Long: `Pauses the execution. Useful for keeping the containers running, so other commands can be executed.`,
  43. Args: cobra.MaximumNArgs(0),
  44. Run: pause,
  45. }
  46. rootCmd := &cobra.Command{Use: "app"}
  47. rootCmd.AddCommand(cmdDNSSuffix)
  48. rootCmd.AddCommand(cmdDNSServerList)
  49. rootCmd.AddCommand(cmdEtcHosts)
  50. rootCmd.AddCommand(cmdPause)
  51. rootCmd.Execute()
  52. }