Skip to content

Commit

Permalink
Fix #977
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Nov 2, 2023
1 parent d367c17 commit 5741f6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
import org.yaml.snakeyaml.constructor.SafeConstructor;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -61,7 +58,8 @@ public class CodeService {
public static final String BUILD_SCRIPT_FILENAME = "build.sh";
public static final String DEV_SERVICES_FILENAME = "devservices.yaml";
public static final String PROJECT_COMPOSE_FILENAME = "docker-compose.yaml";
public static final String PROJECT_DEPLOYMENT_JKUBE_FILENAME = "deployment.jkube.yaml";
public static final String PROJECT_JKUBE_EXTENSION = ".jkube.yaml";
public static final String PROJECT_DEPLOYMENT_JKUBE_FILENAME = "deployment" + PROJECT_JKUBE_EXTENSION;
private static final String SNIPPETS_PATH = "/snippets/";
private static final int INTERNAL_PORT = 8080;

Expand Down Expand Up @@ -90,9 +88,10 @@ public class CodeService {
"limits.cpu", "2000m"
);

public Map<String, String> getProjectFiles(String projectId, Boolean withKamelets) {
public Map<String, String> getProjectFilesForDevMode(String projectId, Boolean withKamelets) {
Map<String, String> files = infinispanService.getProjectFiles(projectId).stream()
.filter(f -> !Objects.equals(f.getName(), PROJECT_COMPOSE_FILENAME))
.filter(f -> !f.getName().endsWith(PROJECT_JKUBE_EXTENSION))
.collect(Collectors.toMap(ProjectFile::getName, ProjectFile::getCode));

if (withKamelets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
import org.apache.camel.karavan.infinispan.model.CamelStatus;
import org.apache.camel.karavan.infinispan.model.CamelStatusValue;
import org.apache.camel.karavan.infinispan.model.ContainerStatus;
import org.apache.camel.karavan.infinispan.model.ProjectFile;
import org.apache.camel.karavan.kubernetes.KubernetesService;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
import org.eclipse.microprofile.faulttolerance.Retry;
import org.jboss.logging.Logger;

import jakarta.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -99,7 +97,7 @@ public void collectCamelStatuses() {
public void reloadProjectCode(String projectId) {
LOGGER.info("Reload project code " + projectId);
try {
Map<String, String> files = codeService.getProjectFiles(projectId, true);
Map<String, String> files = codeService.getProjectFilesForDevMode(projectId, true);
files.forEach((name, code) -> putRequest(projectId, name, code, 1000));
reloadRequest(projectId);
ContainerStatus containerStatus = infinispanService.getDevModeContainerStatus(projectId, environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.camel.karavan.docker.DockerForKaravan;
import org.apache.camel.karavan.code.model.DockerComposeService;
import org.apache.camel.karavan.git.GitService;
import org.apache.camel.karavan.git.model.GitConfig;
import org.apache.camel.karavan.git.model.GitRepo;
import org.apache.camel.karavan.infinispan.InfinispanService;
import org.apache.camel.karavan.infinispan.model.*;
Expand All @@ -40,7 +39,6 @@
import jakarta.enterprise.inject.Default;
import jakarta.inject.Inject;

import java.io.File;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -106,7 +104,7 @@ public String runProjectWithJBangOptions(Project project, String jBangOptions) t
if (ConfigService.inKubernetes()) {
kubernetesService.runDevModeContainer(project, jBangOptions);
} else {
Map<String, String> files = codeService.getProjectFiles(project.getProjectId(), true);
Map<String, String> files = codeService.getProjectFilesForDevMode(project.getProjectId(), true);

ProjectFile compose = infinispanService.getProjectFile(project.getProjectId(), PROJECT_COMPOSE_FILENAME);
DockerComposeService dcs = DockerComposeConverter.fromCode(compose.getCode(), project.getProjectId());
Expand Down

0 comments on commit 5741f6c

Please sign in to comment.