use of org.eclipse.jkube.kit.common.KitLogger in project jkube by eclipse.
the class ApplyMojo method applyEntities.
protected void applyEntities(final KubernetesClient kubernetes, String fileName, final Collection<HasMetadata> entities) throws InterruptedException {
KitLogger serviceLogger = createLogger("[[G]][SVC][[G]] [[s]]");
applyService.applyEntities(fileName, entities, serviceLogger, serviceUrlWaitTimeSeconds);
}
use of org.eclipse.jkube.kit.common.KitLogger in project jkube by eclipse.
the class OpenshiftBuildServiceIntegrationTest method init.
@Before
public void init() throws Exception {
final KitLogger logger = new KitLogger.StdoutLogger();
baseDirectory = temporaryFolder.newFolder("openshift-build-service");
target = temporaryFolder.newFolder("openshift-build-service", "target");
final File emptyDockerBuildTar = new File(target, "docker-build.tar");
FileUtils.touch(emptyDockerBuildTar);
baseDir = baseDirectory.getAbsolutePath();
projectName = "myapp";
FileUtils.deleteDirectory(new File(baseDir, projectName));
final File dockerFile = new File(baseDir, "Docker.tar");
FileUtils.touch(dockerFile);
openshiftHelper = mockStatic(OpenshiftHelper.class);
openshiftHelper.when(() -> OpenshiftHelper.isOpenShift(eq(mockServer.getOpenshiftClient()))).thenReturn(true);
jKubeBuildTarArchiver = mockConstruction(JKubeBuildTarArchiver.class, (mock, ctx) -> when(mock.createArchive(any(File.class), any(BuildDirs.class), eq(ArchiveCompression.none))).thenReturn(emptyDockerBuildTar));
mockedResourceConfig = mock(ResourceConfig.class, RETURNS_DEEP_STUBS);
when(mockedResourceConfig.getNamespace()).thenReturn("ns1");
jKubeServiceHub = mock(JKubeServiceHub.class, RETURNS_DEEP_STUBS);
when(jKubeServiceHub.getClusterAccess().createDefaultClient()).thenReturn(mockServer.getOpenshiftClient());
when(jKubeServiceHub.getLog()).thenReturn(logger);
when(jKubeServiceHub.getDockerServiceHub().getArchiveService()).thenReturn(new ArchiveService(AssemblyManager.getInstance(), logger));
when(jKubeServiceHub.getBuildServiceConfig().getBuildDirectory()).thenReturn(target.getAbsolutePath());
when(jKubeServiceHub.getConfiguration()).thenReturn(JKubeConfiguration.builder().outputDirectory(target.getAbsolutePath()).project(JavaProject.builder().baseDirectory(baseDirectory).buildDirectory(target).build()).registryConfig(RegistryConfig.builder().build()).build());
image = ImageConfiguration.builder().name(projectName).build(BuildConfiguration.builder().from(projectName).build()).build();
defaultConfig = BuildServiceConfig.builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-s2i-suffix2").resourceConfig(mockedResourceConfig).jKubeBuildStrategy(JKubeBuildStrategy.s2i);
defaultConfigSecret = defaultConfig.build().toBuilder().openshiftPullSecret("pullsecret-fabric8");
dockerImageConfig = defaultConfig.build().toBuilder().buildOutputKind("DockerImage");
dockerImageConfigSecret = defaultConfig.build().toBuilder().openshiftPullSecret("pullsecret-fabric8").openshiftPushSecret("pushsecret-fabric8").buildOutputKind("DockerImage");
Serialization.jsonMapper().disable(SerializationFeature.INDENT_OUTPUT);
}
use of org.eclipse.jkube.kit.common.KitLogger in project jkube by eclipse.
the class GeneratorManager method generate.
public static List<ImageConfiguration> generate(List<ImageConfiguration> imageConfigs, GeneratorContext genCtx, boolean prePackagePhase) {
final PluginServiceFactory<GeneratorContext> pluginFactory = new PluginServiceFactory<>(genCtx);
if (genCtx.isUseProjectClasspath()) {
pluginFactory.addAdditionalClassLoader(ClassUtil.createProjectClassLoader(genCtx.getProject().getCompileClassPathElements(), genCtx.getLogger()));
}
List<ImageConfiguration> ret = imageConfigs;
final KitLogger log = genCtx.getLogger();
final List<Generator> generators = pluginFactory.createServiceObjects(SERVICE_PATHS);
final List<Generator> usableGenerators = genCtx.getConfig().prepareProcessors(generators, "generator");
log.verbose("Generators:");
for (Generator generator : usableGenerators) {
log.verbose(" - %s", generator.getName());
if (generator.isApplicable(ret)) {
log.info("Running generator %s", generator.getName());
ret = generator.customize(ret, prePackagePhase);
}
}
return ret;
}
use of org.eclipse.jkube.kit.common.KitLogger in project jkube by eclipse.
the class TaskUtilTest method setUp.
@Before
public void setUp() {
extension = new TestKubernetesExtension();
kitLogger = mock(KitLogger.class, RETURNS_DEEP_STUBS);
}
use of org.eclipse.jkube.kit.common.KitLogger in project jkube by eclipse.
the class Main method main.
public static void main(String[] args) {
final KitLogger kitLogger = new KitLogger.StdoutLogger();
kitLogger.info("Initiating default JKube configuration and required services...");
kitLogger.info(" - Creating Docker Build Service Configuration");
final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
kitLogger.info(" - Creating configuration for JKube");
kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").build();
kitLogger.info("Creating configuration for example Docker Image");
final ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("jkube-example").run(RunImageConfiguration.builder().user("1000").build()).build(BuildConfiguration.builder().putEnv("MY_VAR", "value").putEnv("MY_OTHER_VAR", "true").label("maintainer", "JKube Devs").port("80/tcp").maintainer("JKube Devs").from("busybox").assembly(AssemblyConfiguration.builder().targetDir("/").layer(Assembly.builder().fileSet(AssemblyFileSet.builder().directory(new File("static")).build()).build()).build()).cmd(Arguments.builder().shell("/bin/sh").build()).build()).build();
try (JKubeServiceHub jKubeServiceHub = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(DockerServiceHub.newInstance(kitLogger)).buildServiceConfig(dockerBuildServiceConfig).build()) {
jKubeServiceHub.getBuildService().build(imageConfiguration);
final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId("jkube-example");
kitLogger.info("Docker image built successfully (%s)!", imageId);
System.exit(0);
} catch (Exception ex) {
kitLogger.error("Error occurred: '%s'", ex.getMessage());
}
}
Aggregations