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

Add API, actions, and reducers to get Triggers resources #686

Merged
merged 1 commit into from
Nov 4, 2019

Conversation

a-roberts
Copy link
Member

@a-roberts a-roberts commented Nov 1, 2019

Changes

For #665

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

Hold on, think this is the code but let's see if it actually gets ok

Manual test:

adams-mbp:tektoncd aroberts$ k get el
NAME                   AGE
listener               24s
listener-interceptor   84s
adams-mbp:tektoncd aroberts$ k get tt
NAME                AGE
pipeline-template   100s
adams-mbp:tektoncd aroberts$ k get tb
NAME               AGE
pipeline-binding   104s

(from Triggers example repo), then using the API gives...

http://localhost:9097/proxy/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggertemplates/
->

{"apiVersion":"tekton.dev/v1alpha1","items":[{"apiVersion":"tekton.dev/v1alpha1","kind":"TriggerTemplate","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"TriggerTemplate\",\"metadata\":{\"annotations\":{},\"name\":\"pipeline-template\",\"namespace\":\"tekton-pipelines\"},\"spec\":{\"params\":[{\"default\":\"master\",\"description\":\"The git revision\",\"name\":\"gitrevision\"},{\"description\":\"The git repository url\",\"name\":\"gitrepositoryurl\"},{\"default\":\"This is the default message\",\"description\":\"The message to print\",\"name\":\"message\"},{\"description\":\"The Content-Type of the event\",\"name\":\"contenttype\"}],\"resourcetemplates\":[{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"PipelineResource\",\"metadata\":{\"name\":\"git-source-$(uid)\"},\"spec\":{\"params\":[{\"name\":\"revision\",\"value\":\"$(params.gitrevision)\"},{\"name\":\"url\",\"value\":\"$(params.gitrepositoryurl)\"}],\"type\":\"git\"}},{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"PipelineRun\",\"metadata\":{\"generateName\":\"simple-pipeline-run\"},\"spec\":{\"params\":[{\"name\":\"message\",\"value\":\"$(params.message)\"},{\"name\":\"contenttype\",\"value\":\"$(params.contenttype)\"}],\"pipelineRef\":{\"name\":\"simple-pipeline\"},\"resources\":[{\"name\":\"git-source\",\"resourceRef\":{\"name\":\"git-source-$(uid)\"}}]}}]}}\n"},"creationTimestamp":"2019-11-01T11:33:31Z","generation":1,"name":"pipeline-template","namespace":"tekton-pipelines","resourceVersion":"7323","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggertemplates/pipeline-template","uid":"6e7b302a-fc9b-11e9-a4cd-025000000001"},"spec":{"params":[{"default":"master","description":"The git revision","name":"gitrevision"},{"description":"The git repository url","name":"gitrepositoryurl"},{"default":"This is the default message","description":"The message to print","name":"message"},{"description":"The Content-Type of the event","name":"contenttype"}],"resourcetemplates":[{"apiVersion":"tekton.dev/v1alpha1","kind":"PipelineResource","metadata":{"name":"git-source-$(uid)"},"spec":{"params":[{"name":"revision","value":"$(params.gitrevision)"},{"name":"url","value":"$(params.gitrepositoryurl)"}],"type":"git"}},{"apiVersion":"tekton.dev/v1alpha1","kind":"PipelineRun","metadata":{"generateName":"simple-pipeline-run"},"spec":{"params":[{"name":"message","value":"$(params.message)"},{"name":"contenttype","value":"$(params.contenttype)"}],"pipelineRef":{"name":"simple-pipeline"},"resources":[{"name":"git-source","resourceRef":{"name":"git-source-$(uid)"}}]}}]}}],"kind":"TriggerTemplateList","metadata":{"continue":"","resourceVersion":"8348","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggertemplates"}}

http://localhost:9097/proxy/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggerbindings/
->

