• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang util.Successf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/fabric8io/gofabric8/util.Successf函数的典型用法代码示例。如果您正苦于以下问题:Golang Successf函数的具体用法?Golang Successf怎么用?Golang Successf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Successf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: downloadKubernetes

func downloadKubernetes(isMinishift bool) (err error) {
	os := runtime.GOOS
	arch := runtime.GOARCH
	if isMinishift {
		kubeDistroOrg = minishiftOwner
		kubeDistroRepo = minishift
		kubeDownloadURL = minishiftDownloadURL
		downloadPath = "download/"
		kubeBinary = minishift
	}

	_, err = exec.LookPath(kubeBinary)
	if err != nil {
		latestVersion, err := getLatestVersionFromGitHub(kubeDistroOrg, kubeDistroRepo)
		if err != nil {
			util.Errorf("Unable to get latest version for %s/%s %v", kubeDistroOrg, kubeDistroRepo, err)
			return err
		}

		kubeURL := fmt.Sprintf(kubeDownloadURL+kubeDistroRepo+"/releases/"+downloadPath+"v%s/%s-%s-%s", latestVersion, kubeDistroRepo, os, arch)
		util.Infof("Downloading %s...", kubeURL)

		err = downloadFile(writeFileLocation+kubeBinary, kubeURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", writeFileLocation+kubeBinary, kubeURL, err)
			return err
		}
		util.Successf("Downloaded %s\n", kubeBinary)
	} else {
		util.Successf("%s is already available on your PATH\n", kubeBinary)
	}

	return nil
}
开发者ID:gashcrumb,项目名称:gofabric8,代码行数:34,代码来源:install.go


示例2: downloadFunktion

func downloadFunktion() (err error) {
	os := runtime.GOOS
	arch := runtime.GOARCH

	_, err = exec.LookPath(funktion)
	if err != nil {
		latestVersion, err := getLatestVersionFromGitHub(fabric8io, funktionOperator)
		if err != nil {
			util.Errorf("Unable to get latest version for %s/%s %v", fabric8io, funktionOperator, err)
			return err
		}

		funktionURL := fmt.Sprintf(githubURL+fabric8io+"/"+funktionOperator+"/releases/download/v%s/%s-%s-%s", latestVersion, funktionOperator, os, arch)
		if runtime.GOOS == "windows" {
			funktionURL += ".exe"
		}
		util.Infof("Downloading %s...\n", funktionURL)

		fullPath := filepath.Join(getFabric8BinLocation(), funktion)
		err = downloadFile(fullPath, funktionURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", fullPath, funktionURL, err)
			return err
		}
		util.Successf("Downloaded %s\n", fullPath)
	} else {
		util.Successf("%s is already available on your PATH\n", funktion)
	}

	return nil
}
开发者ID:fabric8io,项目名称:gofabric8,代码行数:31,代码来源:install.go


示例3: openService

func openService(ns string, serviceName string, c *k8sclient.Client, printURL bool, retry bool) {
	if retry {
		if err := RetryAfter(40, func() error { return CheckService(ns, serviceName, c) }, 10*time.Second); err != nil {
			util.Errorf("Could not find finalized endpoint being pointed to by %s: %v", serviceName, err)
			os.Exit(1)
		}
	}
	svcs, err := c.Services(ns).List(kubeApi.ListOptions{})
	if err != nil {
		util.Errorf("No services found %v\n", err)
	}
	found := false
	for _, service := range svcs.Items {
		if serviceName == service.Name {

			url := service.ObjectMeta.Annotations[exposeURLAnnotation]

			if printURL {
				util.Successf("%s\n", url)
			} else {
				util.Successf("\nOpening URL %s\n", url)
				browser.OpenURL(url)
			}
			found = true
			break
		}
	}
	if !found {
		util.Errorf("No service %s in namespace %s\n", serviceName, ns)
	}
}
开发者ID:fabric8io,项目名称:gofabric8,代码行数:31,代码来源:service.go


示例4: printSummary

func printSummary(typeOfMaster util.MasterType, externalNodeName string, ns string, domain string, c *k8sclient.Client) {
	util.Info("\n")
	util.Info("-------------------------\n")
	util.Info("\n")
	clientType := getClientTypeName(typeOfMaster)

	if externalNodeName != "" {
		util.Info("Deploying ingress controller on node ")
		util.Successf("%s", externalNodeName)
		util.Info(" use its external ip when configuring your wildcard DNS.\n")
		util.Infof("To change node move the label: `%s label node %s %s- && %s label node $YOUR_NEW_NODE %s=true`\n", clientType, externalNodeName, externalIPLabel, clientType, externalIPLabel)
		util.Info("\n")
	}

	util.Info("Default GOGS admin username/password = ")
	util.Successf("%s/%s\n", gogsDefaultUsername, gogsDefaultPassword)
	util.Info("\n")

	found, _ := checkIfPVCsPending(c, ns)
	if found {
		util.Errorf("There are pending PersistentVolumeClaims\n")
		util.Infof("If using a local cluster run `gofabric8 volumes` to create missing HostPath volumes\n")
		util.Infof("If using a remote cloud then enable dynamic persistence with a StorageClass.  For details see http://fabric8.io/guide/getStarted/persistence.html\n")
		util.Info("\n")
	}
	util.Infof("Downloading images and waiting to open the fabric8 console...\n")
	util.Info("\n")
	util.Info("-------------------------\n")
}
开发者ID:fabric8io,项目名称:gofabric8,代码行数:29,代码来源:deploy.go


示例5: downloadKubectlClient

