Skip to content

Commit 566ecec

Browse files
committed
Add use, secrets, auth
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
1 parent d778461 commit 566ecec

File tree

6 files changed

+602
-5
lines changed

6 files changed

+602
-5
lines changed

fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseWorkflowBuilder.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ public SELF use(Consumer<UseBuilder> useBuilderConsumer) {
7979
return self();
8080
}
8181

82+
@SafeVarargs
83+
public final SELF use(Consumer<UseBuilder>... configurers) {
84+
if (configurers == null || configurers.length == 0) {
85+
return self();
86+
}
87+
return use(List.of(configurers.clone()));
88+
}
89+
90+
private SELF use(List<Consumer<UseBuilder>> configurers) {
91+
final UseBuilder builder = new UseBuilder();
92+
configurers.forEach(
93+
c -> {
94+
if (c != null) c.accept(builder);
95+
});
96+
this.workflow.setUse(builder.build());
97+
return self();
98+
}
99+
82100
public SELF tasks(Consumer<DBuilder> doTaskConsumer) {
83101
return appendDo(doTaskConsumer);
84102
}

fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/UseBuilder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.serverlessworkflow.fluent.spec;
1717

1818
import io.serverlessworkflow.api.types.Use;
19+
import io.serverlessworkflow.api.types.UseAuthentications;
1920
import java.util.List;
2021
import java.util.function.Consumer;
2122

@@ -25,6 +26,7 @@ public class UseBuilder {
2526

2627
UseBuilder() {
2728
this.use = new Use();
29+
this.use.setAuthentications(new UseAuthentications());
2830
}
2931

3032
public UseBuilder secrets(final String... secrets) {
@@ -37,7 +39,11 @@ public UseBuilder secrets(final String... secrets) {
3739
public UseBuilder authentications(Consumer<UseAuthenticationsBuilder> authenticationsConsumer) {
3840
final UseAuthenticationsBuilder builder = new UseAuthenticationsBuilder();
3941
authenticationsConsumer.accept(builder);
40-
this.use.setAuthentications(builder.build());
42+
final UseAuthentications useAuthentications = builder.build();
43+
this.use
44+
.getAuthentications()
45+
.getAdditionalProperties()
46+
.putAll(useAuthentications.getAdditionalProperties());
4147
return this;
4248
}
4349

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.fluent.spec.configurers;
17+
18+
import io.serverlessworkflow.fluent.spec.UseBuilder;
19+
import java.util.function.Consumer;
20+
21+
@FunctionalInterface
22+
public interface UseConfigurer extends Consumer<UseBuilder> {}

0 commit comments

Comments
 (0)