Skip to content

Commit

Permalink
Merge pull request #777 from xlight05/remove-http-client
Browse files Browse the repository at this point in the history
Remove automatic ssl retrieval and config map/secret improvments
  • Loading branch information
xlight05 committed Apr 3, 2024
2 parents 971ffe6 + d39b879 commit 544f548
Show file tree
Hide file tree
Showing 80 changed files with 441 additions and 1,225 deletions.
25 changes: 25 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Change Log
This file contains all the notable changes done to the Ballerina Cloud package through the releases.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - Unreleased

### Improvements

- Support directories to be mounted as Configmaps/Secrets [778](https://github.com/ballerina-platform/module-ballerina-c2c/issues/778)

### Breaking Changes
- Windows containers are not supported anymore. [773](https://github.com/ballerina-platform/module-ballerina-c2c/issues/773)
- SSL configurations are not automatically retrieved from the code anymore. You need to explicitly mark them as secrets in Cloud.toml. [782](https://github.com/ballerina-platform/module-ballerina-c2c/issues/782)
```toml
[[cloud.secret.files]]
file="resource."
mount_dir="./resource"
```
- Entrypoints are used instead of CMD to run the ballerina application in the dockerfile. [771](https://github.com/ballerina-platform/module-ballerina-c2c/issues/771)
- [[cloud.secret.files]] and [[cloud.config.maps]] changes. [784](https://github.com/ballerina-platform/module-ballerina-c2c/issues/784)
- `mount_path` is renamed to `mount_dir`. `mount_dir` is the directory where the config maps and secrets are mounted.
- suffix is added to each config map and secret file to avoid conflicts.
- subpaths are used underneath to better support multiple files in the same directory.
2 changes: 1 addition & 1 deletion ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "cloud"
version = "2.12.0"
version = "3.0.0"
repository = "https://github.com/ballerina-platform/module-ballerina-c2c"
license = ["Apache-2.0"]
keywords = ["cloud", "kubernetes", "docker", "k8s", "c2c"]
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "code2cloud"
class = "io.ballerina.c2c.C2CCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/cloud-compiler-plugin-2.12.0-SNAPSHOT.jar"
path = "../compiler-plugin/build/libs/cloud-compiler-plugin-3.0.0-SNAPSHOT.jar"
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ distribution-version = "2201.9.0-20240201-152800-3c3df044"
[[package]]
org = "ballerina"
name = "cloud"
version = "2.12.0"
version = "3.0.0"
modules = [
{org = "ballerina", packageName = "cloud", moduleName = "cloud"}
]
Expand Down
266 changes: 3 additions & 263 deletions cloud-util/src/main/java/io/ballerina/c2c/util/C2CVisitor.java

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions cloud-util/src/main/java/io/ballerina/c2c/util/ClientInfo.java

This file was deleted.

46 changes: 0 additions & 46 deletions cloud-util/src/main/java/io/ballerina/c2c/util/HttpsConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Optional;

/**
* Represents Listener information of a ballerina document.
Expand All @@ -32,14 +31,9 @@
public class ListenerInfo {
private String name;
private int port;
private HttpsConfig config;

public ListenerInfo(String name, int port) {
this.name = name;
this.port = port;
}

public Optional<HttpsConfig> getConfig() {
return Optional.ofNullable(config);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
public class ProjectServiceInfo {

private final List<ServiceInfo> serviceList;
private final List<ClientInfo> clientList;
private Task task = null;

public ProjectServiceInfo(Project project) {
Expand All @@ -50,7 +49,6 @@ public ProjectServiceInfo(Project project) {

public ProjectServiceInfo(Project project, List<Diagnostic> diagnostics) {
this.serviceList = new ArrayList<>();
this.clientList = new ArrayList<>();
Package currentPackage = project.currentPackage();
Iterable<Module> modules = currentPackage.modules();
for (Module module : modules) {
Expand All @@ -74,7 +72,6 @@ public ProjectServiceInfo(Project project, List<Diagnostic> diagnostics) {
C2CVisitor visitor = new C2CVisitor(moduleLevelVariables, semanticModel, diagnostics);
node.accept(visitor);
serviceList.addAll(visitor.getServices());
clientList.addAll(visitor.getClientInfos());
this.task = visitor.getTask();
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import static io.ballerina.c2c.KubernetesConstants.DOCKER;
import static io.ballerina.c2c.KubernetesConstants.KUBERNETES;
import static io.ballerina.c2c.test.utils.KubernetesTestUtils.getCommand;
import static io.ballerina.c2c.test.utils.KubernetesTestUtils.getEntryPoint;
import static io.ballerina.c2c.test.utils.KubernetesTestUtils.getExposedPorts;

/**
Expand Down Expand Up @@ -119,15 +119,15 @@ public void validateDockerfile() {
Assert.assertTrue(dockerFile.exists());
}

@Test(enabled = false)
@Test
public void validateDockerImage() {
List<String> ports = getExposedPorts(DOCKER_IMAGE);
Assert.assertEquals(ports.size(), 1);
Assert.assertEquals(ports.get(0), "9090/tcp");
// Validate ballerina.conf in run command
Assert.assertEquals(getCommand(DOCKER_IMAGE).toString(),
"[/bin/sh, -c, java -Xdiag -cp \"anjana-testObservation_0.1.5-0.1.0.jar:jars/*\" " +
"'anjana.testObservation_0$00461$00465.0.$_init']");
Assert.assertEquals(getEntryPoint(DOCKER_IMAGE).toString(),
"[java, -Xdiag, -cp, anjana-testObservation_0.1.5-0.1.0.jar:jars/*, " +
"anjana.testObservation_0&00461&00465.0.$_init]");
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,6 @@ public void testDefaultConfigValueWarning() {
"default value of configurable variable `port` could be overridden in runtime");
}

@Test
public void testInvalidSSLConfigValue() {
Path projectPath = Paths.get("src", "test", "resources", "service", "invalid-ssl-config");
BuildProject project = BuildProject.load(projectPath);
Collection<Diagnostic> diagnostics =
getC2CDiagnostics(project.currentPackage().getCompilation().diagnosticResult().diagnostics());
Assert.assertEquals(diagnostics.size(), 2);
Iterator<Diagnostic> iterator = diagnostics.iterator();
Diagnostic diagnostic = iterator.next();
Assert.assertEquals(diagnostic.diagnosticInfo().severity(), DiagnosticSeverity.WARNING);
Assert.assertEquals(diagnostic.message(),
"unable to read contents of the file `ballerina`");
diagnostic = iterator.next();
Assert.assertEquals(diagnostic.diagnosticInfo().severity(), DiagnosticSeverity.WARNING);
Assert.assertEquals(diagnostic.message(),
"https config extraction only supports basic string paths");
}

@Test
public void testFailedPortRetrieval() {
Path projectPath = Paths.get("src", "test", "resources", "service", "failed-port-retrieval");
Expand All @@ -167,29 +149,12 @@ public void testFailedPortRetrieval() {
}

@Test
public void testFailedGrpcSSL() {
Path projectPath = Paths.get("src", "test", "resources", "service", "grpc-ssl-key-config-neg");
BuildProject project = BuildProject.load(projectPath);
Collection<Diagnostic> diagnostics =
getC2CDiagnostics(project.currentPackage().getCompilation().diagnosticResult().diagnostics());
Assert.assertEquals(diagnostics.size(), 2);
Iterator<Diagnostic> iterator = diagnostics.iterator();
Diagnostic diagnostic = iterator.next();
Assert.assertEquals(diagnostic.diagnosticInfo().severity(), DiagnosticSeverity.WARNING);
Assert.assertEquals(diagnostic.message(), "https config extraction only supports basic string paths");
}

@Test
public void testFailedPortRetrievalVarRef() {
Path projectPath = Paths.get("src", "test", "resources", "service", "client-ssl-config-neg");
public void testGrpc() {
Path projectPath = Paths.get("src", "test", "resources", "service", "grpc-test");
BuildProject project = BuildProject.load(projectPath);
Collection<Diagnostic> diagnostics =
getC2CDiagnostics(project.currentPackage().getCompilation().diagnosticResult().diagnostics());
Assert.assertEquals(diagnostics.size(), 1);
Iterator<Diagnostic> iterator = diagnostics.iterator();
Diagnostic diagnostic = iterator.next();
Assert.assertEquals(diagnostic.diagnosticInfo().severity(), DiagnosticSeverity.WARNING);
Assert.assertEquals(diagnostic.message(), "unable to retrieve the value of variable `certPath`");
Assert.assertEquals(diagnostics.size(), 0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import static io.ballerina.c2c.KubernetesConstants.DOCKER;
import static io.ballerina.c2c.KubernetesConstants.KUBERNETES;
import static io.ballerina.c2c.test.utils.KubernetesTestUtils.getCommand;
import static io.ballerina.c2c.test.utils.KubernetesTestUtils.getEntryPoint;

/**
* Test cases for Multiple Config files.
Expand Down Expand Up @@ -121,7 +121,7 @@ public void validateDeployment() {
// Validate config file
Assert.assertEquals(container.getEnv().get(0).getName(), "BAL_CONFIG_FILES");
Assert.assertEquals(container.getEnv().get(0).getValue(),
"/home/ballerina/conf1/Config1.toml:/home/ballerina/conf/Config.toml:" +
"/home/ballerina/conf/Config.toml:/home/ballerina/conf1/Config1.toml:" +
"/home/ballerina/secrets/mysql-secrets.toml:/home/ballerina/secrets1/additional-secrets.toml:");
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public void validateDockerfile() {

@Test
public void validateDockerImage() {
Assert.assertEquals(getCommand(DOCKER_IMAGE).toString(), "[java, -Xdiag, -cp," +
Assert.assertEquals(getEntryPoint(DOCKER_IMAGE).toString(), "[java, -Xdiag, -cp," +
" anjana-mix_configs_job-0.1.0.jar:jars/*, anjana.mix_configs_job.0.$_init]");
}

Expand Down
Loading

0 comments on commit 544f548

Please sign in to comment.