func downloadKubectlClient() (err error) {

	os := runtime.GOOS
	arch := runtime.GOARCH

	kubectlBinary := kubectl
	if runtime.GOOS == "windows" {
		kubectlBinary += ".exe"
	}

	_, err = exec.LookPath(kubectlBinary)
	if err != nil {
		latestVersion, err := getLatestVersionFromGitHub(kubernetes, kubernetes)
		if err != nil {
			return fmt.Errorf("Unable to get latest version for %s/%s %v", kubernetes, kubernetes, err)
		}

		clientURL := fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/v%s/bin/%s/%s/%s", latestVersion, os, arch, kubectlBinary)

		util.Infof("Downloading %s...\n", clientURL)

		fullPath := filepath.Join(getFabric8BinLocation(), kubectlBinary)
		err = downloadFile(fullPath, clientURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", fullPath, clientURL, err)
			return err
		}
		util.Successf("Downloaded %s\n", fullPath)
	} else {
		util.Successf("%s is already available on your PATH\n", kubectlBinary)
	}

	return nil
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:34,代码来源:install.go


示例6: downloadKubernetes

func downloadKubernetes(d downloadProperties) (err error) {
	os := runtime.GOOS
	arch := runtime.GOARCH

	if runtime.GOOS == "windows" {
		d.kubeBinary += ".exe"
	}

	_, err = exec.LookPath(d.kubeBinary)
	if err != nil {
		latestVersion, err := getLatestVersionFromGitHub(d.kubeDistroOrg, d.kubeDistroRepo)
		if err != nil {
			util.Errorf("Unable to get latest version for %s/%s %v", d.kubeDistroOrg, d.kubeDistroRepo, err)
			return err
		}

		kubeURL := fmt.Sprintf(d.downloadURL+d.kubeDistroRepo+"/releases/"+d.extraPath+"v%s/%s-%s-%s", latestVersion, d.kubeDistroRepo, os, arch)
		if runtime.GOOS == "windows" {
			kubeURL += ".exe"
		}
		util.Infof("Downloading %s...\n", kubeURL)

		fullPath := filepath.Join(getFabric8BinLocation(), d.kubeBinary)
		err = downloadFile(fullPath, kubeURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", fullPath, kubeURL, err)
			return err
		}
		util.Successf("Downloaded %s\n", fullPath)
	} else {
		util.Successf("%s is already available on your PATH\n", d.kubeBinary)
	}

	return nil
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:35,代码来源:install.go


示例7: downloadClient

func downloadClient(isMinishift bool) (err error) {

	os := runtime.GOOS
	arch := runtime.GOARCH

	_, err = exec.LookPath(kubectl)
	if err != nil {
		latestVersion, err := getLatestVersionFromGitHub(kubeDistroOrg, kubernetes)
		if err != nil {
			return fmt.Errorf("Unable to get latest version for %s/%s %v", kubeDistroOrg, kubernetes, err)
		}

		if isMinishift {
			clientBinary = oc
			return fmt.Errorf("Openshift client download not yet supported")
		}

		clientURL := fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/v%s/bin/%s/%s/%s", latestVersion, os, arch, kubectl)
		util.Infof("Downloading %s...", clientURL)

		err = downloadFile(writeFileLocation+clientBinary, clientURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", writeFileLocation+clientBinary, clientURL, err)
			return err
		}
		util.Successf("Downloaded %s\n", clientBinary)
	} else {
		util.Successf("%s is already available on your PATH\n", clientBinary)
	}

	return nil
}
开发者ID:gashcrumb,项目名称:gofabric8,代码行数:32,代码来源:install.go


示例8: NewCmdIngress

func NewCmdIngress(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "ingress",
		Short: "Creates any missing Ingress resources for services",
		Long:  `Creates any missing Ingress resources for Services which are of type LoadBalancer`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, err := f.DefaultNamespace()
			if err != nil {
				util.Fatal("No default namespace")
				printResult("Get default namespace", Failure, err)
			} else {
				domain := cmd.Flags().Lookup(domainFlag).Value.String()

				util.Info("Setting up ingress on your ")
				util.Success(string(util.TypeOfMaster(c)))
				util.Info(" installation at ")
				util.Success(cfg.Host)
				util.Info(" in namespace ")
				util.Successf("%s at domain %s\n\n", ns, domain)
				err := createIngressForDomain(ns, domain, c, f)
				printError("Create Ingress", err)
			}
		},
	}
	cmd.PersistentFlags().StringP(domainFlag, "", defaultDomain(), "The domain to put the created routes inside")
	return cmd
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:31,代码来源:ingress.go


示例9: NewCmdVolume

func NewCmdVolume(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "volume",
		Short: "Creates a persisent volume for fabric8 apps needing persistent disk",
		Long:  `Creates a persisent volume so that the PersistentVolumeClaims in fabric8 apps can be satisfied when creating fabric8 apps`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, err := f.DefaultNamespace()
			if err != nil {
				util.Fatal("No default namespace")
				printResult("Get default namespace", Failure, err)
			} else {
				util.Info("Creating a persistent volume for your ")
				util.Success(string(util.TypeOfMaster(c)))
				util.Info(" installation at ")
				util.Success(cfg.Host)
				util.Info(" in namespace ")
				util.Successf("%s\n\n", ns)

				r, err := createPersistentVolume(cmd, ns, c, f)
				printResult("Create PersistentVolume", r, err)
			}
		},
	}
	cmd.PersistentFlags().StringP(hostPathFlag, "", "", "Defines the host folder on which to define a persisent volume for single node setups")
	cmd.PersistentFlags().StringP(nameFlag, "", "fabric8", "The name of the PersistentVolume to create")
	return cmd
}
开发者ID:ALRubinger,项目名称:gofabric8,代码行数:31,代码来源:volume.go


示例10: NewCmdRoutes

func NewCmdRoutes(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "routes",
		Short: "Creates any missing Routes for services",
		Long:  `Creates any missing Route resources for Services which need to be exposed remotely`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			oc, _ := client.NewOpenShiftClient(cfg)
			ns, _, err := f.DefaultNamespace()
			if err != nil {
				util.Fatal("No default namespace")
				printResult("Get default namespace", Failure, err)
			} else {
				util.Info("Creating a persistent volume for your ")
				util.Success(string(util.TypeOfMaster(c)))
				util.Info(" installation at ")
				util.Success(cfg.Host)
				util.Info(" in namespace ")
				util.Successf("%s\n\n", ns)

				domain := cmd.Flags().Lookup(domainFlag).Value.String()

				err := createRoutesForDomain(ns, domain, c, oc, f)
				printError("Create Routes", err)
			}
		},
	}
	cmd.PersistentFlags().StringP(domainFlag, "", defaultDomain(), "The domain to put the created routes inside")
	return cmd
}
开发者ID:iocanel,项目名称:gofabric8,代码行数:33,代码来源:routes.go


示例11: runTemplate

func runTemplate(c *k8sclient.Client, oc *oclient.Client, appToRun string, ns string, domain string, apiserver string, pv bool) {
	util.Info("\n\nInstalling: ")
	util.Successf("%s\n\n", appToRun)
	typeOfMaster := util.TypeOfMaster(c)
	if typeOfMaster == util.Kubernetes {
		jsonData, format, err := loadTemplateData(ns, appToRun, c, oc)
		if err != nil {
			printError("Failed to load app "+appToRun, err)
		}
		createTemplate(jsonData, format, appToRun, ns, domain, apiserver, c, oc, pv)
	} else {
		tmpl, err := oc.Templates(ns).Get(appToRun)
		if err != nil {
			printError("Failed to load template "+appToRun, err)
		}
		util.Infof("Loaded template with %d objects", len(tmpl.Objects))
		processTemplate(tmpl, ns, domain, apiserver)

		objectCount := len(tmpl.Objects)

		util.Infof("Creating "+appToRun+" template resources from %d objects\n", objectCount)
		for _, o := range tmpl.Objects {
			err = processItem(c, oc, &o, ns, pv)
		}
	}
}
开发者ID:fabric8io,项目名称:gofabric8,代码行数:26,代码来源:deploy.go


示例12: runTemplate

func runTemplate(c *k8sclient.Client, oc *oclient.Client, appToRun string, ns string, domain string, apiserver string) {
	util.Info("\n\nInstalling: ")
	util.Successf("%s\n\n", appToRun)
	jsonData, err := loadTemplateData(ns, appToRun, c, oc)
	if err != nil {
		printError("Failed to load app "+appToRun, err)
	}
	createTemplate(jsonData, appToRun, ns, domain, apiserver, c)
}
开发者ID:rhuss,项目名称:gofabric8,代码行数:9,代码来源:deploy.go


示例13: NewCmdSecrets

func NewCmdSecrets(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "secrets",
		Short: "Set up Secrets on your Kubernetes or OpenShift environment",
		Long:  `set up Secrets on your Kubernetes or OpenShift environment`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, _ := f.DefaultNamespace()
			util.Info("Setting up secrets on your ")
			util.Success(string(util.TypeOfMaster(c)))
			util.Info(" installation at ")
			util.Success(cfg.Host)
			util.Info(" in namespace ")
			util.Successf("%s\n\n", ns)

			if confirmAction(cmd.Flags()) {
				typeOfMaster := util.TypeOfMaster(c)

				if typeOfMaster == util.Kubernetes {
					util.Fatal("Support for Kubernetes not yet available...\n")
				} else {
					oc, _ := client.NewOpenShiftClient(cfg)
					t := getTemplates(oc, ns)

					count := 0
					// get all the Templates and find the annotations on any Pods
					for _, i := range t.Items {
						// convert TemplateList.Objects to Kubernetes resources
						_ = runtime.DecodeList(i.Objects, api.Scheme, runtime.UnstructuredJSONScheme)
						for _, rc := range i.Objects {
							switch rc := rc.(type) {
							case *api.ReplicationController:
								for secretType, secretDataIdentifiers := range rc.Spec.Template.Annotations {
									count += createAndPrintSecrets(secretDataIdentifiers, secretType, c, f, cmd.Flags())
								}
							}
						}
					}

					if count == 0 {
						util.Info("No secrets created as no fabric8 secrets annotations found in the templates\n")
						util.Info("For more details see: https://github.com/fabric8io/fabric8/blob/master/docs/secretAnnotations.md\n")
					}
				}
			}
		},
	}
	cmd.PersistentFlags().BoolP("print-import-folder-structure", "", true, "Prints the folder structures that are being used by the template annotations to import secrets")
	cmd.PersistentFlags().BoolP("write-generated-keys", "", false, "Write generated secrets to the local filesystem")
	cmd.PersistentFlags().BoolP("generate-secrets-data", "g", true, "Generate secrets data if secrets cannot be found to import from the local filesystem")
	return cmd
}
开发者ID:MarWestermann,项目名称:gofabric8,代码行数:55,代码来源:secrets.go


示例14: NewCmdRun

func NewCmdRun(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "run",
		Short: "Runs a fabric8 microservice from one of the installed templates",
		Long:  `runs a fabric8 microservice from one of the installed templates`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, _ := f.DefaultNamespace()

			if len(args) == 0 {
				util.Info("Please specify a template name to run\n")
				return
			}
			domain := cmd.Flags().Lookup(domainFlag).Value.String()
			apiserver := cmd.Flags().Lookup(apiServerFlag).Value.String()
			pv := cmd.Flags().Lookup(pvFlag).Value.String() == "true"

			typeOfMaster := util.TypeOfMaster(c)

			util.Info("Running an app template to your ")
			util.Success(string(typeOfMaster))
			util.Info(" installation at ")
			util.Success(cfg.Host)
			util.Info(" for domain ")
			util.Success(domain)
			util.Info(" in namespace ")
			util.Successf("%s\n\n", ns)

			if len(apiserver) == 0 {
				apiserver = domain
			}

			yes := cmd.Flags().Lookup(yesFlag).Value.String() == "false"
			if strings.Contains(domain, "=") {
				util.Warnf("\nInvalid domain: %s\n\n", domain)

			} else if confirmAction(yes) {
				oc, _ := client.NewOpenShiftClient(cfg)
				initSchema()

				for _, app := range args {
					runTemplate(c, oc, app, ns, domain, apiserver, pv)
				}
			}
		},
	}
	cmd.PersistentFlags().StringP(domainFlag, "d", defaultDomain(), "The domain name to append to the service name to access web applications")
	cmd.PersistentFlags().String(apiServerFlag, "", "overrides the api server url")
	cmd.PersistentFlags().Bool(pvFlag, true, "Enable the use of persistence (enabling the PersistentVolumeClaims)?")
	return cmd
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:54,代码来源:run.go


示例15: printSummary

func printSummary(typeOfMaster util.MasterType, externalNodeName string, mini bool, ns string, domain string) {
	util.Info("\n")
	util.Info("-------------------------\n")
	util.Info("\n")
	clientType := getClientTypeName(typeOfMaster)

	if externalNodeName != "" {
		util.Info("Deploying ingress controller on node ")
		util.Successf("%s", externalNodeName)
		util.Info(" use its external ip when configuring your wildcard DNS.\n")
		util.Infof("To change node move the label: `%s label node %s %s- && %s label node $YOUR_NEW_NODE %s=true`\n", clientType, externalNodeName, externalIPLabel, clientType, externalIPLabel)
		util.Info("\n")
	}

	util.Info("Default GOGS admin username/password = ")
	util.Successf("%s/%s\n", gogsDefaultUsername, gogsDefaultPassword)
	util.Info("\n")

	util.Infof("Downloading images and waiting to open the fabric8 console...\n")
	util.Info("\n")
	util.Info("-------------------------\n")
}
开发者ID:gashcrumb,项目名称:gofabric8,代码行数:22,代码来源:deploy.go


示例16: printResult

func printResult(check string, r Result, err error) {
	if err != nil {
		r = Failure
	}
	padLen := 78 - len(check)
	pad := ""
	if padLen > 0 {
		pad = strings.Repeat(".", padLen)
	}
	util.Infof("%s%s", check, pad)
	if r == Failure {
		util.Failuref("%-2s", r)
	} else {
		util.Successf("%-2s", r)
	}
	if err != nil {
		util.Failuref("%v", err)
	}
	util.Blank()
}
开发者ID:ALRubinger,项目名称:gofabric8,代码行数:20,代码来源:validate.go


示例17: NewCmdValidate

func NewCmdValidate(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "validate",
		Short: "Validate your Kubernetes or OpenShift environment",
		Long:  `validate your Kubernetes or OpenShift environment`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, _ := f.DefaultNamespace()
			util.Info("Validating your ")
			util.Success(string(util.TypeOfMaster(c)))
			util.Info(" installation at ")
			util.Success(cfg.Host)
			util.Info(" in namespace ")
			util.Successf("%s\n\n", ns)
			printValidationResult("Service account", validateServiceAccount, c, f)
			printValidationResult("Console", validateConsoleDeployment, c, f)

			r, err := validateProxyServiceRestAPI(c, f, cfg.Host)
			printResult("REST Proxy Service API", r, err)

			if util.TypeOfMaster(c) == util.Kubernetes {
				printValidationResult("Jenkinshift Service", validateJenkinshiftService, c, f)
			}

			if util.TypeOfMaster(c) == util.OpenShift {
				printValidationResult("Router", validateRouter, c, f)
				oc, _ := client.NewOpenShiftClient(cfg)
				printOValidationResult("Templates", validateTemplates, oc, f)
				printValidationResult("SecurityContextConstraints", validateSecurityContextConstraints, c, f)
			}

			printValidationResult("PersistentVolumeClaims", validatePersistenceVolumeClaims, c, f)
			printValidationResult("ConfigMaps", validateConfigMaps, c, f)
		},
	}

	return cmd
}
开发者ID:rhuss,项目名称:gofabric8,代码行数:41,代码来源:validate.go


示例18: NewCmdDeploy

func NewCmdDeploy(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "deploy",
		Short: "Deploy fabric8 to your Kubernetes or OpenShift environment",
		Long:  `deploy fabric8 to your Kubernetes or OpenShift environment`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			c, cfg := client.NewClient(f)
			ns, _, _ := f.DefaultNamespace()

			domain := cmd.Flags().Lookup(domainFlag).Value.String()
			apiserver := cmd.Flags().Lookup(apiServerFlag).Value.String()
			arch := cmd.Flags().Lookup(archFlag).Value.String()

			typeOfMaster := util.TypeOfMaster(c)

			util.Info("Deploying fabric8 to your ")
			util.Success(string(typeOfMaster))
			util.Info(" installation at ")
			util.Success(cfg.Host)
			util.Info(" for domain ")
			util.Success(domain)
			util.Info(" in namespace ")
			util.Successf("%s\n\n", ns)

			useIngress := cmd.Flags().Lookup(useIngressFlag).Value.String() == "true"
			deployConsole := cmd.Flags().Lookup(consoleFlag).Value.String() == "true"

			mavenRepo := cmd.Flags().Lookup(mavenRepoFlag).Value.String()
			if !strings.HasSuffix(mavenRepo, "/") {
				mavenRepo = mavenRepo + "/"
			}
			util.Info("Loading fabric8 releases from maven repository:")
			util.Successf("%s\n", mavenRepo)

			dockerRegistry := cmd.Flags().Lookup(dockerRegistryFlag).Value.String()
			if len(dockerRegistry) > 0 {
				util.Infof("Loading fabric8 docker images from docker registry: %s\n", dockerRegistry)
			}

			if len(apiserver) == 0 {
				apiserver = domain
			}

			if strings.Contains(domain, "=") {
				util.Warnf("\nInvalid domain: %s\n\n", domain)
			} else if confirmAction(cmd.Flags()) {
				v := cmd.Flags().Lookup("fabric8-version").Value.String()

				consoleVersion := f8ConsoleVersion(mavenRepo, v, typeOfMaster)

				versioniPaaS := cmd.Flags().Lookup(versioniPaaSFlag).Value.String()
				versioniPaaS = versionForUrl(versioniPaaS, urlJoin(mavenRepo, iPaaSMetadataUrl))

				versionDevOps := cmd.Flags().Lookup(versionDevOpsFlag).Value.String()
				versionDevOps = versionForUrl(versionDevOps, urlJoin(mavenRepo, devOpsMetadataUrl))

				versionKubeflix := cmd.Flags().Lookup(versionKubeflixFlag).Value.String()
				versionKubeflix = versionForUrl(versionKubeflix, urlJoin(mavenRepo, kubeflixMetadataUrl))

				versionZipkin := cmd.Flags().Lookup(versionZipkinFlag).Value.String()
				versionZipkin = versionForUrl(versionZipkin, urlJoin(mavenRepo, zipkinMetadataUrl))

				util.Warnf("\nStarting fabric8 console deployment using %s...\n\n", consoleVersion)

				oc, _ := client.NewOpenShiftClient(cfg)

				aapi.AddToScheme(api.Scheme)
				aapiv1.AddToScheme(api.Scheme)
				tapi.AddToScheme(api.Scheme)
				tapiv1.AddToScheme(api.Scheme)

				if typeOfMaster == util.Kubernetes {
					uri := fmt.Sprintf(urlJoin(mavenRepo, baseConsoleKubernetesUrl), consoleVersion)
					if fabric8ImageAdaptionNeeded(dockerRegistry, arch) {
						jsonData, err := loadJsonDataAndAdaptFabric8Images(uri, dockerRegistry, arch)
						if err == nil {
							tmpFileName := "/tmp/fabric8-console.json"
							t, err := os.OpenFile(tmpFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
							if err != nil {
								util.Fatalf("Cannot open the converted fabric8 console template file: %v", err)
							}
							defer t.Close()

							_, err = io.Copy(t, bytes.NewReader(jsonData))
							if err != nil {
								util.Fatalf("Cannot write the converted fabric8 console template file: %v", err)
							}
							uri = tmpFileName
						}
					}
					filenames := []string{uri}

					if deployConsole {
						createCmd := &cobra.Command{}
						cmdutil.AddValidateFlags(createCmd)
						cmdutil.AddOutputFlagsForMutation(createCmd)
						cmdutil.AddApplyAnnotationFlags(createCmd)
//.........这里部分代码省略.........
开发者ID:rhuss,项目名称:gofabric8,代码行数:101,代码来源:deploy.go


示例19: NewCmdStart

// NewCmdStart starts a local cloud environment
func NewCmdStart(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "start",
		Short: "Starts a local cloud development environment",
		Long:  `Starts a local cloud development environment`,

		Run: func(cmd *cobra.Command, args []string) {

			flag := cmd.Flags().Lookup(minishift)
			isOpenshift := false
			if flag != nil {
				isOpenshift = flag.Value.String() == "true"
			}

			flag = cmd.Flags().Lookup(ipaas)
			isIPaaS := false
			if flag != nil && flag.Value.String() == "true" {
				isOpenshift = true
				isIPaaS = true
			}

			if !isInstalled(isOpenshift) {
				install(isOpenshift)
			}
			kubeBinary := minikube
			if isOpenshift {
				kubeBinary = minishift
			}

			if runtime.GOOS == "windows" && !strings.HasSuffix(kubeBinary, ".exe") {
				kubeBinary += ".exe"
			}

			binaryFile := resolveBinaryLocation(kubeBinary)

			// check if already running
			out, err := exec.Command(binaryFile, "status").Output()
			if err != nil {
				util.Fatalf("Unable to get status %v", err)
			}

			doWait := false
			if err == nil && strings.Contains(string(out), "Running") {
				// already running
				util.Successf("%s already running\n", kubeBinary)

				kubectlBinaryFile := resolveBinaryLocation(kubectl)

				// setting context
				if kubeBinary == minikube {
					e := exec.Command(kubectlBinaryFile, "config", "use-context", kubeBinary)
					e.Stdout = os.Stdout
					e.Stderr = os.Stderr
					err = e.Run()
					if err != nil {
						util.Errorf("Unable to start %v", err)
					}
				} else {
					// minishift context has changed, we need to work it out now
					util.Info("minishift is already running, you can switch to the context\n")
				}

			} else {
				args := []string{"start"}

				vmDriverValue := cmd.Flags().Lookup(vmDriver).Value.String()
				if len(vmDriverValue) == 0 {
					switch runtime.GOOS {
					case "darwin":
						vmDriverValue = "xhyve"
					case "windows":
						vmDriverValue = "hyperv"
					case "linux":
						vmDriverValue = "kvm"
					default:
						vmDriverValue = "virtualbox"
					}

				}
				args = append(args, "--vm-driver="+vmDriverValue)

				// set memory flag
				memoryValue := cmd.Flags().Lookup(memory).Value.String()
				args = append(args, "--memory="+memoryValue)

				// set cpu flag
				cpusValue := cmd.Flags().Lookup(cpus).Value.String()
				args = append(args, "--cpus="+cpusValue)

				// set disk-size flag
				diskSizeValue := cmd.Flags().Lookup(diskSize).Value.String()
				args = append(args, "--disk-size="+diskSizeValue)

				// start the local VM
				logCommand(binaryFile, args)
				e := exec.Command(binaryFile, args...)
				e.Stdout = os.Stdout
				e.Stderr = os.Stderr
				err = e.Run()
//.........这里部分代码省略.........
开发者ID:fabric8io,项目名称:gofabric8,代码行数:101,代码来源:start.go


示例20: downloadOpenShiftClient

func downloadOpenShiftClient() (err error) {
	os := runtime.GOOS
	arch := runtime.GOARCH

	ocBinary := "oc"
	if runtime.GOOS == "windows" {
		ocBinary += ".exe"
	}

	_, err = exec.LookPath(ocBinary)
	if err != nil {

		// need to fix the version we download as not able to work out the oc sha in the URL yet
		sha := "dad658de7465ba8a234a4fb40b5b446a45a4cee1"
		latestVersion := "1.3.1"

		clientURL := fmt.Sprintf("https://github.com/openshift/origin/releases/download/v%s/openshift-origin-client-tools-v%s-%s", latestVersion, latestVersion, sha)

		extension := ".zip"
		switch runtime.GOOS {
		case "windows":
			clientURL += "-windows.zip"
		case "darwin":
			clientURL += "-mac.zip"
		default:
			extension = ".tar.gz"
			clientURL += fmt.Sprintf(clientURL+"-%s-%s.tar.gz", os, arch)
		}

		util.Infof("Downloading %s...\n", clientURL)

		writeFileLocation := getFabric8BinLocation()
		fullPath := filepath.Join(getFabric8BinLocation(), oc+extension)
		dotPath := filepath.Join(getFabric8BinLocation(), ".")

		err = downloadFile(fullPath, clientURL)
		if err != nil {
			util.Errorf("Unable to download file %s/%s %v", writeFileLocation+oc, clientURL, err)
			return err
		}

		switch runtime.GOOS {
		case "windows":
			err = unzip(fullPath, dotPath)
			if err != nil {
				util.Errorf("Unable to unzip %s %v", fullPath, err)
				return err
			}
		case "darwin":
			err = unzip(fullPath, dotPath)
			if err != nil {
				util.Errorf("Unable to unzip %s %v", fullPath, err)
				return err
			}
		default:
			err = unzip(fullPath, dotPath)
			if err != nil {
				util.Errorf("Unable to untar %s %v", writeFileLocation+oc+".tar.gz", err)
				return err
			}
		}

		util.Successf("Downloaded %s\n", oc)
	} else {
		util.Successf("%s is already available on your PATH\n", oc)
	}

	return nil
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:69,代码来源:install.go



注:本文中的github.com/fabric8io/gofabric8/util.Successf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.TypeOfMaster函数代码示例发布时间:2022-05-23
下一篇:
Golang util.Success函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap