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 image tag definition in buildrun spec #233

Merged
merged 4 commits into from
Jun 2, 2020
Merged

Add image tag definition in buildrun spec #233

merged 4 commits into from
Jun 2, 2020

Conversation

xiujuan95
Copy link
Contributor

Fix issue:#150

If imageURL exists in build and buildRun spec simultaneously, then the imageURL in build spec will be overwrote using the imageURL in buildRun spec. Finally, built image will be push into the imageURL in buildRun.

  • Add e2e test for above scenario. E2E test passed:
Ran 16 of 21 Specs in 698.229 seconds
SUCCESS! -- 16 Passed | 0 Failed | 0 Pending | 5 Skipped


Ginkgo ran 1 suite in 12m9.653532807s
Test Suite Passed
  • Besides, for testing locally, we need to define a new environment parameter TEST_IMAGE_REPO_BUILDRUN .

So now, if you want to run e2e test locally, you must export TEST_IMAGE_REPO_BUILDRUN first.

  • Below is an example, build and buildrun both have image url definition:
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
  name: build-image-tag
spec:
  source:
    url: https://github.com/sbose78/taxi
  strategy:
    name: kaniko
    kind: ClusterBuildStrategy
  resources:
    limits:
      cpu: "500m"
      memory: "1Gi"
  output:
    image: us.icr.io/zoe_namespace/imagev1
apiVersion: build.dev/v1alpha1
kind: BuildRun
metadata:
  name: buildrun-image-tag
spec:
  buildRef:
    name: build-image-tag
  output:
    image: us.icr.io/zoe_namespace/imagev2

And then the spec of taskrun should be:

apiVersion: tekton.dev/v1beta1li$ k get tr buildrun-image-tag-8j8j4 -o yaml
kind: TaskRun
metadata:
  annotations:
    pipeline.tekton.dev/release: devel
  creationTimestamp: "2020-05-27T09:09:52Z"
  generateName: buildrun-image-tag-
  generation: 1
  labels:
    app.kubernetes.io/managed-by: tekton-pipelines
    build.build.dev/generation: "1"
    build.build.dev/name: build-image-tag
    buildrun.build.dev/generation: "1"
    buildrun.build.dev/name: buildrun-image-tag
  name: buildrun-image-tag-8j8j4
  namespace: default
  ownerReferences:
  - apiVersion: build.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: BuildRun
    name: buildrun-image-tag
    uid: 3e5e662e-bbd1-41f0-bf5f-0a6eceb53356
  resourceVersion: "3540868"
  selfLink: /apis/tekton.dev/v1beta1/namespaces/default/taskruns/buildrun-image-tag-8j8j4
  uid: 88073643-4a6f-4f76-bc3b-8f4a2cf7447b
spec:
  resources:
    inputs:
    - name: source
      resourceSpec:
        params:
        - name: url
          value: https://github.com/sbose78/taxi
        - name: revision
          value: master
        type: git
    outputs:
    - name: image
      resourceSpec:
        params:
        - name: url
          value: us.icr.io/zoe_namespace/imagev2
        type: image
  serviceAccountName: pipeline
  taskSpec:
    params:
    - default: docker.io/centos/nodejs-8-centos7
      description: Image containing the build tools/logic
      name: BUILDER_IMAGE
      type: string
    - default: Dockerfile
      description: Path to the Dockerfile
      name: DOCKERFILE
      type: string
    - default: .
      description: The root of the code
      name: PATH_CONTEXT
      type: string
    resources:
      inputs:
      - name: source
        type: git
      outputs:
      - name: image
        type: image
    steps:
    - args:
      - --skip-tls-verify=true
      - --dockerfile=$(inputs.params.DOCKERFILE)
      - --context=/workspace/source/$(inputs.params.PATH_CONTEXT)
      - --destination=$(outputs.resources.image.url)
      command:
      - /kaniko/executor
      env:
      - name: DOCKER_CONFIG
        value: /tekton/home/.docker
      image: gcr.io/kaniko-project/executor:latest
      name: step-build-and-push
      resources:
        limits:
          cpu: 500m
          memory: 1Gi
      securityContext:
        capabilities:
          add:
          - CHOWN
          - DAC_OVERRIDE
          - FOWNER
          - SETGID
          - SETUID
        runAsUser: 0
  timeout: 1h0m0s
status:

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 27, 2020
@openshift-ci-robot
Copy link

Hi @xiujuan95. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@SaschaSchwarze0
Copy link
Member

SaschaSchwarze0 commented May 27, 2020 via email

@xiujuan95
Copy link
Contributor Author

@zhangtbj @qu1queee Pls also help review, thanks a lot!

@qu1queee qu1queee self-requested a review May 27, 2020 20:51
@qu1queee
Copy link
Contributor

/assign @qu1queee

@sbose78
Copy link
Member

sbose78 commented May 28, 2020

Are you overriding output image credentials too?

@xiujuan95
Copy link
Contributor Author

Are you overriding output image credentials too?

@sbose78 No, I just change the output image url, I don't overwrite the credentials

Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

@xiujuan95 hi, thanks for the PR. I have a very minor request for change, the rest is actually a more general questions, where I think we do not need the e2e tests, and is enough with the unit tests you wrote. Feel free to challenge this.

pkg/controller/buildrun/generate_taskrun.go Outdated Show resolved Hide resolved
test/e2e/validators.go Outdated Show resolved Hide resolved
@otaviof
Copy link
Member

otaviof commented May 29, 2020

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 29, 2020
@xiujuan95
Copy link
Contributor Author

@xiujuan95 hi, thanks for the PR. I have a very minor request for change, the rest is actually a more general questions, where I think we do not need the e2e tests, and is enough with the unit tests you wrote. Feel free to challenge this.

@qu1queee Thanks for your review! Yes, about this opinion, I agree with you, I have modified it. And also I add imageURL definition doc in buildRun. Pls help review again, thanks a lot!

@zhangtbj zhangtbj added the Release 0.1.x Label for release 0.1.x label Jun 1, 2020
@qu1queee qu1queee self-requested a review June 2, 2020 07:08
Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@qu1queee
Copy link
Contributor

qu1queee commented Jun 2, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2020
@qu1queee
Copy link
Contributor

qu1queee commented Jun 2, 2020

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qu1queee

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 2, 2020
@openshift-merge-robot openshift-merge-robot merged commit 402a5f1 into shipwright-io:master Jun 2, 2020
qu1queee added a commit to qu1queee/build that referenced this pull request Jun 4, 2020
- Add missing spec.output declaration in the buildrun. I think
  this was missing in shipwright-io#233
- Add missing timeout in spec.status.buildSpec, I think this was missed
 somehow after shipwright-io#158 was merged.

Also, this can be reproduced by doing `operator-sdk generate crds`
qu1queee added a commit to qu1queee/build that referenced this pull request Jun 5, 2020
- Add missing spec.output declaration in the buildrun. I think
  this was missing in shipwright-io#233
- Add missing timeout in spec.status.buildSpec, I think this was missed
 somehow after shipwright-io#158 was merged.

Also, this can be reproduced by doing `operator-sdk generate crds`
openshift-merge-robot pushed a commit that referenced this pull request Jun 7, 2020
- Add missing spec.output declaration in the buildrun. I think
  this was missing in #233
- Add missing timeout in spec.status.buildSpec, I think this was missed
 somehow after #158 was merged.

Also, this can be reproduced by doing `operator-sdk generate crds`
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. Release 0.1.x Label for release 0.1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants