Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/reorganize properties #662

Merged
merged 29 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
75e6e2c
deprecate old properties
jonathanlukas Jan 26, 2024
0822399
refactoring usage of properties
jonathanlukas Jan 26, 2024
bb6a416
wip
jonathanlukas Feb 16, 2024
02a8a2d
wip
jonathanlukas Feb 16, 2024
71cbb3c
wip
jonathanlukas Feb 21, 2024
e782240
wip
jonathanlukas Feb 21, 2024
6156d0a
legacy config still working
jonathanlukas Feb 28, 2024
07ebd7f
removed unused configuration
jonathanlukas Feb 28, 2024
9e9834b
added backend issuer url to default saas props
jonathanlukas Feb 28, 2024
c7b5f1d
adjusted readme
jonathanlukas Feb 28, 2024
50f7f68
fixed broken test
jonathanlukas Mar 5, 2024
aba5352
functionality of new property strategy proved
jonathanlukas Mar 8, 2024
24f6cc8
moved from spring profiles to properties post processor
jonathanlukas Mar 8, 2024
4108638
moved tests as well
jonathanlukas Mar 8, 2024
65c69fb
worker overrides are applied over global overrides
jonathanlukas Mar 9, 2024
3334eff
typo
jonathanlukas Mar 12, 2024
9e4568b
table format
jonathanlukas Mar 12, 2024
20b341a
add a general comment for first orientation
jonathanlukas Mar 12, 2024
7dd4642
removed property
jonathanlukas Mar 12, 2024
916339a
typo
jonathanlukas Mar 12, 2024
e6aae6d
updated docs about variable fetching
jonathanlukas Mar 12, 2024
57c61ae
typo
jonathanlukas Mar 12, 2024
d378ae2
update link to reflect new properties class
jonathanlukas Mar 12, 2024
5f47cad
typo
jonathanlukas Mar 12, 2024
29b2b4b
deprecated classes
jonathanlukas Mar 12, 2024
256d9a8
updated executorserviceconfig to reflect new properties
jonathanlukas Mar 12, 2024
f29b961
added a test to assert all deprecations are applied correctly
jonathanlukas Mar 12, 2024
a81bdb5
applied deprecation notices to all legacy properties
jonathanlukas Mar 14, 2024
7330d7c
adjusted a reason comment
jonathanlukas Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
325 changes: 220 additions & 105 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public JwtCredential(String clientId, String clientSecret, String audience, Stri
this.authUrl = authUrl;
}

private String clientId;
private String clientSecret;
private String audience;
private String authUrl;
private final String clientId;
private final String clientSecret;
private final String audience;
private final String authUrl;

