-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: extract flows and templates #984
Conversation
Totally agree, |
cbf4d51
to
acfeaed
Compare
|
||
try(DefaultHttpClient client = client()) { | ||
MutableHttpRequest<Object> request = HttpRequest | ||
.GET("/api/v1/flows/extract/by_query?namespace=" + namespace).accept(MediaType.APPLICATION_OCTET_STREAM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.GET("/api/v1/flows/extract/by_query?namespace=" + namespace).accept(MediaType.APPLICATION_OCTET_STREAM); | |
.GET("/api/v1/flows/extract/query?namespace=" + namespace).accept(MediaType.APPLICATION_OCTET_STREAM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, see your comment bellow
Totally agree, /extract/by-ids and /extract/by-query is better I think
I'm OK to change it but as extract is a verb by-query reads better than just query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, if we keep by-ids
we should use by-query
@@ -25,6 +31,16 @@ | |||
@ToString | |||
@EqualsAndHashCode | |||
public class Template implements DeletedInterface { | |||
|
|||
private static final ObjectMapper jsonMapper = JacksonMapper.ofJson().copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many duplicate from flow
@@ -93,6 +109,23 @@ public Optional<ConstraintViolationException> validateUpdate(Template updated) { | |||
} | |||
} | |||
|
|||
public String generateSource() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is not necessary, a simple mapper will generate the source on templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I setup the object mapper once for all and use it directly.
By the way, I think the same can be done on the flow class, as the Flow.generateSource()
method is now only used in tests this should be fine to change it the same way I did for templates.
@@ -416,4 +421,59 @@ public List<ValidateConstraintViolation> validateFlows( | |||
}) | |||
.collect(Collectors.toList()); | |||
} | |||
|
|||
@ExecuteOn(TaskExecutors.IO) | |||
@Get(uri = "/extract/by_query", produces = MediaType.APPLICATION_OCTET_STREAM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Get(uri = "/extract/by_query", produces = MediaType.APPLICATION_OCTET_STREAM) | |
@Get(uri = "/extract/query", produces = MediaType.APPLICATION_OCTET_STREAM) |
webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java
Outdated
Show resolved
Hide resolved
ZipOutputStream archive = new ZipOutputStream(bos)) { | ||
|
||
List<FlowWithSource> toExtract = flowRepository.findWithSource(query, namespace, RequestUtils.toMap(labels)); | ||
for(var flowWithSource : toExtract) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many duplication, create a service that create the zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot share the zip code between template and flow easily so I create private methods in each class to avoid duplication (this was my originla plan but I forgot to do it).
1f6706b
to
924f391
Compare
e1a4b67
to
4ef4aba
Compare
cdbd192
to
9d9c672
Compare
So that we can extract flows and templates from different namespace in one call.
f840eed
to
b690831
Compare
Allow extracting Flows and Templates