本文整理匯總了Golang中github.com/fabric8io/gofabric8/util.Successf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Successf函數的具體用法?Golang Successf怎麽用?Golang Successf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Successf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
示例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
}
示例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)
}
}
示例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")
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}
}
}
示例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)
}
示例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
}
示例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
}
示例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")
}