Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2015 Red Hat, Inc. Red Hat licenses this file to you under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package io.fabric8.forge.kubernetes;
 
 import  org.jboss.forge.addon.projects.ProjectFactory;
 import  org.jboss.forge.addon.projects.ui.AbstractProjectCommand;
 import  org.jboss.forge.addon.ui.UIProvider;
 import  org.jboss.forge.addon.ui.command.UICommand;
 import  org.jboss.forge.addon.ui.context.UIBuilder;
 import  org.jboss.forge.addon.ui.input.UIInput;
 import  org.jboss.forge.addon.ui.metadata.WithAttributes;
 import  org.jboss.forge.addon.ui.output.UIOutput;
 import  org.jboss.forge.addon.ui.result.Result;
 import  org.jboss.forge.addon.ui.result.Results;
 
 import  javax.inject.Inject;
An abstract base class for kubernetes related commands
 
 public abstract class AbstractKubernetesCommand extends AbstractProjectCommand implements UICommand {
     public static String CATEGORY = "Kubernetes";
     private static String namespace;
 
     private KubernetesClient kubernetes;
 
     @Inject
     private ProjectFactory projectFactory;
 
     /*
         @Inject
     */
     UIProvider uiProvider;
 
     @Inject
     @WithAttributes(name = "kubernetesUrl", label = "The URL where the kubernetes master is running")
     UIInput<StringkubernetesUrl;
 
     @Override
     protected boolean isProjectRequired() {
         return false;
     }
 
     @Override
     protected ProjectFactory getProjectFactory() {
         return ;
     }
 
     public KubernetesClient getKubernetes() {
         if ( == null) {
             String kubernetesAddress = .getValue();
             if (Strings.isNotBlank(kubernetesAddress)) {
                  = new KubernetesClient(new KubernetesFactory(kubernetesAddress));
             } else {
                  = new KubernetesClient();
             }
             if ( != null) {
                 .setNamespace();
             }
         }
         Objects.notNull("kubernetes");
         return ;
     }
 
     public void setKubernetes(KubernetesClient kubernetes) {
         this. = kubernetes;
     }
 
     public boolean isGUI() {
         return getUiProvider().isGUI();
     }
 
     public UIOutput getOutput() {
         UIProvider provider = getUiProvider();
         return provider != null ? provider.getOutput() : null;
     }
 
     public UIProvider getUiProvider() {
         return ;
     }
    public void setUiProvider(UIProvider uiProvider) {
        this. = uiProvider;
    }
    @Override
    public void initializeUI(UIBuilder uiBuilderthrows Exception {
    }

    
Prints the given table and returns success
    protected Result tableResults(TablePrinter table) {
        table.print(getOut());
        return Results.success();
    }
    public PrintStream getOut() {
        UIOutput output = getOutput();
        if (output != null) {
            return output.out();
        } else {
            return .;
        }
    }
    public String getNamespace() {
        return getKubernetes().getNamespace();
    }
    public void setNamespace(String namespace) {
        . = namespace;
        if ( != null) {
            .setNamespace(namespace);
        }
    }
New to GrepCode? Check out our FAQ X