public String getClientId() {
return clientId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
package io.camunda.common.auth;

import java.util.Arrays;

/** Enum for different C8 Products */
public enum Product {
ZEEBE,
OPERATE,
TASKLIST,
CONSOLE,
OPTIMIZE,
WEB_MODELER
ZEEBE(true),
OPERATE(true),
TASKLIST(true),
CONSOLE(false),
OPTIMIZE(true),
WEB_MODELER(false),
IDENTITY(true);

private final boolean covered;

Product(boolean covered) {
this.covered = covered;
}

public static Product[] coveredProducts() {
return Arrays.stream(Product.values())
.filter(Product::covered)
.toList()
.toArray(new Product[0]);
}

public boolean covered() {
return covered;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ public class SimpleAuthentication implements Authentication {
private final SimpleConfig simpleConfig;
private final Map<Product, String> tokens = new HashMap<>();

private final String authUrl;

public SimpleAuthentication(String simpleUrl, SimpleConfig simpleConfig) {
public SimpleAuthentication(SimpleConfig simpleConfig) {
this.simpleConfig = simpleConfig;
this.authUrl = simpleUrl + "/api/login";
}

public SimpleConfig getSimpleConfig() {
Expand Down Expand Up @@ -64,7 +61,7 @@ private String retrieveToken(Product product, SimpleCredential simpleCredential)
}

private HttpPost buildRequest(SimpleCredential simpleCredential) {
HttpPost httpPost = new HttpPost(authUrl);
HttpPost httpPost = new HttpPost(simpleCredential.getBaseUrl() + "/api/login");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", simpleCredential.getUser()));
params.add(new BasicNameValuePair("password", simpleCredential.getPassword()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
import io.camunda.common.auth.Authentication.AuthenticationBuilder;

public class SimpleAuthenticationBuilder implements AuthenticationBuilder {
private String simpleUrl;
private SimpleConfig simpleConfig;

public SimpleAuthenticationBuilder withSimpleUrl(String simpleUrl) {
this.simpleUrl = simpleUrl;
return this;
}

public SimpleAuthenticationBuilder withSimpleConfig(SimpleConfig simpleConfig) {
this.simpleConfig = simpleConfig;
return this;
}

@Override
public Authentication build() {
return new SimpleAuthentication(simpleUrl, simpleConfig);
return new SimpleAuthentication(simpleConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/** Contains mapping between products and their Simple credentials */
public class SimpleConfig {

private Map<Product, SimpleCredential> map;
private final Map<Product, SimpleCredential> map;

public SimpleConfig() {
map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
/** Contains credential for particular product. Used for Simple authentication. */
public class SimpleCredential {

public SimpleCredential(String user, String password) {
public SimpleCredential(String baseUrl, String user, String password) {
this.baseUrl = baseUrl;
this.user = user;
this.password = password;
}

private String user;
private String password;
private final String baseUrl;
private final String user;
private final String password;

public String getUser() {
return user;
Expand All @@ -18,4 +20,8 @@ public String getUser() {
public String getPassword() {
return password;
}

public String getBaseUrl() {
return baseUrl;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package io.camunda.zeebe.spring.example;

import io.camunda.operate.CamundaOperateClient;
import io.camunda.operate.exception.OperateException;
import io.camunda.operate.model.ProcessDefinition;
import io.camunda.operate.search.SearchQuery;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -15,7 +20,14 @@ public class PeriodicProcessStarter {

private static Logger log = LoggerFactory.getLogger(ExampleApplication.class);

@Autowired private ZeebeClient client;
private final ZeebeClient client;
private final CamundaOperateClient operateClient;

@Autowired
public PeriodicProcessStarter(ZeebeClient client, CamundaOperateClient operateClient) {
this.client = client;
this.operateClient = operateClient;
}

@Scheduled(fixedRate = 5000L)
public void startProcesses() {
Expand All @@ -40,4 +52,18 @@ public void startProcesses() {
event.getVersion(),
event.getProcessInstanceKey());
}

@Scheduled(fixedRate = 5000L)
public void listProcesses() throws OperateException {
SearchQuery query = new SearchQuery();
List<ProcessDefinition> processDefinitions = operateClient.searchProcessDefinitions(query);
processDefinitions.forEach(
processDefinition ->
log.info(
"Process Definition: Key: {}, BPMN process Id: {}, Name: {}, Tenant: {}",
processDefinition.getKey(),
processDefinition.getBpmnProcessId(),
processDefinition.getName(),
processDefinition.getTenantId()));
}
}
2 changes: 0 additions & 2 deletions example/src/main/resources/application.properties

This file was deleted.

4 changes: 4 additions & 0 deletions example/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
camunda:
client:
mode: simple

5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
<artifactId>identity-spring-boot-starter</artifactId>
<version>${identity.version}</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>identity-spring-boot-autoconfigure</artifactId>
<version>${identity.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion spring-boot-starter-camunda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>identity-spring-boot-starter</artifactId>
<artifactId>identity-spring-boot-autoconfigure</artifactId>
</dependency>
<!-- Make sure slf4j (transitive dependency of resilience4j is on the classpath in the version compatible with Spring boot
(not specifying a version here means it is taken from the Spring BOM pulled in on root level
Expand All @@ -61,6 +61,13 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.4.1</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.common.json.SdkObjectMapper;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.JsonMapper;
import io.camunda.zeebe.client.impl.ZeebeObjectMapper;
import io.camunda.zeebe.spring.client.configuration.*;
import io.camunda.zeebe.spring.client.event.ZeebeLifecycleEventProducer;
import io.camunda.zeebe.spring.client.testsupport.SpringZeebeTestContext;
Expand All @@ -27,10 +24,12 @@
@ImportAutoConfiguration({
ZeebeClientProdAutoConfiguration.class,
ZeebeClientAllAutoConfiguration.class,
CommonClientConfiguration.class,
OperateClientConfiguration.class,
ZeebeActuatorConfiguration.class,
MetricsDefaultConfiguration.class
MetricsDefaultConfiguration.class,
AuthenticationConfiguration.class,
CommonClientConfiguration.class,
JsonMapperConfiguration.class
})
@AutoConfigureAfter(
JacksonAutoConfiguration
Expand All @@ -53,28 +52,4 @@ public ZeebeLifecycleEventProducer zeebeLifecycleEventProducer(
final ZeebeClient client, final ApplicationEventPublisher publisher) {
return new ZeebeLifecycleEventProducer(client, publisher);
}

/**
* Registering a JsonMapper bean when there is none already exists in {@link
* org.springframework.beans.factory.BeanFactory}.
*
* <p>NOTE: This method SHOULD NOT be explicitly called as it might lead to unexpected behaviour
* due to the {@link ConditionalOnMissingBean} annotation. i.e. Calling this method when another
* JsonMapper bean is defined in the context might throw {@link
* org.springframework.beans.factory.NoSuchBeanDefinitionException}
*
* @return a new JsonMapper bean if none already exists in {@link
* org.springframework.beans.factory.BeanFactory}
*/
@Bean(name = "zeebeJsonMapper")
@ConditionalOnMissingBean
public JsonMapper jsonMapper(ObjectMapper objectMapper) {
return new ZeebeObjectMapper(objectMapper);
}

@Bean(name = "commonJsonMapper")
@ConditionalOnMissingBean
public io.camunda.common.json.JsonMapper commonJsonMapper(ObjectMapper objectMapper) {
return new SdkObjectMapper(objectMapper);
}
}
Loading
Loading