{"apiVersion":"tekton.dev/v1alpha1","items":[{"apiVersion":"tekton.dev/v1alpha1","kind":"TriggerBinding","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"TriggerBinding\",\"metadata\":{\"annotations\":{},\"name\":\"pipeline-binding\",\"namespace\":\"tekton-pipelines\"},\"spec\":{\"params\":[{\"name\":\"gitrevision\",\"value\":\"$(body.head_commit.id)\"},{\"name\":\"gitrepositoryurl\",\"value\":\"$(body.repository.url)\"},{\"name\":\"contenttype\",\"value\":\"$(header.Content-Type)\"}]}}\n"},"creationTimestamp":"2019-11-01T11:33:28Z","generation":1,"name":"pipeline-binding","namespace":"tekton-pipelines","resourceVersion":"7319","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggerbindings/pipeline-binding","uid":"6c66696f-fc9b-11e9-a4cd-025000000001"},"spec":{"params":[{"name":"gitrevision","value":"$(body.head_commit.id)"},{"name":"gitrepositoryurl","value":"$(body.repository.url)"},{"name":"contenttype","value":"$(header.Content-Type)"}]}}],"kind":"TriggerBindingList","metadata":{"continue":"","resourceVersion":"8355","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/triggerbindings"}}

http://localhost:9097/proxy/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/eventlisteners/
->

