Search in sources :

Example 61 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8 by jboss-fuse.

the class DeployToProfileMojoTest method before.

// Fixtures setup
@Before
public void before() {
    mojo.fabricServer = mock(Server.class);
    project = new MavenProject();
    project.setGroupId("io.fabric8");
    project.setArtifactId("artifact");
    project.setVersion(FABRIC_VERSION);
    mojo.project = project;
    deployResults = new DeployResults();
    deployResults.setProfileId("profileId");
    deployResults.setVersionId("versionId");
}
Also used : DeployResults(io.fabric8.deployer.dto.DeployResults) Server(org.apache.maven.settings.Server) MavenProject(org.apache.maven.project.MavenProject) Before(org.junit.Before)

Example 62 with Project

use of io.fabric8.openshift.api.model.Project in project jointware by isdream.

the class KubernetesKeyValueStyleGeneratorTest method testOpenShiftWithAllKind.

protected static void testOpenShiftWithAllKind() throws Exception {
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Policy());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Group());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new User());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthClient());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ClusterRoleBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ImageStreamTag());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ImageStream());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Build());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new BuildConfig());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new RoleBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Route());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new PolicyBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthAuthorizeToken());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Role());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Project());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthAccessToken());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new DeploymentConfig());
}
Also used : NetworkPolicy(io.fabric8.kubernetes.api.model.extensions.NetworkPolicy) Policy(io.fabric8.openshift.api.model.Policy) Group(io.fabric8.openshift.api.model.Group) User(io.fabric8.openshift.api.model.User) OAuthClient(io.fabric8.openshift.api.model.OAuthClient) ClusterRoleBinding(io.fabric8.openshift.api.model.ClusterRoleBinding) ImageStreamTag(io.fabric8.openshift.api.model.ImageStreamTag) ImageStream(io.fabric8.openshift.api.model.ImageStream) PolicyBinding(io.fabric8.openshift.api.model.PolicyBinding) OAuthAuthorizeToken(io.fabric8.openshift.api.model.OAuthAuthorizeToken) Role(io.fabric8.openshift.api.model.Role) Project(io.fabric8.openshift.api.model.Project) Build(io.fabric8.openshift.api.model.Build) OpenShiftDocumentKeyValueStyleGenerator(com.github.isdream.chameleon.docs.OpenShiftDocumentKeyValueStyleGenerator) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) OAuthAccessToken(io.fabric8.openshift.api.model.OAuthAccessToken) ClusterRoleBinding(io.fabric8.openshift.api.model.ClusterRoleBinding) RoleBinding(io.fabric8.openshift.api.model.RoleBinding) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Route(io.fabric8.openshift.api.model.Route)

Example 63 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class ResourceMojo method lateInit.

private void lateInit() throws MojoExecutionException {
    if (goalFinder.runningWithGoal(project, session, "fabric8:watch") || goalFinder.runningWithGoal(project, session, "fabric8:watch")) {
        Properties properties = project.getProperties();
        properties.setProperty("fabric8.watch", "true");
    }
    platformMode = clusterAccess.resolvePlatformMode(mode, log);
    log.info("Running in [[B]]%s[[B]] mode", platformMode.getLabel());
    if (isOpenShiftMode()) {
        Properties properties = project.getProperties();
        if (!properties.contains(DOCKER_IMAGE_USER)) {
            String namespace = clusterAccess.getNamespace();
            log.info("Using docker image name of namespace: " + namespace);
            properties.setProperty(DOCKER_IMAGE_USER, namespace);
        }
        if (!properties.contains(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE)) {
            properties.setProperty(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE, platformMode.toString());
        }
    }
    openShiftConverters = new HashMap<>();
    openShiftConverters.put("ReplicaSet", new ReplicSetOpenShiftConverter());
    openShiftConverters.put("Deployment", new DeploymentOpenShiftConverter(platformMode, getOpenshiftDeployTimeoutSeconds()));
    // TODO : This converter shouldn't be here. See its javadoc.
    openShiftConverters.put("DeploymentConfig", new DeploymentConfigOpenShiftConverter(getOpenshiftDeployTimeoutSeconds()));
    openShiftConverters.put("Namespace", new NamespaceOpenShiftConverter());
    handlerHub = new HandlerHub(project);
}
Also used : NamespaceOpenShiftConverter(io.fabric8.maven.plugin.converter.NamespaceOpenShiftConverter) DeploymentConfigOpenShiftConverter(io.fabric8.maven.plugin.converter.DeploymentConfigOpenShiftConverter) DeploymentOpenShiftConverter(io.fabric8.maven.plugin.converter.DeploymentOpenShiftConverter) Properties(java.util.Properties) ReplicSetOpenShiftConverter(io.fabric8.maven.plugin.converter.ReplicSetOpenShiftConverter) HandlerHub(io.fabric8.maven.core.handler.HandlerHub)

Example 64 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class HelmMojo method generateHelmChartDirectory.

protected void generateHelmChartDirectory(String chartName, HelmConfig.HelmType type) throws MojoExecutionException {
    File outputDir = prepareOutputDir(type);
    File sourceDir = checkSourceDir(chartName, type);
    if (sourceDir == null) {
        return;
    }
    log.info("Creating Helm Chart \"%s\" for %s", chartName, type.getDescription());
    log.verbose("SourceDir: %s", sourceDir);
    log.verbose("OutputDir: %s", outputDir);
    // Copy over all resource descriptors into the helm templates dir
    File templatesDir = copyResourceFilesToTemplatesDir(outputDir, sourceDir);
    // Save Helm chart
    createChartYaml(chartName, outputDir);
    // Copy over support files
    copyTextFile(outputDir, "README");
    copyTextFile(outputDir, "LICENSE");
    Template template = findTemplate();
    if (template != null) {
        createTemplateParameters(outputDir, template, templatesDir);
    }
    // now lets create the tarball
    File destinationFile = new File(project.getBuild().getDirectory(), chartName + "-" + project.getVersion() + "-" + type.getClassifier() + "." + getChartFileExtension());
    MavenUtil.createArchive(outputDir.getParentFile(), destinationFile, this.archiver);
    projectHelper.attachArtifact(project, getChartFileExtension(), type.getClassifier(), destinationFile);
}
Also used : File(java.io.File) Template(io.fabric8.openshift.api.model.Template)

Example 65 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class JavaExecGeneratorMainClassDeterminationTest method testMainClassDeterminationFromConfig.

/**
 * The main class is determined via config in a non-fat-jar deployment
 * @throws MojoExecutionException
 */
@Test
public void testMainClassDeterminationFromConfig() throws MojoExecutionException {
    new MockBuild();
    new MockProcessorConfig("the.main.ClassName");
    new MockMavenProject();
    final GeneratorContext generatorContext = new GeneratorContext.Builder().project(new MavenProject()).config(new ProcessorConfig()).strategy(OpenShiftBuildStrategy.docker).logger(log).build();
    JavaExecGenerator generator = new JavaExecGenerator(generatorContext);
    final List<ImageConfiguration> images = new ArrayList<ImageConfiguration>();
    List<ImageConfiguration> customized = generator.customize(images, false);
    assertEquals("1 images returned", (long) 1, (long) customized.size());
    ImageConfiguration imageConfig = customized.get(0);
    assertEquals("Image name", "TheImageName", imageConfig.getName());
    assertEquals("Main Class set as environment variable", "the.main.ClassName", imageConfig.getBuildConfiguration().getEnv().get(JavaExecGenerator.JAVA_MAIN_CLASS_ENV_VAR));
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) ArrayList(java.util.ArrayList) GeneratorContext(io.fabric8.maven.generator.api.GeneratorContext) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)51 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)29 File (java.io.File)14 Expectations (mockit.Expectations)14 ArrayList (java.util.ArrayList)13 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)11 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)11 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)9 IOException (java.io.IOException)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)8 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)7 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)6 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)5 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)5 MojoFailureException (org.apache.maven.plugin.MojoFailureException)5 MavenProject (org.apache.maven.project.MavenProject)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3