本文整理汇总了Golang中github.com/openshift/origin/pkg/generate/app/cmd.AppConfig类的典型用法代码示例。如果您正苦于以下问题:Golang AppConfig类的具体用法?Golang AppConfig怎么用?Golang AppConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: PrepareAppConfig
// PrepareAppConfig sets fields in config appropriate for running tests. It
// returns two buffers bound to stdout and stderr.
func PrepareAppConfig(config *cmd.AppConfig) (stdout, stderr *bytes.Buffer) {
config.ExpectToBuild = true
stdout, stderr = new(bytes.Buffer), new(bytes.Buffer)
config.Out, config.ErrOut = stdout, stderr
config.Detector = app.SourceRepositoryEnumerator{
Detectors: source.DefaultDetectors,
Tester: dockerfile.NewTester(),
}
config.DockerSearcher = app.DockerRegistrySearcher{
Client: dockerregistry.NewClient(10*time.Second, true),
}
config.ImageStreamByAnnotationSearcher = fakeImageStreamSearcher()
config.ImageStreamSearcher = fakeImageStreamSearcher()
config.OriginNamespace = "default"
config.OSClient = &client.Fake{}
config.RefBuilder = &app.ReferenceBuilder{}
config.TemplateSearcher = app.TemplateSearcher{
Client: &client.Fake{},
TemplateConfigsNamespacer: &client.Fake{},
Namespaces: []string{"openshift", "default"},
}
config.Typer = kapi.Scheme
return
}
开发者ID:enoodle,项目名称:origin,代码行数:27,代码来源:newapp_test.go
示例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 {
if err := setupAppConfig(f, c, args, config); err != nil {
return err
}
if config.AsSearch {
result, err := config.RunSearch(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 printHumanReadableSearchResult(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
}
开发者ID:bdmiller3,项目名称:origin,代码行数:60,代码来源:newapp.go
示例3: RunNewBuild
// RunNewBuild contains all the necessary functionality for the OpenShift cli new-build command
func RunNewBuild(fullName string, f *clientcmd.Factory, out io.Writer, in io.Reader, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
output := cmdutil.GetFlagString(c, "output")
if config.Dockerfile == "-" {
data, err := ioutil.ReadAll(in)
if err != nil {
return err
}
config.Dockerfile = string(data)
}
if err := setupAppConfig(f, out, c, args, config); err != nil {
return err
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.RunBuilds()
if err != nil {
if errs, ok := err.(errors.Aggregate); ok {
if len(errs.Errors()) == 1 {
err = errs.Errors()[0]
}
}
if err == newcmd.ErrNoInputs {
// TODO: suggest things to the user
return cmdutil.UsageError(c, "You must specify one or more images, image streams and source code locations to create a build configuration.")
}
return err
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewBuild}, 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
}
for _, item := range result.List.Items {
switch t := item.(type) {
case *buildapi.BuildConfig:
fmt.Fprintf(c.Out(), "Build configuration %q created and build triggered.\n", t.Name)
}
}
if len(result.List.Items) > 0 {
fmt.Fprintf(c.Out(), "Run '%s %s' to check the progress.\n", fullName, StatusRecommendedName)
}
return nil
}
开发者ID:porcelli,项目名称:origin,代码行数:57,代码来源:newbuild.go
示例4: 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
}
result, err := config.RunAll(out, c.Out())
if err != nil {
if errs, ok := err.(errors.Aggregate); ok {
if len(errs.Errors()) == 1 {
err = errs.Errors()[0]
}
}
if err == newcmd.ErrNoInputs {
// TODO: suggest things to the user
return cmdutil.UsageError(c, "You must specify one or more images, image streams, templates or source code locations to create an application.")
}
return err
}
if err := setLabels(c, 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 ImageStream %q, but it does not look like a Docker registry has been integrated with the OpenShift 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
}
开发者ID:heriipurnama,项目名称:origin,代码行数:55,代码来源:newapp.go
示例5: CompleteAppConfig
func CompleteAppConfig(config *newcmd.AppConfig, f *clientcmd.Factory, c *cobra.Command, args []string) error {
mapper, typer := f.Object(false)
if config.Mapper == nil {
config.Mapper = mapper
}
if config.Typer == nil {
config.Typer = typer
}
if config.ClientMapper == nil {
config.ClientMapper = resource.ClientMapperFunc(f.ClientForMapping)
}
namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}
osclient, _, kclient, err := f.Clients()
if err != nil {
return err
}
config.KubeClient = kclient
dockerClient, _ := getDockerClient()
config.SetOpenShiftClient(osclient, namespace, dockerClient)
if config.AllowSecretUse {
cfg, err := f.OpenShiftClientConfig.ClientConfig()
if err != nil {
return err
}
config.SecretAccessor = newConfigSecretRetriever(cfg)
}
unknown := config.AddArguments(args)
if len(unknown) != 0 {
return kcmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown)
}
if config.AllowMissingImages && config.AsSearch {
return kcmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.")
}
if len(config.SourceImage) != 0 && len(config.SourceImagePath) == 0 {
return kcmdutil.UsageError(c, "--source-image-path must be specified when --source-image is specified.")
}
if len(config.SourceImage) == 0 && len(config.SourceImagePath) != 0 {
return kcmdutil.UsageError(c, "--source-image must be specified when --source-image-path is specified.")
}
if config.BinaryBuild && config.Strategy == generate.StrategyPipeline {
return kcmdutil.UsageError(c, "specifying binary builds and the pipeline strategy at the same time is not allowed.")
}
return nil
}
开发者ID:nak3,项目名称:origin,代码行数:55,代码来源:newapp.go
示例6: setupAppConfig
func setupAppConfig(f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}
dockerClient, _, err := dockerutil.NewHelper().GetClient()
if err == nil {
if err = dockerClient.Ping(); err == nil {
config.SetDockerClient(dockerClient)
}
}
if err != nil {
glog.V(2).Infof("No local Docker daemon detected: %v", err)
}
osclient, _, err := f.Clients()
if err != nil {
return err
}
config.SetOpenShiftClient(osclient, namespace)
config.Out = out
config.ErrOut = c.Out()
unknown := config.AddArguments(args)
if len(unknown) != 0 {
return cmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown)
}
if config.AllowMissingImages && config.AsSearch {
return cmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.")
}
return nil
}
开发者ID:sztsian,项目名称:origin,代码行数:34,代码来源:newapp.go
示例7: RunNewBuild
// RunNewBuild contains all the necessary functionality for the OpenShift cli new-build command
func RunNewBuild(fullName string, f *clientcmd.Factory, out io.Writer, in io.Reader, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
output := cmdutil.GetFlagString(c, "output")
if config.Dockerfile == "-" {
data, err := ioutil.ReadAll(in)
if err != nil {
return err
}
config.Dockerfile = string(data)
}
if err := setupAppConfig(f, out, c, args, config); err != nil {
return err
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.RunBuilds()
if err != nil {
return handleBuildError(c, err, fullName)
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewBuild}, result); err != nil {
return err
}
if len(output) != 0 && output != "name" {
return f.Factory.PrintObject(c, result.List, out)
}
if err := createObjects(f, out, c.Out(), output == "name", true, result); err != nil {
return err
}
for _, item := range result.List.Items {
switch t := item.(type) {
case *buildapi.BuildConfig:
fmt.Fprintf(c.Out(), "Build configuration %q created and build triggered.\n", t.Name)
}
}
if len(result.List.Items) > 0 {
fmt.Fprintf(c.Out(), "Run '%s %s' to check the progress.\n", fullName, StatusRecommendedName)
}
return nil
}
开发者ID:hloganathan,项目名称:origin,代码行数:48,代码来源:newbuild.go
示例8: setupAppConfig
func setupAppConfig(f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}
osclient, kclient, err := f.Clients()
if err != nil {
return err
}
config.KubeClient = kclient
dockerClient, _ := getDockerClient()
config.SetOpenShiftClient(osclient, namespace, dockerClient)
// Only output="" should print descriptions of intermediate steps. Everything
// else should print only some specific output (json, yaml, go-template, ...)
output := kcmdutil.GetFlagString(c, "output")
if len(output) == 0 {
config.Out = out
} else {
config.Out = ioutil.Discard
}
config.ErrOut = c.Out()
if config.AllowSecretUse {
cfg, err := f.OpenShiftClientConfig.ClientConfig()
if err != nil {
return err
}
config.SecretAccessor = newConfigSecretRetriever(cfg)
}
unknown := config.AddArguments(args)
if len(unknown) != 0 {
return kcmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown)
}
if config.AllowMissingImages && config.AsSearch {
return kcmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.")
}
if len(config.SourceImage) != 0 && len(config.SourceImagePath) == 0 {
return kcmdutil.UsageError(c, "--source-image-path must be specified when --source-image is specified.")
}
if len(config.SourceImage) == 0 && len(config.SourceImagePath) != 0 {
return kcmdutil.UsageError(c, "--source-image must be specified when --source-image-path is specified.")
}
return nil
}
开发者ID:poomsujarit,项目名称:origin,代码行数:49,代码来源:newapp.go
示例9: RunNewBuild
// RunNewBuild contains all the necessary functionality for the OpenShift cli new-build command
func RunNewBuild(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 err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.RunBuilds(out, c.Out())
if err != nil {
if errs, ok := err.(errors.Aggregate); ok {
if len(errs.Errors()) == 1 {
err = errs.Errors()[0]
}
}
if err == newcmd.ErrNoInputs {
// TODO: suggest things to the user
return cmdutil.UsageError(c, "You must specify one or more images, image streams and source code locations to create a build configuration.")
}
return err
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewBuild}, 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
}
for _, item := range result.List.Items {
switch t := item.(type) {
case *buildapi.BuildConfig:
fmt.Fprintf(c.Out(), "A build configuration was created - you can run `%s start-build %s` to start it.\n", fullName, t.Name)
}
}
return nil
}
开发者ID:hferentschik,项目名称:origin,代码行数:44,代码来源:newbuild.go
示例10: setupAppConfig
func setupAppConfig(f *clientcmd.Factory, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}
dockerClient, _, err := dockerutil.NewHelper().GetClient()
if err == nil {
if err = dockerClient.Ping(); err == nil {
config.SetDockerClient(dockerClient)
}
}
if err != nil {
glog.V(2).Infof("No local Docker daemon detected: %v", err)
}
osclient, _, err := f.Clients()
if err != nil {
return err
}
config.SetOpenShiftClient(osclient, namespace)
unknown := config.AddArguments(args)
if len(unknown) != 0 {
return cmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown)
}
return nil
}
开发者ID:patrykattc,项目名称:origin,代码行数:29,代码来源:newapp.go
示例11: 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
}
开发者ID:sztsian,项目名称:origin,代码行数:65,代码来源:newapp.go
示例12: 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 {
//.........这里部分代码省略.........
开发者ID:poomsujarit,项目名称:origin,代码行数:101,代码来源:newapp.go
示例13: TestNewAppAddArguments
func TestNewAppAddArguments(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "test-newapp")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer os.RemoveAll(tmpDir)
testDir := filepath.Join(tmpDir, "test/one/two/three")
err = os.MkdirAll(testDir, 0777)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
tests := map[string]struct {
args []string
env []string
parms []string
repos []string
components []string
unknown []string
}{
"components": {
args: []string{"one", "two+three", "four~five"},
components: []string{"one", "two+three", "four~five"},
unknown: []string{},
},
"source": {
args: []string{".", testDir, "git://github.com/openshift/origin.git"},
repos: []string{".", testDir, "git://github.com/openshift/origin.git"},
unknown: []string{},
},
"source custom ref": {
args: []string{"https://github.com/openshift/ruby-hello-world#beta4"},
repos: []string{"https://github.com/openshift/ruby-hello-world#beta4"},
unknown: []string{},
},
"env": {
args: []string{"first=one", "second=two", "third=three"},
env: []string{"first=one", "second=two", "third=three"},
unknown: []string{},
},
"mix 1": {
args: []string{"git://github.com/openshift/origin.git", "[email protected]/openshift/origin.git", "env1=test", "ruby-helloworld-sample"},
repos: []string{"git://github.com/openshift/origin.git"},
components: []string{"[email protected]/openshift/origin.git", "ruby-helloworld-sample"},
env: []string{"env1=test"},
unknown: []string{},
},
}
for n, c := range tests {
a := cmd.AppConfig{}
unknown := a.AddArguments(c.args)
if !reflect.DeepEqual(a.Environment, c.env) {
t.Errorf("%s: Different env variables. Expected: %v, Actual: %v", n, c.env, a.Environment)
}
if !reflect.DeepEqual(a.SourceRepositories, c.repos) {
t.Errorf("%s: Different source repos. Expected: %v, Actual: %v", n, c.repos, a.SourceRepositories)
}
if !reflect.DeepEqual(a.Components, c.components) {
t.Errorf("%s: Different components. Expected: %v, Actual: %v", n, c.components, a.Components)
}
if !reflect.DeepEqual(unknown, c.unknown) {
t.Errorf("%s: Different unknown result. Expected: %v, Actual: %v", n, c.unknown, unknown)
}
}
}
开发者ID:enoodle,项目名称:origin,代码行数:68,代码来源:newapp_test.go
示例14: RunNewBuild
// RunNewBuild contains all the necessary functionality for the OpenShift cli new-build command
func RunNewBuild(fullName string, f *clientcmd.Factory, out io.Writer, in io.Reader, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
output := kcmdutil.GetFlagString(c, "output")
shortOutput := output == "name"
if config.Dockerfile == "-" {
data, err := ioutil.ReadAll(in)
if err != nil {
return err
}
config.Dockerfile = string(data)
}
if err := setupAppConfig(f, out, c, args, config); err != nil {
return err
}
if err := setAppConfigLabels(c, config); err != nil {
return err
}
result, err := config.Run()
if err != nil {
return handleBuildError(c, err, fullName)
}
if len(config.Labels) == 0 && len(result.Name) > 0 {
config.Labels = map[string]string{"build": result.Name}
}
if err := setLabels(config.Labels, result); err != nil {
return err
}
if err := setAnnotations(map[string]string{newcmd.GeneratedByNamespace: newcmd.GeneratedByNewBuild}, 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)
default:
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()
if err := createObjects(f, configcmd.NewPrintNameOrErrorAfterIndent(mapper, shortOutput, "created", out, c.Out(), indent), result); err != nil {
return err
}
if shortOutput {
return nil
}
fmt.Fprintf(out, "--> Success\n")
for _, item := range result.List.Items {
switch t := item.(type) {
case *buildapi.BuildConfig:
if len(t.Spec.Triggers) > 0 && t.Spec.Source.Binary == nil {
fmt.Fprintf(out, "%sBuild configuration %q created and build triggered.\n", indent, t.Name)
fmt.Fprintf(out, "%sRun '%s logs -f bc/%s' to stream the build progress.\n", indent, fullName, t.Name)
}
}
}
return nil
}
开发者ID:jwforres,项目名称:origin,代码行数:81,代码来源:newbuild.go
示例15: setupAppConfig
func setupAppConfig(f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error {
namespace, _, err := f.DefaultNamespace()
if err != nil {
return err
}
dockerClient, _, err := dockerutil.NewHelper().GetClient()
if err == nil {
if err = dockerClient.Ping(); err == nil {
config.SetDockerClient(dockerClient)
} else {
glog.V(4).Infof("Docker client did not respond to a ping: %v", err)
}
}
if err != nil {
glog.V(2).Infof("No local Docker daemon detected: %v", err)
}
osclient, kclient, err := f.Clients()
if err != nil {
return err
}
config.KubeClient = kclient
config.SetOpenShiftClient(osclient, namespace)
// Only output="" should print descriptions of intermediate steps. Everything
// else should print only some specific output (json, yaml, go-template, ...)
output := cmdutil.GetFlagString(c, "output")
if len(output) == 0 {
config.Out = out
} else {
config.Out = ioutil.Discard
}
config.ErrOut = c.Out()
if config.AllowSecretUse {
cfg, err := f.OpenShiftClientConfig.ClientConfig()
if err != nil {
return err
}
config.SecretAccessor = newConfigSecretRetriever(cfg)
}
unknown := config.AddArguments(args)
if len(unknown) != 0 {
return cmdutil.UsageError(c, "Did not recognize the following arguments: %v", unknown)
}
if config.AllowMissingImages && config.AsSearch {
return cmdutil.UsageError(c, "--allow-missing-images and --search are mutually exclusive.")
}
return nil
}
开发者ID:abhat,项目名称:origin,代码行数:53,代码来源:newapp.go
注:本文中的github.com/openshift/origin/pkg/generate/app/cmd.AppConfig类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论