{"apiVersion":"tekton.dev/v1alpha1","items":[{"apiVersion":"tekton.dev/v1alpha1","kind":"EventListener","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"EventListener\",\"metadata\":{\"annotations\":{},\"name\":\"listener\",\"namespace\":\"tekton-pipelines\"},\"spec\":{\"serviceAccountName\":\"tekton-webhooks-extension\",\"triggers\":[{\"binding\":{\"name\":\"pipeline-binding\"},\"interceptor\":{\"objectRef\":{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"name\":\"el-listener-interceptor\",\"namespace\":\"tekton-pipelines\"}},\"name\":\"foo-trig\",\"params\":[{\"name\":\"secretKeyRef\",\"value\":\"secretToken\"},{\"name\":\"wantedRepositoryURL\",\"value\":\"https://github.ibm.com/AROBERTS/devops-world-example.git\"}],\"template\":{\"name\":\"pipeline-template\"}}]}}\n"},"creationTimestamp":"2019-11-01T11:34:45Z","generation":1,"name":"listener","namespace":"tekton-pipelines","resourceVersion":"8297","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/eventlisteners/listener","uid":"9a7b9378-fc9b-11e9-a4cd-025000000001"},"spec":{"serviceAccountName":"tekton-webhooks-extension","triggers":[{"binding":{"name":"pipeline-binding"},"interceptor":{"objectRef":{"apiVersion":"v1","kind":"Service","name":"el-listener-interceptor","namespace":"tekton-pipelines"}},"name":"foo-trig","params":[{"name":"secretKeyRef","value":"secretToken"},{"name":"wantedRepositoryURL","value":"https://github.ibm.com/AROBERTS/devops-world-example.git"}],"template":{"name":"pipeline-template"}}]},"status":{"address":{"hostname":"el-listener.tekton-pipelines.svc.cluster.local"},"conditions":[{"lastTransitionTime":"2019-11-01T11:34:45Z","message":"Deployment does not have minimum availability.","reason":"MinimumReplicasUnavailable","status":"False","type":"Available"},{"lastTransitionTime":"2019-11-01T11:34:45Z","message":"Deployment exists","status":"True","type":"Deployment"},{"lastTransitionTime":"2019-11-01T11:44:45Z","message":"ReplicaSet \"el-listener-b486cb988\" has timed out progressing.","reason":"ProgressDeadlineExceeded","status":"False","type":"Progressing"},{"lastTransitionTime":"2019-11-01T11:44:45Z","message":"pods \"el-listener-b486cb988-\" is forbidden: error looking up service account tekton-pipelines/tekton-webhooks-extension: serviceaccount \"tekton-webhooks-extension\" not found","reason":"FailedCreate","status":"True","type":"ReplicaFailure"},{"lastTransitionTime":"2019-11-01T11:34:45Z","message":"Service exists","status":"True","type":"Service"}],"configuration":{"generatedName":"el-listener"}}},{"apiVersion":"tekton.dev/v1alpha1","kind":"EventListener","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"tekton.dev/v1alpha1\",\"kind\":\"EventListener\",\"metadata\":{\"annotations\":{},\"name\":\"listener-interceptor\",\"namespace\":\"tekton-pipelines\"},\"spec\":{\"serviceAccountName\":\"tekton-triggers-example-sa\",\"triggers\":[{\"binding\":{\"name\":\"pipeline-binding\"},\"interceptor\":{\"header\":[{\"name\":\"Foo-Trig-Header1\",\"value\":\"string-value\"},{\"name\":\"Foo-Trig-Header2\",\"value\":[\"array-val1\",\"array-val2\"]}],\"objectRef\":{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"name\":\"gh-validate\",\"namespace\":\"default\"}},\"name\":\"foo-trig\",\"params\":[{\"name\":\"message\",\"value\":\"Hello from the Triggers EventListener!\"}],\"template\":{\"name\":\"pipeline-template\"}}]}}\n"},"creationTimestamp":"2019-11-01T11:33:45Z","generation":1,"name":"listener-interceptor","namespace":"tekton-pipelines","resourceVersion":"8221","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/eventlisteners/listener-interceptor","uid":"770d6d75-fc9b-11e9-a4cd-025000000001"},"spec":{"serviceAccountName":"tekton-triggers-example-sa","triggers":[{"binding":{"name":"pipeline-binding"},"interceptor":{"header":[{"name":"Foo-Trig-Header1","value":"string-value"},{"name":"Foo-Trig-Header2","value":["array-val1","array-val2"]}],"objectRef":{"apiVersion":"v1","kind":"Service","name":"gh-validate","namespace":"default"}},"name":"foo-trig","params":[{"name":"message","value":"Hello from the Triggers EventListener!"}],"template":{"name":"pipeline-template"}}]},"status":{"address":{"hostname":"el-listener-interceptor.tekton-pipelines.svc.cluster.local"},"conditions":[{"lastTransitionTime":"2019-11-01T11:33:45Z","message":"Deployment does not have minimum availability.","reason":"MinimumReplicasUnavailable","status":"False","type":"Available"},{"lastTransitionTime":"2019-11-01T11:33:45Z","message":"Deployment exists","status":"True","type":"Deployment"},{"lastTransitionTime":"2019-11-01T11:43:45Z","message":"ReplicaSet \"el-listener-interceptor-79f7976f66\" has timed out progressing.","reason":"ProgressDeadlineExceeded","status":"False","type":"Progressing"},{"lastTransitionTime":"2019-11-01T11:43:45Z","message":"pods \"el-listener-interceptor-79f7976f66-\" is forbidden: error looking up service account tekton-pipelines/tekton-triggers-example-sa: serviceaccount \"tekton-triggers-example-sa\" not found","reason":"FailedCreate","status":"True","type":"ReplicaFailure"},{"lastTransitionTime":"2019-11-01T11:33:45Z","message":"Service exists","status":"True","type":"Service"}],"configuration":{"generatedName":"el-listener-interceptor"}}}],"kind":"EventListenerList","metadata":{"continue":"","resourceVersion":"8357","selfLink":"/apis/tekton.dev/v1alpha1/namespaces/tekton-pipelines/eventlisteners"}}

@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 1, 2019
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 1, 2019
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 1, 2019
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 1, 2019
@a-roberts a-roberts changed the title [WIP] Add API, actions, and reducers to get Triggers resources Add API, actions, and reducers to get Triggers resources Nov 1, 2019
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 1, 2019
@a-roberts
Copy link
Member Author

a-roberts commented Nov 1, 2019

I1101 11:46:10.351] --- FAIL: TestExtensionRegistration (10.04s)
I1101 11:46:10.351]     routes_test.go:318: In TestExtensionRegistration
I1101 11:46:10.351]     routes_test.go:344: robots.secrets
I1101 11:46:10.351]     routes_test.go:461: waiting for registration
I1101 11:46:10.352]     routes_test.go:462: services:�
I1101 11:46:10.352]     routes_test.go:463: start time: 2019-11-01 11:46:00.236459867 +0000 UTC m=+0.188153595
I1101 11:46:10.352]     routes_test.go:464: --- ---
... skipping 5 lines ...
I1101 11:46:10.353]     routes_test.go:478: counter: 2
I1101 11:46:10.353]     routes_test.go:479: time: 2019-11-01 11:46:00.247983598 +0000 UTC m=+0.199677396
I1101 11:46:10.353]     routes_test.go:483: extensionCreates:
I1101 11:46:10.353]     routes_test.go:484: 2
I1101 11:46:10.353]     routes_test.go:490: 
I1101 11:46:10.353]     routes_test.go:470: Timed out waiting for expected services to be registered
I1101 11:46:10.354] FAIL
I1101 11:46:10.354] FAIL	github.com/tektoncd/dashboard/pkg/router	10.219s
I1101 11:46:10.354] ?   	github.com/tektoncd/dashboard/pkg/testutils	[no test files]
I1101 11:46:10.354] ?   	github.com/tektoncd/dashboard/pkg/utils	[no test files]
I1101 11:46:10.354] ?   	github.com/tektoncd/dashboard/pkg/websocket	[no test files]

🙄

@a-roberts
Copy link
Member Author

/retest

@a-roberts
Copy link
Member Author

Plumbing chinwag raised: https://tektoncd.slack.com/archives/CJ4ERJWAU/p1572610739084900

@a-roberts
Copy link
Member Author

/retest

Copy link
Contributor

@carlos-logro carlos-logro left a comment

Choose a reason for hiding this comment

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

everything looks good to me! just a minor question regarding the api call for TriggerBindings. Also, no tests for triggerTemplates and triggerBindings reducers?

src/api/index.js Outdated Show resolved Hide resolved
@a-roberts
Copy link
Member Author

/test pull-tekton-dashboard-integration-tests

@a-roberts
Copy link
Member Author

#447 issue made for dealing with the failing integration tests

Copy link
Member

@ncskier ncskier left a comment

Choose a reason for hiding this comment

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

Overall looks great! I just have a handful of minor nits, and a question about the filters option; if we're including filters for one of the Triggers resources, we should probably do it for all of them, and I think this was missing for the EventListener & TriggerTemplate actions.

src/actions/triggerBindings.test.js Outdated Show resolved Hide resolved
src/actions/eventListeners.js Outdated Show resolved Hide resolved
src/actions/triggerTemplates.js Outdated Show resolved Hide resolved
src/api/index.js Outdated Show resolved Hide resolved
src/api/index.test.js Outdated Show resolved Hide resolved
src/reducers/eventListeners.test.js Outdated Show resolved Hide resolved
src/reducers/triggerBindings.test.js Outdated Show resolved Hide resolved
src/reducers/triggerTemplates.test.js Outdated Show resolved Hide resolved
@a-roberts
Copy link
Member Author

a-roberts commented Nov 4, 2019

Cheers for the detailed review @ncskier, addressed (must fix #447) first then I'll rebase 😄

@a-roberts a-roberts force-pushed the triggersapi branch 2 times, most recently from 1f94797 to 229ca4d Compare November 4, 2019 11:06
@a-roberts
Copy link
Member Author

Rebased

Copy link
Member

@ncskier ncskier left a comment

Choose a reason for hiding this comment

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

Thanks for the changes Adam! Just one small nit I found 😄

src/actions/eventListeners.test.js Outdated Show resolved Hide resolved
@a-roberts
Copy link
Member Author

Pushed 😄

Copy link
Member

@ncskier ncskier left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for making those changes Adam!
(I don't remember how my powers work in this repo, but let's try this)
/lgtm
/meow space

@tekton-robot
Copy link
Contributor

@ncskier: cat image

In response to this:

Awesome, thanks for making those changes Adam!
(I don't remember how my powers work in this repo, but let's try this)
/lgtm
/meow space

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2019
@a-roberts
Copy link
Member Author

/approve

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-roberts, ncskier

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2019
@tekton-robot tekton-robot merged commit f5489d5 into tektoncd:master Nov 4, 2019
@a-roberts a-roberts deleted the triggersapi branch November 4, 2019 15:15
@carlos-logro
Copy link
Contributor

Just noticed that the reducers are not specified in reducers/index. Must be added for the panels to work properly.

@a-roberts
Copy link
Member Author

a-roberts commented Nov 4, 2019

Just noticed that the reducers are not specified in reducers/index. Must be added for the panels to work properly.

How about this? I've just done a quick copy job mind you, so not tested

/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { combineReducers } from 'redux';

import clusterTasks, * as clusterTaskSelectors from './clusterTasks';
import extensions, * as extensionSelectors from './extensions';
import locale, * as localeSelectors from './locale';
import namespaces, * as namespaceSelectors from './namespaces';
import notifications, * as notificationSelectors from './notifications';
import pipelines, * as pipelineSelectors from './pipelines';
import pipelineResources, * as pipelineResourcesSelectors from './pipelineResources';
import pipelineRuns, * as pipelineRunsSelectors from './pipelineRuns';
import secrets, * as secretSelectors from './secrets';
import serviceAccounts, * as serviceAccountSelectors from './serviceAccounts';
import tasks, * as taskSelectors from './tasks';
import taskRuns, * as taskRunsSelectors from './taskRuns';
import eventListeners, * as eventListenerSelectors from './eventListeners';
import triggerTemplates, * as triggerTemplateSelectors from './triggerTemplates';
import triggerBindings, * as triggerBindingSelectors from './triggerBindings';


export default combineReducers({
  clusterTasks,
  extensions,
  locale,
  namespaces,
  notifications,
  pipelines: pipelines(),
  pipelineResources: pipelineResources(),
  pipelineRuns: pipelineRuns(),
  secrets,
  serviceAccounts: serviceAccounts(),
  tasks: tasks(),
  taskRuns: taskRuns(),
  triggerTemplates: triggerTemplates(),
  triggerBindings: triggerBindings(),
  eventListeners: eventListeners()
});

export function getSelectedNamespace(state) {
  return namespaceSelectors.getSelectedNamespace(state.namespaces);
}

export function getNamespaces(state) {
  return namespaceSelectors.getNamespaces(state.namespaces);
}

export function getServiceAccounts(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return serviceAccountSelectors.getServiceAccounts(
    state.serviceAccounts,
    namespace
  );
}

export function isFetchingServiceAccounts(state) {
  return serviceAccountSelectors.isFetchingServiceAccounts(
    state.serviceAccounts
  );
}

export function getServiceAccountsErrorMessage(state) {
  return serviceAccountSelectors.getServiceAccountsErrorMessage(
    state.serviceAccounts
  );
}

export function isFetchingNamespaces(state) {
  return namespaceSelectors.isFetchingNamespaces(state.namespaces);
}

export function getExtensions(state) {
  return extensionSelectors
    .getExtensions(state.extensions)
    .filter(({ displayName }) => !!displayName);
}

export function getExtensionsErrorMessage(state) {
  return extensionSelectors.getExtensionsErrorMessage(state.extensions);
}

export function isFetchingExtensions(state) {
  return extensionSelectors.isFetchingExtensions(state.extensions);
}

export function getPipeline(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return pipelineSelectors.getPipeline(state.pipelines, name, namespace);
}

export function getPipelines(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return pipelineSelectors.getPipelines(state.pipelines, namespace);
}

export function getPipelinesErrorMessage(state) {
  return pipelineSelectors.getPipelinesErrorMessage(state.pipelines);
}

export function isFetchingPipelines(state) {
  return pipelineSelectors.isFetchingPipelines(state.pipelines);
}

export function getPipelineResources(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return pipelineResourcesSelectors.getPipelineResources(
    state.pipelineResources,
    namespace
  );
}

export function getPipelineResource(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return pipelineResourcesSelectors.getPipelineResource(
    state.pipelineResources,
    name,
    namespace
  );
}

export function getPipelineResourcesErrorMessage(state) {
  return pipelineResourcesSelectors.getPipelineResourcesErrorMessage(
    state.pipelineResources
  );
}

export function isFetchingPipelineResources(state) {
  return pipelineResourcesSelectors.isFetchingPipelineResources(
    state.pipelineResources
  );
}

export function getPipelineRuns(
  state,
  { filters, namespace = getSelectedNamespace(state) } = {}
) {
  const runs = pipelineRunsSelectors.getPipelineRuns(
    state.pipelineRuns,
    namespace
  );
  return runs.filter(pipelineRun => {
    return filters.every(filter => {
      const [filterKey, filterValue] = filter.split('=');
      return (
        pipelineRun.metadata.labels &&
        filterKey &&
        filterValue &&
        pipelineRun.metadata.labels[filterKey] === filterValue
      );
    });
  });
}

export function getPipelineRun(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return pipelineRunsSelectors.getPipelineRun(
    state.pipelineRuns,
    name,
    namespace
  );
}

export function getPipelineRunsErrorMessage(state) {
  return pipelineRunsSelectors.getPipelineRunsErrorMessage(state.pipelineRuns);
}

export function isFetchingPipelineRuns(state) {
  return pipelineRunsSelectors.isFetchingPipelineRuns(state.pipelineRuns);
}

export function getTaskRun(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return taskRunsSelectors.getTaskRun(state.taskRuns, name, namespace);
}

export function getTaskRunsByPipelineRunName(
  state,
  pipelineRunName,
  { namespace = getSelectedNamespace(state) } = {}
) {
  const runs = taskRunsSelectors.getTaskRuns(state.taskRuns, namespace);
  return runs.filter(
    taskRun =>
      taskRun.metadata &&
      taskRun.metadata.labels &&
      taskRun.metadata.labels['tekton.dev/pipelineRun'] === pipelineRunName
  );
}

export function getTaskRuns(
  state,
  { filters, namespace = getSelectedNamespace(state) } = {}
) {
  const runs = taskRunsSelectors.getTaskRuns(state.taskRuns, namespace);
  return runs.filter(taskRun => {
    return filters.every(filter => {
      const [filterKey, filterValue] = filter.split('=');
      return (
        taskRun.metadata.labels &&
        filterKey &&
        filterValue &&
        taskRun.metadata.labels[filterKey] === filterValue
      );
    });
  });
}

export function getTaskRunsErrorMessage(state) {
  return taskRunsSelectors.getTaskRunsErrorMessage(state.taskRuns);
}

export function isFetchingTaskRuns(state) {
  return taskRunsSelectors.isFetchingTaskRuns(state.taskRuns);
}

export function getTasks(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return taskSelectors.getTasks(state.tasks, namespace);
}

export function getTask(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return taskSelectors.getTask(state.tasks, name, namespace);
}

export function getTasksErrorMessage(state) {
  return taskSelectors.getTasksErrorMessage(state.tasks);
}

export function isFetchingTasks(state) {
  return taskSelectors.isFetchingTasks(state.tasks);
}

export function getClusterTasks(state) {
  return clusterTaskSelectors.getClusterTasks(state.clusterTasks);
}

export function getClusterTask(state, name) {
  return clusterTaskSelectors.getClusterTask(state.clusterTasks, name);
}

export function getClusterTasksErrorMessage(state) {
  return clusterTaskSelectors.getClusterTasksErrorMessage(state.clusterTasks);
}

export function isFetchingClusterTasks(state) {
  return clusterTaskSelectors.isFetchingClusterTasks(state.clusterTasks);
}

export function getTaskByType(
  state,
  { type, name, namespace = getSelectedNamespace(state) }
) {
  return type === 'clustertasks'
    ? getClusterTask(state, name)
    : getTask(state, { name, namespace });
}

export function getSecrets(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return secretSelectors.getSecrets(state.secrets, namespace);
}

export function getSecretsErrorMessage(state) {
  return secretSelectors.getSecretsErrorMessage(state.secrets);
}

export function getCreateSecretsSuccessMessage(state) {
  return secretSelectors.getCreateSecretsSuccessMessage(state.secrets);
}

export function getDeleteSecretsSuccessMessage(state) {
  return secretSelectors.getDeleteSecretsSuccessMessage(state.secrets);
}

export function isFetchingSecrets(state) {
  return secretSelectors.isFetchingSecrets(state.secrets);
}

export function getLocale(state) {
  return localeSelectors.getLocale(state.locale);
}

export function isWebSocketConnected(state) {
  return notificationSelectors.isWebSocketConnected(state.notifications);
}

export function getEventListeners(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return eventListenerSelectors.getEventListeners(state.eventListeners, namespace);
}

export function getEventListener(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return eventListenerSelectors.getEventListener(state.pipelines, name, namespace);
}

export function getTriggerBindings(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return triggerBindingSelectors.getTriggerBindings(state.triggerBindings, namespace);
}

export function getTriggerBinding(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return eventListenerSelectors.getTriggerBindings(state.triggerBindings, name, namespace);
}

export function getTriggerTemplates(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return triggerTemplateSelectors.getTriggerTemplates(state.triggertemplates, namespace);
}

export function getTriggerTemplate(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return eventListenerSelectors.getTriggerTemplates(state.triggerTemplates, name, namespace);
}

@carlos-logro
Copy link
Contributor

correct but missing isFetching and getErrorMessage. I was going to include them respectively in the future PR's.

triggerTemplates for example goes:

export function getTriggerTemplates(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return triggerTemplatesSelectors.getTriggerTemplates(
    state.triggerTemplates,
    namespace
  );
}

export function getTriggerTemplate(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return triggerTemplatesSelectors.getTriggerTemplate(
    state.triggerTemplates,
    name,
    namespace
  );
}

export function getTriggerTemplatesErrorMessage(state) {
  return triggerTemplatesSelectors.getTriggerTemplatesErrorMessage(
    state.triggerTemplates
  );
}

export function isFetchingTriggerTemplates(state) {
  return triggerTemplatesSelectors.isFetchingTriggerTemplates(
    state.triggerTemplates
  );
}

@a-roberts
Copy link
Member Author

correct but missing isFetching and getErrorMessage. I was going to include them respectively in the future PR's.

triggerTemplates for example goes:

export function getTriggerTemplates(
  state,
  { namespace = getSelectedNamespace(state) } = {}
) {
  return triggerTemplatesSelectors.getTriggerTemplates(
    state.triggerTemplates,
    namespace
  );
}

export function getTriggerTemplate(
  state,
  { name, namespace = getSelectedNamespace(state) }
) {
  return triggerTemplatesSelectors.getTriggerTemplate(
    state.triggerTemplates,
    name,
    namespace
  );
}

export function getTriggerTemplatesErrorMessage(state) {
  return triggerTemplatesSelectors.getTriggerTemplatesErrorMessage(
    state.triggerTemplates
  );
}

export function isFetchingTriggerTemplates(state) {
  return triggerTemplatesSelectors.isFetchingTriggerTemplates(
    state.triggerTemplates
  );
}

Ok, yeah let's do that then (the follow up PR to add with a combination of our comments above) 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants