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

feat(web): add optional query params to the GET /pipelines endpoint #1252

Merged
merged 2 commits into from
Apr 21, 2023

Conversation

dbyron-sf
Copy link
Contributor

@dbyron-sf dbyron-sf commented Apr 20, 2023

so it's possible for consumers of pipelines (e.g. echo) to get only the information they need.

enabledPipelines: boolean -- only return enabled/disabled pipelines
enabledTriggers: boolean -- only return pipelines with at least one enabled trigger
triggerTypes: only return pipelines with a trigger whose type is present in this comma-separated string of trigger types

for example GET /pipelines?enabledPipelines=true&enabledTriggers=true&triggerTypes=foo,bar

which, with correct URL-encoding is:

GET /pipelines?enabledPipelines=true&enabledTriggers=true&triggerTypes=foo%2Cbar

Note that if both enabledTriggers and triggerTypes are specified, that a single trigger must satisfy both conditions for front50 to return its pipeline.

Also add a GET /pipelines/{application}/name/{name} endpoint which queries for a pipeline by application and name. It responds with 404 if no such pipeline is found.

echo uses this endpoint in spinnaker/echo#1292 for manual triggers by application and name, when its cache doesn't contain the triggered pipeline.

so it's possible for consumers of pipelines (e.g. echo) to get only the information they need.

enabledPipelines: boolean -- only return enabled/disabled pipelines
enabledTriggers: boolean -- only return pipelines with at least one enabled trigger
triggerTypes: only return pipelines with a trigger whose type is present in this comma-separated string of trigger types

for example GET /pipelines?enabledPipelines=true&enabledTriggers=true&triggerTypes=foo,bar

which, with correct URL-encoding is:

GET /pipelines?enabledPipelines=true&enabledTriggers=true&triggerTypes=foo%2Cbar

Note that if both enabledTriggers and triggerTypes are specified, a single trigger must satisfy both conditions for front50 to return its pipeline.
@dbyron-sf dbyron-sf marked this pull request as draft April 20, 2023 17:40
@dbyron-sf dbyron-sf force-pushed the query-params-for-get-pipelines branch from de0bc6a to 5f581b8 Compare April 20, 2023 17:51
which queries for a pipeline by application and name.  It responds with 404 if no such pipeline is found.

