util.go 602 B

12345678910111213141516171819202122232425262728293031
  1. package control
  2. import (
  3. "bufio"
  4. "fmt"
  5. "os"
  6. "strings"
  7. "github.com/rancher/os/config"
  8. "github.com/rancher/os/log"
  9. )
  10. func yes(question string) bool {
  11. fmt.Printf("%s [y/N]: ", question)
  12. in := bufio.NewReader(os.Stdin)
  13. line, err := in.ReadString('\n')
  14. if err != nil {
  15. log.Fatal(err)
  16. }
  17. return strings.ToLower(line[0:1]) == "y"
  18. }
  19. func formatImage(image string, cfg *config.CloudConfig) string {
  20. domainRegistry := cfg.Rancher.Environment["REGISTRY_DOMAIN"]
  21. if domainRegistry != "docker.io" && domainRegistry != "" {
  22. return fmt.Sprintf("%s/%s", domainRegistry, image)
  23. }
  24. return image
  25. }