本文整理匯總了Golang中github.com/openshift/origin/pkg/generate/app/cmd.AppConfig.Querying方法的典型用法代碼示例。如果您正苦於以下問題:Golang AppConfig.Querying方法的具體用法?Golang AppConfig.Querying怎麽用?Golang AppConfig.Querying使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/openshift/origin/pkg/generate/app/cmd.AppConfig
的用法示例。
在下文中一共展示了AppConfig.Querying方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RunNewApplication
// RunNewApplication contains all the necessary functionality for the OpenShift cli new-app command
func RunNewApplication(fullName string, f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
if err := setupAppConfig(f, c, args, config); err != nil {
return err
}
if config.Querying() {
result, err := config.RunQuery(out, c.Out())
if err != nil {
return handleRunError(c, err)
}
if len(cmdutil.GetFlagString(c, "output")) != 0 {
return f.Factory.PrintObject(c, result.List, out)
}
return printHumanReadableQueryResult(result, out, fullName)
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.RunAll(out, c.Out())
if err != nil {
return handleRunError(c, err)
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if len(cmdutil.GetFlagString(c, "output")) != 0 {
return f.Factory.PrintObject(c, result.List, out)
}
if err := createObjects(f, out, result); err != nil {
return err
}
hasMissingRepo := false
for _, item := range result.List.Items {
switch t := item.(type) {
case *kapi.Service:
portMappings := "."
if len(t.Spec.Ports) > 0 {
portMappings = fmt.Sprintf(" with port mappings %s.", describeServicePorts(t.Spec))
}
fmt.Fprintf(c.Out(), "Service %q created at %s%s\n", t.Name, t.Spec.ClusterIP, portMappings)
case *buildapi.BuildConfig:
fmt.Fprintf(c.Out(), "A build was created - you can run `%s start-build %s` to start it.\n", fullName, t.Name)
case *imageapi.ImageStream:
if len(t.Status.DockerImageRepository) == 0 {
if hasMissingRepo {
continue
}
hasMissingRepo = true
fmt.Fprintf(c.Out(), "WARNING: We created an image stream %q, but it does not look like a Docker registry has been integrated with the server. Automatic builds and deployments depend on that integration to detect new images and will not function properly.\n", t.Name)
}
}
}
fmt.Fprintf(c.Out(), "Run '%s status' to view your app.\n", fullName)
return nil
}
示例2: RunNewApplication
// RunNewApplication contains all the necessary functionality for the OpenShift cli new-app command
func RunNewApplication(fullName string, f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
output := cmdutil.GetFlagString(c, "output")
if err := setupAppConfig(f, out, c, args, config); err != nil {
return err
}
if config.Querying() {
result, err := config.RunQuery()
if err != nil {
return handleRunError(c, err, fullName)
}
if len(output) != 0 {
return f.Factory.PrintObject(c, result.List, out)
}
return printHumanReadableQueryResult(result, out, fullName)
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.RunAll()
if err != nil {
return handleRunError(c, err, fullName)
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewApp}, result); err != nil {
return err
}
if len(output) != 0 && output != "name" {
return f.Factory.PrintObject(c, result.List, out)
}
if err := createObjects(f, out, output == "name", result); err != nil {
return err
}
hasMissingRepo := false
for _, item := range result.List.Items {
switch t := item.(type) {
case *buildapi.BuildConfig:
if len(t.Spec.Triggers) > 0 {
fmt.Fprintf(c.Out(), "Build scheduled for %q - use the build-logs command to track its progress.\n", t.Name)
}
case *imageapi.ImageStream:
if len(t.Status.DockerImageRepository) == 0 {
if hasMissingRepo {
continue
}
hasMissingRepo = true
fmt.Fprint(c.Out(), "WARNING: No Docker registry has been configured with the server. Automatic builds and deployments may not function.\n")
}
}
}
if len(result.List.Items) > 0 {
fmt.Fprintf(c.Out(), "Run '%s %s' to view your app.\n", fullName, StatusRecommendedName)
}
return nil
}
示例3: RunNewApplication
// RunNewApplication contains all the necessary functionality for the OpenShift cli new-app command
func RunNewApplication(fullName string, f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
output := kcmdutil.GetFlagString(c, "output")
shortOutput := output == "name"
if err := setupAppConfig(f, out, c, args, config); err != nil {
return err
}
if config.Querying() {
result, err := config.RunQuery()
if err != nil {
return handleRunError(c, err, fullName)
}
if len(output) != 0 {
result.List.Items, err = ocmdutil.ConvertItemsForDisplayFromDefaultCommand(c, result.List.Items)
if err != nil {
return err
}
return f.Factory.PrintObject(c, result.List, out)
}
return printHumanReadableQueryResult(result, out, fullName)
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.Run()
if err := handleRunError(c, err, fullName); err != nil {
return err
}
if len(config.Labels) == 0 && len(result.Name) > 0 {
config.Labels = map[string]string{"app": result.Name}
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewApp}, result); err != nil {
return err
}
indent := " "
switch {
case shortOutput:
indent = ""
case len(output) != 0:
result.List.Items, err = ocmdutil.ConvertItemsForDisplayFromDefaultCommand(c, result.List.Items)
if err != nil {
return err
}
return f.Factory.PrintObject(c, result.List, out)
case !result.GeneratedJobs:
if len(config.Labels) > 0 {
fmt.Fprintf(out, "--> Creating resources with label %s ...\n", labels.SelectorFromSet(config.Labels).String())
} else {
fmt.Fprintf(out, "--> Creating resources ...\n")
}
}
if config.DryRun {
fmt.Fprintf(out, "--> Success (DRY RUN)\n")
return nil
}
mapper, _ := f.Object()
var afterFn configcmd.AfterFunc
switch {
// only print success if we don't have installables
case !result.GeneratedJobs:
afterFn = configcmd.NewPrintNameOrErrorAfterIndent(mapper, shortOutput, "created", out, c.Out(), indent)
default:
afterFn = configcmd.NewPrintErrorAfter(mapper, c.Out())
afterFn = configcmd.HaltOnError(afterFn)
}
if err := createObjects(f, afterFn, result); err != nil {
return err
}
if !shortOutput && !result.GeneratedJobs {
fmt.Fprintf(out, "--> Success\n")
}
hasMissingRepo := false
installing := []*kapi.Pod{}
for _, item := range result.List.Items {
switch t := item.(type) {
case *kapi.Pod:
if t.Annotations[newcmd.GeneratedForJob] == "true" {
installing = append(installing, t)
}
case *buildapi.BuildConfig:
triggered := false
for _, trigger := range t.Spec.Triggers {
switch trigger.Type {
//.........這裏部分代碼省略.........