echo uses this endpoint for manual triggers by application and name, when its cache doesn't contain the triggered pipeline.
Pipeline getPipelineByName(String application, String pipelineName, boolean refresh) {
map.values().stream()
.filter({ p -> p.getApplication().equalsIgnoreCase(application) })
.filter({ p -> p.getName().equalsIgnoreCase(pipelineName) })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAY a case where we ignore case :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to follow what similar methods do above ...

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Apr 21, 2023
@mergify mergify bot added the auto merged label Apr 21, 2023
@mergify mergify bot merged commit 35d71e6 into spinnaker:master Apr 21, 2023
@dbyron-sf dbyron-sf deleted the query-params-for-get-pipelines branch April 4, 2024 22:36
dbyron-sf pushed a commit to dbyron-sf/front50 that referenced this pull request Apr 7, 2024
…ines at once to sql db.

This is part of: spinnaker/spinnaker#6147.

Enhanced PipelineController.java to

Added new rest api method bulksave(List<Map> pipelineList, Boolean staleCheck)
This method accepts a list of pipelines json.
This method checks each and every pipeline for authorization.
If the pipeline has valid authorization, then it will be saved to a savedPipelineList.
If the pipeline do not have a valid authorization, then it will be saved to a errorPipelineList
 and an error message is also populated.
All the savedPipelinesList will be saved to sql database using bulk insert.
This method returns a Map object having the below data:
{
  “Successful”: <count>,
  “Failed”: <cound>,
  “Failed_list”: [<array of failed pipelines - (application, pipeline name, etc) and the error message]
}

Enhanced AuthorizationSupport.java to

Added code to accept the pipeline list and authorize the pipelines.

Enhanced PipelineControllerSpec.java to

Added bean of FiatPermissionEvalutor.java as it is used in the PipelineController constructor.

Conflicts:
	front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/PipelineController.java
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerSpec.groovy
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerTck.groovy
due to additional imports from spinnaker#1251 and spinnaker#1252

and org.springframework.context.support.DefaultMessageSourceResolvable has been removed
from master by spinnaker#1035

note, this fails to compile because bulkSave has code that expects Pipelines to behave as
Maps.  As of spinnaker#1035 that's no longer true.
dbyron-sf pushed a commit to dbyron-sf/front50 that referenced this pull request Apr 18, 2024
…ines at once to sql db.

This is part of: spinnaker/spinnaker#6147.

Enhanced PipelineController.java to

Added new rest api method bulksave(List<Map> pipelineList, Boolean staleCheck)
This method accepts a list of pipelines json.
This method checks each and every pipeline for authorization.
If the pipeline has valid authorization, then it will be saved to a savedPipelineList.
If the pipeline do not have a valid authorization, then it will be saved to a errorPipelineList
 and an error message is also populated.
All the savedPipelinesList will be saved to sql database using bulk insert.
This method returns a Map object having the below data:
{
  “Successful”: <count>,
  “Failed”: <cound>,
  “Failed_list”: [<array of failed pipelines - (application, pipeline name, etc) and the error message]
}

Enhanced AuthorizationSupport.java to

Added code to accept the pipeline list and authorize the pipelines.

Enhanced PipelineControllerSpec.java to

Added bean of FiatPermissionEvalutor.java as it is used in the PipelineController constructor.

Conflicts:
	front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/PipelineController.java
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerSpec.groovy
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerTck.groovy
due to additional imports from spinnaker#1251 and spinnaker#1252

and org.springframework.context.support.DefaultMessageSourceResolvable has been removed
from master by spinnaker#1035

note, this fails to compile because bulkSave has code that expects Pipelines to behave as
Maps.  As of spinnaker#1035 that's no longer true.
dbyron-sf pushed a commit to dbyron-sf/front50 that referenced this pull request Jul 1, 2024
…ines at once to sql db.

This is part of: spinnaker/spinnaker#6147.

Enhanced PipelineController.java to

Added new rest api method bulksave(List<Map> pipelineList, Boolean staleCheck)
This method accepts a list of pipelines json.
This method checks each and every pipeline for authorization.
If the pipeline has valid authorization, then it will be saved to a savedPipelineList.
If the pipeline do not have a valid authorization, then it will be saved to a errorPipelineList
 and an error message is also populated.
All the savedPipelinesList will be saved to sql database using bulk insert.
This method returns a Map object having the below data:
{
  “Successful”: <count>,
  “Failed”: <cound>,
  “Failed_list”: [<array of failed pipelines - (application, pipeline name, etc) and the error message]
}

Enhanced AuthorizationSupport.java to

Added code to accept the pipeline list and authorize the pipelines.

Enhanced PipelineControllerSpec.java to

Added bean of FiatPermissionEvalutor.java as it is used in the PipelineController constructor.

Conflicts:
	front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/PipelineController.java
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerSpec.groovy
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerTck.groovy
due to additional imports from spinnaker#1251 and spinnaker#1252

and org.springframework.context.support.DefaultMessageSourceResolvable has been removed
from master by spinnaker#1035

note, this fails to compile because bulkSave has code that expects Pipelines to behave as
Maps.  As of spinnaker#1035 that's no longer true.
dbyron-sf pushed a commit to dbyron-sf/front50 that referenced this pull request Jul 1, 2024
…ines at once to sql db.

This is part of: spinnaker/spinnaker#6147.

Enhanced PipelineController.java to

Added new rest api method bulksave(List<Map> pipelineList, Boolean staleCheck)
This method accepts a list of pipelines json.
This method checks each and every pipeline for authorization.
If the pipeline has valid authorization, then it will be saved to a savedPipelineList.
If the pipeline do not have a valid authorization, then it will be saved to a errorPipelineList
 and an error message is also populated.
All the savedPipelinesList will be saved to sql database using bulk insert.
This method returns a Map object having the below data:
{
  “Successful”: <count>,
  “Failed”: <cound>,
  “Failed_list”: [<array of failed pipelines - (application, pipeline name, etc) and the error message]
}

Enhanced AuthorizationSupport.java to

Added code to accept the pipeline list and authorize the pipelines.

Enhanced PipelineControllerSpec.java to

Added bean of FiatPermissionEvalutor.java as it is used in the PipelineController constructor.

Conflicts:
	front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/PipelineController.java
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerSpec.groovy
	front50-web/src/test/groovy/com/netflix/spinnaker/front50/controllers/PipelineControllerTck.groovy
due to additional imports from spinnaker#1251 and spinnaker#1252

and org.springframework.context.support.DefaultMessageSourceResolvable has been removed
from master by spinnaker#1035

note, this fails to compile because bulkSave has code that expects Pipelines to behave as
Maps.  As of spinnaker#1035 that's no longer true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants