kubebb / core

A declarative component lifecycle management platform
https://kubebb.github.io/website
Apache License 2.0
8 stars 9 forks source link

feat: add rating controller #275

Closed 0xff-dev closed 1 year ago

0xff-dev commented 1 year ago

What type of PR is this?

/kind feature

What this PR does / why we need it

feat: add rating controller.

Which issue(s) this PR fixes

Fix: https://github.com/kubebb/core/issues/210

Special notes for your reviewer

example 1

one pipeline with two tasks.

apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: Rating
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"core.kubebb.k8s.com.cn/v1alpha1","kind":"Rating","metadata":{"annotations":{},"name":"rating","namespace":"kubebb-system"},"spec":{"componentName":"kubebb.kubebb-core","pipelineParams":[{"params":[{"name":"URL","value":{"arrayVal":[],"objectVal":{},"stringVal":"https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz","type":"string"}},{"name":"COMPONENT_NAME","value":{"stringVal":"kubebb-core","type":"string"}},{"name":"VERSION","value":{"stringVal":"v0.1.10","type":"string"}},{"name":"REPOSITORY_NAME","value":{"stringVal":"kubebb","type":"string"}}],"pipelineName":"kubebb"}]}}
  creationTimestamp: "2023-08-23T05:34:18Z"
  generation: 2
  labels:
    rating.component: kubebb.kubebb-core
    rating.repository: kubebb
  name: rating
  namespace: kubebb-system
  resourceVersion: "5531804"
  uid: e987a4ec-3713-43b8-a45d-79ed7feffa34
spec:
  componentName: kubebb.kubebb-core
  pipelineParams:
  - params:
    - name: URL
      value:
        stringVal: https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz
        type: string
    - name: COMPONENT_NAME
      value:
        stringVal: kubebb-core
        type: string
    - name: VERSION
      value:
        stringVal: v0.1.10
        type: string
    - name: REPOSITORY_NAME
      value:
        stringVal: kubebb
        type: string
    pipelineName: kubebb
status:
  pipelineRuns:
    rating.kubebb:
      actualWeight: 2
      conditions:
      - lastTransitionTime: "2023-08-23T05:39:53Z"
        message: 'Tasks Completed: 2 (Failed: 0, Cancelled 0), Skipped: 0'
        reason: Succeeded
        status: "True"
        type: Succeeded
      expectWeight: 2
      pipelineName: kubebb
      tasks:
      - conditions:
        - lastTransitionTime: "2023-08-23T05:39:53Z"
          message: All Steps have completed executing
          reason: Succeeded
          status: "True"
          type: Succeeded
        name: kubebb-rback
        taskRunName: rating.kubebb-kubebb-rback
      - conditions:
        - lastTransitionTime: "2023-08-23T05:39:53Z"
          message: All Steps have completed executing
          reason: Succeeded
          status: "True"
          type: Succeeded
        name: kubebb-helm-lint
        taskRunName: rating.kubebb-kubebb-helm-lint

example 2 Each of the two pipelines has a task.

apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: Rating
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"core.kubebb.k8s.com.cn/v1alpha1","kind":"Rating","metadata":{"annotations":{},"name":"two-pipelines","namespace":"kubebb-system"},"spec":{"componentName":"kubebb.kubebb-core","pipelineParams":[{"params":[{"name":"URL","value":{"arrayVal":[],"objectVal":{},"stringVal":"https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz","type":"string"}},{"name":"COMPONENT_NAME","value":{"stringVal":"kubebb-core","type":"string"}},{"name":"VERSION","value":{"stringVal":"v0.1.10","type":"string"}},{"name":"REPOSITORY_NAME","value":{"stringVal":"kubebb","type":"string"}}],"pipelineName":"only-helm-lint"},{"params":[{"name":"URL","value":{"arrayVal":[],"objectVal":{},"stringVal":"https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz","type":"string"}},{"name":"COMPONENT_NAME","value":{"stringVal":"kubebb-core","type":"string"}},{"name":"VERSION","value":{"stringVal":"v0.1.10","type":"string"}},{"name":"REPOSITORY_NAME","value":{"stringVal":"kubebb","type":"string"}}],"pipelineName":"only-rback"}]}}
  creationTimestamp: "2023-08-23T05:41:06Z"
  generation: 2
  labels:
    rating.component: kubebb.kubebb-core
    rating.repository: kubebb
  name: two-pipelines
  namespace: kubebb-system
  resourceVersion: "5532807"
  uid: 9bc38934-45e2-4a1a-b3c3-da59c05f7acf
spec:
  componentName: kubebb.kubebb-core
  pipelineParams:
  - params:
    - name: URL
      value:
        stringVal: https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz
        type: string
    - name: COMPONENT_NAME
      value:
        stringVal: kubebb-core
        type: string
    - name: VERSION
      value:
        stringVal: v0.1.10
        type: string
    - name: REPOSITORY_NAME
      value:
        stringVal: kubebb
        type: string
    pipelineName: only-helm-lint
  - params:
    - name: URL
      value:
        stringVal: https://github.com/kubebb/components/releases/download/kubebb-core-v0.1.10/kubebb-core-v0.1.10.tgz
        type: string
    - name: COMPONENT_NAME
      value:
        stringVal: kubebb-core
        type: string
    - name: VERSION
      value:
        stringVal: v0.1.10
        type: string
    - name: REPOSITORY_NAME
      value:
        stringVal: kubebb
        type: string
    pipelineName: only-rback
status:
  pipelineRuns:
    two-pipelines.only-helm-lint:
      actualWeight: 1
      conditions:
      - lastTransitionTime: "2023-08-23T05:41:16Z"
        message: 'Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0'
        reason: Succeeded
        status: "True"
        type: Succeeded
      expectWeight: 1
      pipelineName: only-helm-lint
      tasks:
      - conditions:
        - lastTransitionTime: "2023-08-23T05:41:16Z"
          message: All Steps have completed executing
          reason: Succeeded
          status: "True"
          type: Succeeded
        name: helm-lint
        taskRunName: two-pipelines.only-helm-lint-helm-lint
    two-pipelines.only-rback:
      actualWeight: 1
      conditions:
      - lastTransitionTime: "2023-08-23T05:43:26Z"
        message: 'Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0'
        reason: Succeeded
        status: "True"
        type: Succeeded
      expectWeight: 1
      pipelineName: only-rback
      tasks:
      - conditions:
        - lastTransitionTime: "2023-08-23T05:43:26Z"
          message: All Steps have completed executing
          reason: Succeeded
          status: "True"
          type: Succeeded
        name: rback
        taskRunName: two-pipelines.only-rback-rback
0xff-dev commented 1 year ago

Does example-test need to be submitted together? In fact, the example-test has not been written yet.😅

codecov[bot] commented 1 year ago

Codecov Report

Merging #275 (693bc24) into main (d73d61f) will decrease coverage by 1.47%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #275      +/-   ##
==========================================
- Coverage   17.60%   16.13%   -1.47%     
==========================================
  Files          35       36       +1     
  Lines        3562     3885     +323     
==========================================
  Hits          627      627              
- Misses       2898     3221     +323     
  Partials       37       37              
Files Changed Coverage Δ
api/v1alpha1/condition.go 100.00% <ø> (ø)
api/v1alpha1/rating.go 0.00% <0.00%> (ø)
api/v1alpha1/rating_types.go 100.00% <ø> (ø)
api/v1alpha1/zz_generated.deepcopy.go 0.00% <0.00%> (ø)
controllers/rating_controller.go 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

Abirdcfly commented 1 year ago

rating config/sample and example-test can add by other pr

bjwswang commented 1 year ago

Does example-test need to be submitted together? In fact, the example-test has not been written yet.😅

it's ok to put it in another pr.BUT...make sure this works for the very common case

bjwswang commented 1 year ago

Seems the taskRunName is wrong