当前位置: 首页>>代码示例>>Golang>>正文


Golang util.Success函数代码示例

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


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

示例1: logPackageVersion

func logPackageVersion(packageName string, version string) {
	util.Info("Deploying package: ")
	util.Success(packageName)
	util.Info(" version: ")
	util.Success(version)
	util.Info("\n\n")
}
开发者ID:fabric8io,项目名称:gofabric8,代码行数:7,代码来源:deploy.go

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: downloadDriver

func downloadDriver() (err error) {

	if runtime.GOOS == "darwin" {
		util.Infof("fabric8 recommends OSX users use the xhyve driver\n")
		info, err := exec.Command("brew", "info", "docker-machine-driver-xhyve").Output()

		if err != nil || strings.Contains(string(info), "Not installed") {
			e := exec.Command("brew", "install", "docker-machine-driver-xhyve")
			e.Stdout = os.Stdout
			e.Stderr = os.Stderr
			err = e.Run()
			if err != nil {
				return err
			}

			out, err := exec.Command("brew", "--prefix").Output()
			if err != nil {
				return err
			}

			brewPrefix := strings.TrimSpace(string(out))

			file := string(brewPrefix) + "/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve"
			e = exec.Command("sudo", "chown", "root:wheel", file)
			e.Stdout = os.Stdout
			e.Stderr = os.Stderr
			err = e.Run()
			if err != nil {
				return err
			}

			e = exec.Command("sudo", "chmod", "u+s", file)
			e.Stdout = os.Stdout
			e.Stderr = os.Stderr
			err = e.Run()
			if err != nil {
				return err
			}

			util.Success("xhyve driver installed\n")
		} else {
			util.Success("xhyve driver already installed\n")
		}

	} else if runtime.GOOS == "linux" {
		return errors.New("Driver install for " + runtime.GOOS + " not yet supported")
	}
	return nil
}
开发者ID:gashcrumb,项目名称:gofabric8,代码行数:49,代码来源:install.go

示例8: NewCmdPull

func NewCmdPull(f *cmdutil.Factory) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "pull [templateNames]",
		Short: "Pulls the docker images for the given templates",
		Long:  `Performs a docker pull on all the docker images referenced in the given templates to preload the local docker registry with images`,
		PreRun: func(cmd *cobra.Command, args []string) {
			showBanner()
		},
		Run: func(cmd *cobra.Command, args []string) {
			if len(args) < 1 {
				util.Error("No template names specified!")
				cmd.Usage()
			} else {
				_, cfg := client.NewClient(f)
				oc, _ := client.NewOpenShiftClient(cfg)
				ns, _, err := f.DefaultNamespace()
				if err != nil {
					util.Fatal("No default namespace")
				} else {
					for _, template := range args {
						util.Info("Downloading docker images for template ")
						util.Success(template)
						util.Info("\n\n")

						r, err := downloadTemplateDockerImages(cmd, ns, oc, f, template)
						printResult("Download Docker images", r, err)
					}
				}
			}
		},
	}
	return cmd
}
开发者ID:MarWestermann,项目名称:gofabric8,代码行数:33,代码来源:pull.go

示例9: 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

示例10: cleanUp

func cleanUp(f *cmdutil.Factory) error {
	c, cfg := client.NewClient(f)
	ns, _, _ := f.DefaultNamespace()
	typeOfMaster := util.TypeOfMaster(c)
	selector, err := unversioned.LabelSelectorAsSelector(&unversioned.LabelSelector{MatchLabels: map[string]string{"provider": "fabric8"}})
	if err != nil {
		return err
	}
	if typeOfMaster == util.OpenShift {
		oc, _ := client.NewOpenShiftClient(cfg)
		cleanUpOpenshiftResources(c, oc, ns, selector)
	}

	cleanUpKubernetesResources(c, ns, selector)

	util.Success("Successfully cleaned up\n")
	return nil
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:18,代码来源:cleanup.go

示例11: downloadDockerImage

func downloadDockerImage(imageName string) error {
	util.Info("Downloading image ")
	util.Success(imageName)
	util.Info("\n")

	cmd := exec.Command("docker", "pull", imageName)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	var waitStatus syscall.WaitStatus
	if err := cmd.Run(); err != nil {
		printErr(err)
		if exitError, ok := err.(*exec.ExitError); ok {
			waitStatus = exitError.Sys().(syscall.WaitStatus)
			printStatus(waitStatus.ExitStatus())
		}
		return err
	} else {
		waitStatus = cmd.ProcessState.Sys().(syscall.WaitStatus)
		printStatus(waitStatus.ExitStatus())
		return nil
	}
}
开发者ID:MarWestermann,项目名称:gofabric8,代码行数:22,代码来源:pull.go

示例12: 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

示例13: deploy

func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
	c, cfg := client.NewClient(f)
	ns, _, _ := f.DefaultNamespace()

	domain := d.domain
	dockerRegistry := d.dockerRegistry

	mini, err := util.IsMini()
	if err != nil {
		util.Failuref("error checking if minikube or minishift %v", err)
	}

	packageName := d.packageName
	if len(packageName) == 0 {
		util.Fatalf("Missing value for --%s", packageFlag)
	}

	typeOfMaster := util.TypeOfMaster(c)

	// extract the ip address from the URL
	u, err := url.Parse(cfg.Host)
	if err != nil {
		util.Fatalf("%s", err)
	}

	ip, _, err := net.SplitHostPort(u.Host)
	if err != nil && !strings.Contains(err.Error(), "missing port in address") {
		util.Fatalf("%s", err)
	}

	// default xip domain if local deployment incase users deploy ingress controller or router
	if mini && typeOfMaster == util.OpenShift {
		domain = ip + ".xip.io"
	}

	// default to the server from the current context
	apiserver := u.Host
	if d.apiserver != "" {
		apiserver = d.apiserver
	}

	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)

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

	if len(dockerRegistry) > 0 {
		util.Infof("Loading fabric8 docker images from docker registry: %s\n", dockerRegistry)
	}

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

	if len(d.appToRun) > 0 {
		util.Warn("Please note that the --app parameter is now deprecated.\n")
		util.Warn("Please use the --package argument to specify a package like `platform`, `console`, `ipaas` or to refer to a URL or file of the YAML package to install\n")
	}

	if strings.Contains(domain, "=") {
		util.Warnf("\nInvalid domain: %s\n\n", domain)
	} else if confirmAction(d.yes) {

		oc, _ := client.NewOpenShiftClient(cfg)

		initSchema()

		ensureNamespaceExists(c, oc, ns)

		versionPlatform := ""
		baseUri := ""
		switch packageName {
		case "":
		case platformPackage:
			baseUri = platformPackageUrlPrefix
			versionPlatform = versionForUrl(d.versionPlatform, urlJoin(mavenRepo, platformMetadataUrl))
			logPackageVersion(packageName, versionPlatform)
		case consolePackage:
			baseUri = consolePackageUrlPrefix
			versionPlatform = versionForUrl(d.versionPlatform, urlJoin(mavenRepo, consolePackageMetadataUrl))
			logPackageVersion(packageName, versionPlatform)
		case iPaaSPackage:
			baseUri = ipaasPackageUrlPrefix
			versionPlatform = versionForUrl(d.versioniPaaS, urlJoin(mavenRepo, ipaasMetadataUrl))
			logPackageVersion(packageName, versionPlatform)
		default:
			baseUri = ""
		}
		uri := ""
//.........这里部分代码省略.........
开发者ID:fabric8io,项目名称:gofabric8,代码行数:101,代码来源:deploy.go

示例14: 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)

			yes := cmd.Flags().Lookup(yesFlag).Value.String() == "false"
			if confirmAction(yes) {
				tapi.AddToScheme(api.Scheme)
				tapiv1.AddToScheme(api.Scheme)
				count := 0

				typeOfMaster := util.TypeOfMaster(c)

				catalogSelector := map[string]string{
					"provider": "fabric8.io",
					"kind":     "catalog",
				}
				configmaps, err := c.ConfigMaps(ns).List(api.ListOptions{
					LabelSelector: labels.Set(catalogSelector).AsSelector(),
				})
				if err != nil {
					fmt.Println("Failed to load Catalog configmaps %s", err)
				} else {
					for _, configmap := range configmaps.Items {
						for key, data := range configmap.Data {
							obj, err := runtime.Decode(api.Codecs.UniversalDecoder(), []byte(data))
							if err != nil {
								util.Infof("Failed to decodeconfig map %s with key %s. Got error: %s", configmap.ObjectMeta.Name, key, err)
							} else {
								switch rc := obj.(type) {
								case *api.ReplicationController:
									for secretType, secretDataIdentifiers := range rc.Spec.Template.Annotations {
										count += createAndPrintSecrets(secretDataIdentifiers, secretType, c, f, cmd.Flags())
									}
								case *tapi.Template:
									count += processSecretsForTemplate(c, *rc, f, cmd)
								}
							}
						}
					}
				}

				if typeOfMaster != util.Kubernetes {
					oc, _ := client.NewOpenShiftClient(cfg)
					t := getTemplates(oc, ns)

					// get all the Templates and find the annotations on any Pods
					for _, i := range t.Items {
						count += processSecretsForTemplate(c, i, f, cmd)
					}
				}

				if count == 0 {
					util.Info("No secrets created as no fabric8 secrets annotations found in the Fabric8 Catalog\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:fabric8io,项目名称:gofabric8,代码行数:77,代码来源:secrets.go

示例15: 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()
			util.Info("Deploying fabric8 to 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()) {
				v := cmd.Flags().Lookup("version").Value.String()

				typeOfMaster := util.TypeOfMaster(c)
				v = f8Version(v, typeOfMaster)

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

				util.Warnf("\nStarting deployment of %s...\n\n", v)

				if typeOfMaster == util.Kubernetes {
					uri := fmt.Sprintf(baseConsoleKubernetesUrl, v)
					filenames := []string{uri}

					createCmd := cobra.Command{}
					createCmd.Flags().StringSlice("filename", filenames, "")
					err := kcmd.RunCreate(f, &createCmd, ioutil.Discard)
					if err != nil {
						printResult("fabric8 console", Failure, err)
					} else {
						printResult("fabric8 console", Success, nil)
					}
				} else {
					oc, _ := client.NewOpenShiftClient(cfg)

					r, err := verifyRestrictedSecurityContextConstraints(c, f)
					printResult("SecurityContextConstraints restricted", r, err)
					r, err = deployFabric8SecurityContextConstraints(c, f, ns)
					printResult("SecurityContextConstraints fabric8", r, err)

					printAddClusterRoleToUser(oc, f, "cluster-admin", "system:serviceaccount:"+ns+":fabric8")
					printAddClusterRoleToUser(oc, f, "cluster-admin", "system:serviceaccount:"+ns+":jenkins")
					printAddClusterRoleToUser(oc, f, "cluster-reader", "system:serviceaccount:"+ns+":metrics")

					printAddServiceAccount(c, f, "metrics")
					printAddServiceAccount(c, f, "router")

					if cmd.Flags().Lookup(templatesFlag).Value.String() == "true" {
						uri := fmt.Sprintf(baseConsoleUrl, v)
						resp, err := http.Get(uri)
						if err != nil {
							util.Fatalf("Cannot get fabric8 template to deploy: %v", err)
						}
						defer resp.Body.Close()
						jsonData, err := ioutil.ReadAll(resp.Body)
						if err != nil {
							util.Fatalf("Cannot get fabric8 template to deploy: %v", err)
						}
						var v1tmpl tapiv1.Template
						err = json.Unmarshal(jsonData, &v1tmpl)
						if err != nil {
							util.Fatalf("Cannot get fabric8 template to deploy: %v", err)
						}
						var tmpl tapi.Template

						err = api.Scheme.Convert(&v1tmpl, &tmpl)
						if err != nil {
							util.Fatalf("Cannot get fabric8 template to deploy: %v", err)
						}

						generators := map[string]generator.Generator{
							"expression": generator.NewExpressionValueGenerator(rand.New(rand.NewSource(time.Now().UnixNano()))),
						}
						p := template.NewProcessor(generators)

						tmpl.Parameters = append(tmpl.Parameters, tapi.Parameter{
							Name:  "DOMAIN",
							Value: cmd.Flags().Lookup("domain").Value.String(),
						})

						p.Process(&tmpl)

						for _, o := range tmpl.Objects {
							switch o := o.(type) {
							case *runtime.Unstructured:
								var b []byte
								b, err = json.Marshal(o.Object)
								if err != nil {
									break
								}
								req := c.Post().Body(b)
//.........这里部分代码省略.........
开发者ID:Dumidu,项目名称:gofabric8,代码行数:101,代码来源:deploy.go


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