mirror of
https://github.com/kubernetes-csi/csi-driver-nvmf.git
synced 2025-04-27 02:51:26 +00:00
Squashed 'release-tools/' content from commit f9d5b9c
git-subtree-dir: release-tools git-subtree-split: f9d5b9c05ef730f191dd31f2a012d6161d98bff6
This commit is contained in:
commit
4199ec0739
23
.prow.sh
Executable file
23
.prow.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#! /bin/bash -e
|
||||
|
||||
# Copyright 2021 The Kubernetes 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.
|
||||
|
||||
# This is for testing csi-release-tools itself in Prow. All other
|
||||
# repos use prow.sh for that, but as csi-release-tools isn't a normal
|
||||
# repo with some Go code in it, it has a custom Prow test script.
|
||||
|
||||
./verify-shellcheck.sh "$(pwd)"
|
||||
./verify-spelling.sh "$(pwd)"
|
||||
./verify-boilerplate.sh "$(pwd)"
|
31
CONTRIBUTING.md
Normal file
31
CONTRIBUTING.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt:
|
||||
|
||||
_As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._
|
||||
|
||||
## Getting Started
|
||||
|
||||
We have full documentation on how to get started contributing here:
|
||||
|
||||
<!---
|
||||
If your repo has certain guidelines for contribution, put them here ahead of the general k8s resources
|
||||
-->
|
||||
|
||||
- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests
|
||||
- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing)
|
||||
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet.md) - Common resources for existing developers
|
||||
|
||||
## Mentorship
|
||||
|
||||
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!
|
||||
|
||||
<!---
|
||||
Custom Information - if you're copying this template for the first time you can add custom content here, for example:
|
||||
|
||||
## Contact Information
|
||||
|
||||
- [Slack channel](https://kubernetes.slack.com/messages/kubernetes-users) - Replace `kubernetes-users` with your slack channel string, this will send users directly to your channel.
|
||||
- [Mailing list](URL)
|
||||
|
||||
-->
|
40
KUBERNETES_CSI_OWNERS_ALIASES
Normal file
40
KUBERNETES_CSI_OWNERS_ALIASES
Normal file
@ -0,0 +1,40 @@
|
||||
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
|
||||
|
||||
aliases:
|
||||
|
||||
# SIG-Storage chairs and leads should always have approval rights in all repos.
|
||||
# Others may be added as needed here or in each repo.
|
||||
kubernetes-csi-approvers:
|
||||
- jsafrane
|
||||
- msau42
|
||||
- saad-ali
|
||||
- xing-yang
|
||||
|
||||
# Reviewers are automatically assigned to new PRs. The following
|
||||
# reviewers will be active in all repos. Other reviewers can be
|
||||
# added in each repo.
|
||||
#
|
||||
# Reviewers are encouraged to set the "Busy" flag in their GitHub status
|
||||
# when they are temporarily unable to review PRs.
|
||||
kubernetes-csi-reviewers:
|
||||
- andyzhangx
|
||||
- chrishenzie
|
||||
- ggriffiths
|
||||
- gnufied
|
||||
- humblec
|
||||
- mauriciopoppe
|
||||
- j-griffith
|
||||
- jingxu97
|
||||
- jsafrane
|
||||
- pohly
|
||||
- RaunakShah
|
||||
- sunnylovestiramisu
|
||||
- xing-yang
|
||||
|
||||
# This documents who previously contributed to Kubernetes-CSI
|
||||
# as approver.
|
||||
emeritus_approvers:
|
||||
- Jiawei0227
|
||||
- lpabon
|
||||
- sbezverk
|
||||
- vladimirvivien
|
201
LICENSE
Normal file
201
LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
8
OWNERS
Normal file
8
OWNERS
Normal file
@ -0,0 +1,8 @@
|
||||
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
|
||||
|
||||
approvers:
|
||||
- kubernetes-csi-approvers
|
||||
- pohly
|
||||
|
||||
reviewers:
|
||||
- kubernetes-csi-reviewers
|
1
OWNERS_ALIASES
Symbolic link
1
OWNERS_ALIASES
Symbolic link
@ -0,0 +1 @@
|
||||
KUBERNETES_CSI_OWNERS_ALIASES
|
177
README.md
Normal file
177
README.md
Normal file
@ -0,0 +1,177 @@
|
||||
# [csi-release-tools](https://github.com/kubernetes-csi/csi-release-tools)
|
||||
|
||||
These build and test rules can be shared between different Go projects
|
||||
without modifications. Customization for the different projects happen
|
||||
in the top-level Makefile.
|
||||
|
||||
The rules include support for building and pushing Docker images, with
|
||||
the following features:
|
||||
- one or more command and image per project
|
||||
- push canary and/or tagged release images
|
||||
- automatically derive the image tag(s) from repo tags
|
||||
- the source code revision is stored in a "revision" image label
|
||||
- never overwrites an existing release image
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The expected repository layout is:
|
||||
- `cmd/*/*.go` - source code for each command
|
||||
- `cmd/*/Dockerfile` - docker file for each command or
|
||||
Dockerfile in the root when only building a single command
|
||||
- `Makefile` - includes `release-tools/build.make` and sets
|
||||
configuration variables
|
||||
- `.prow.sh` script which imports `release-tools/prow.sh`
|
||||
and may contain further customization
|
||||
- `.cloudbuild.sh` and `cloudbuild.yaml` as symlinks to
|
||||
the corresponding files in `release-tools` or (if necessary)
|
||||
as custom files
|
||||
|
||||
To create a release, tag a certain revision with a name that
|
||||
starts with `v`, for example `v1.0.0`, then `make push`
|
||||
while that commit is checked out.
|
||||
|
||||
It does not matter on which branch that revision exists, i.e. it is
|
||||
possible to create releases directly from master. A release branch can
|
||||
still be created for maintenance releases later if needed.
|
||||
|
||||
Release branches are expected to be named `release-x.y` for releases
|
||||
`x.y.z`. Building from such a branch creates `x.y-canary`
|
||||
images. Building from master creates the main `canary` image.
|
||||
|
||||
Sharing and updating
|
||||
--------------------
|
||||
|
||||
[`git subtree`](https://github.com/git/git/blob/HEAD/contrib/subtree/git-subtree.txt)
|
||||
is the recommended way of maintaining a copy of the rules inside the
|
||||
`release-tools` directory of a project. This way, it is possible to make
|
||||
changes also locally, test them and then push them back to the shared
|
||||
repository at a later time.
|
||||
|
||||
We no longer care about importing the full commit history, so `--squash` should be used
|
||||
when submitting a `release-tools` update. Also make sure that the PR for that
|
||||
contains the automatically generated commit message in the PR description.
|
||||
It contains the list of individual commits that were squashed. The script from
|
||||
https://github.com/kubernetes-csi/csi-release-tools/issues/7 can create such
|
||||
PRs automatically.
|
||||
|
||||
Cheat sheet:
|
||||
|
||||
- `git subtree add --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - add release tools to a repo which does not have them yet (only once)
|
||||
- `git subtree pull --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - update local copy to latest upstream (whenever upstream changes)
|
||||
- edit, `git commit`, `git subtree push --prefix=release-tools git@github.com:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR
|
||||
|
||||
verify-shellcheck.sh
|
||||
--------------------
|
||||
|
||||
The [verify-shellcheck.sh](./verify-shellcheck.sh) script in this repo
|
||||
is a stripped down copy of the [corresponding
|
||||
script](https://github.com/kubernetes/kubernetes/blob/release-1.14/hack/verify-shellcheck.sh)
|
||||
in the Kubernetes repository. It can be used to check for certain
|
||||
errors shell scripts, like missing quotation marks. The default
|
||||
`test-shellcheck` target in [build.make](./build.make) only checks the
|
||||
scripts in this directory. Components can add more directories to
|
||||
`TEST_SHELLCHECK_DIRS` to check also other scripts.
|
||||
|
||||
End-to-end testing
|
||||
------------------
|
||||
|
||||
A repo that wants to opt into testing via Prow must set up a top-level
|
||||
`.prow.sh`. Typically that will source `prow.sh` and then transfer
|
||||
control to it:
|
||||
|
||||
``` bash
|
||||
#! /bin/bash -e
|
||||
|
||||
. release-tools/prow.sh
|
||||
main
|
||||
```
|
||||
|
||||
All Kubernetes-CSI repos are expected to switch to Prow. For details
|
||||
on what is enabled in Prow, see
|
||||
https://github.com/kubernetes/test-infra/tree/HEAD/config/jobs/kubernetes-csi
|
||||
|
||||
Test results for periodic jobs are visible in
|
||||
https://testgrid.k8s.io/sig-storage-csi-ci
|
||||
|
||||
It is possible to reproduce the Prow testing locally on a suitable machine:
|
||||
- Linux host
|
||||
- Docker installed
|
||||
- code to be tested checkout out in `$GOPATH/src/<import path>`
|
||||
- `cd $GOPATH/src/<import path> && ./.prow.sh`
|
||||
|
||||
Beware that the script intentionally doesn't clean up after itself and
|
||||
modifies the content of `$GOPATH`, in particular the `kubernetes` and
|
||||
`kind` repositories there. Better run it in an empty, disposable
|
||||
`$GOPATH`.
|
||||
|
||||
When it terminates, the following command can be used to get access to
|
||||
the Kubernetes cluster that was brought up for testing (assuming that
|
||||
this step succeeded):
|
||||
|
||||
export KUBECONFIG="$(kind get kubeconfig-path --name="csi-prow")"
|
||||
|
||||
It is possible to control the execution via environment variables. See
|
||||
`prow.sh` for details. Particularly useful is testing against different
|
||||
Kubernetes releases:
|
||||
|
||||
CSI_PROW_KUBERNETES_VERSION=1.13.3 ./.prow.sh
|
||||
CSI_PROW_KUBERNETES_VERSION=latest ./.prow.sh
|
||||
|
||||
Dependencies and vendoring
|
||||
--------------------------
|
||||
|
||||
Most projects will (eventually) use `go mod` to manage
|
||||
dependencies. `dep` is also still supported by `csi-release-tools`,
|
||||
but not documented here because it's not recommended anymore.
|
||||
|
||||
The usual instructions for using [go
|
||||
modules](https://github.com/golang/go/wiki/Modules) apply. Here's a cheat sheet
|
||||
for some of the relevant commands:
|
||||
- list available updates: `GO111MODULE=on go list -u -m all`
|
||||
- update or add a single dependency: `GO111MODULE=on go get <package>`
|
||||
- update all dependencies to their next minor or patch release:
|
||||
`GO111MODULE=on go get ./...` (add `-u=patch` to limit to patch
|
||||
releases)
|
||||
- lock onto a specific version: `GO111MODULE=on go get <package>@<version>`
|
||||
- clean up `go.mod`: `GO111MODULE=on go mod tidy`
|
||||
- update vendor directory: `GO111MODULE=on go mod vendor`
|
||||
|
||||
`GO111MODULE=on` can be left out when using Go >= 1.13 or when the
|
||||
source is checked out outside of `$GOPATH`.
|
||||
|
||||
`go mod tidy` must be used to ensure that the listed dependencies are
|
||||
really still needed. Changing import statements or a tentative `go
|
||||
get` can result in stale dependencies.
|
||||
|
||||
The `test-vendor` verifies that it was used when run locally or in a
|
||||
pre-merge CI job. If a `vendor` directory is present, it will also
|
||||
verify that it's content is up-to-date.
|
||||
|
||||
The `vendor` directory is optional. It is still present in projects
|
||||
because it avoids downloading sources during CI builds. If this is no
|
||||
longer deemed necessary, then a project can also remove the directory.
|
||||
|
||||
Conversion of a repository that uses `dep` to `go mod` can be done with:
|
||||
|
||||
GO111MODULE=on go mod init
|
||||
release-tools/go-get-kubernetes.sh <current Kubernetes version from Gopkg.toml>
|
||||
GO111MODULE=on go mod tidy
|
||||
GO111MODULE=on go mod vendor
|
||||
git rm -f Gopkg.toml Gopkg.lock
|
||||
git add go.mod go.sum vendor
|
||||
|
||||
### Updating Kubernetes dependencies
|
||||
|
||||
When using packages that are part of the Kubernetes source code, the
|
||||
commands above are not enough because the [lack of semantic
|
||||
versioning](https://github.com/kubernetes/kubernetes/issues/72638)
|
||||
prevents `go mod` from finding newer releases. Importing directly from
|
||||
`kubernetes/kubernetes` also needs `replace` statements to override
|
||||
the fake `v0.0.0` versions
|
||||
(https://github.com/kubernetes/kubernetes/issues/79384). The
|
||||
`go-get-kubernetes.sh` script can be used to update all packages in
|
||||
lockstep to a different Kubernetes version. Example usage:
|
||||
```
|
||||
$ ./release-tools/go-get-kubernetes.sh 1.16.4
|
||||
```
|
5
RELEASE.md
Normal file
5
RELEASE.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Release Process
|
||||
|
||||
No tagged releases are planned at this point. The intention is to keep
|
||||
the master branch in a state such that it can be used for all
|
||||
supported branches in downstream repos which use these files.
|
14
SECURITY_CONTACTS
Normal file
14
SECURITY_CONTACTS
Normal file
@ -0,0 +1,14 @@
|
||||
# Defined below are the security contacts for this repo.
|
||||
#
|
||||
# They are the contact point for the Product Security Team to reach out
|
||||
# to for triaging and handling of incoming issues.
|
||||
#
|
||||
# The below names agree to abide by the
|
||||
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/HEAD/security-release-process-documentation/security-release-process.md#embargo-policy)
|
||||
# and will be removed and replaced if they violate that agreement.
|
||||
#
|
||||
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
|
||||
# INSTRUCTIONS AT https://kubernetes.io/security/
|
||||
|
||||
saad-ali
|
||||
msau42
|
182
SIDECAR_RELEASE_PROCESS.md
Normal file
182
SIDECAR_RELEASE_PROCESS.md
Normal file
@ -0,0 +1,182 @@
|
||||
# Sidecar Release Process
|
||||
|
||||
This page describes the process for releasing a kubernetes-csi sidecar.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The release manager must:
|
||||
|
||||
* Be a member of the kubernetes-csi organization. Open an
|
||||
[issue](https://github.com/kubernetes/org/issues/new?assignees=&labels=area%2Fgithub-membership&template=membership.md&title=REQUEST%3A+New+membership+for+%3Cyour-GH-handle%3E) in
|
||||
kubernetes/org to request membership
|
||||
* Be part of the maintainers group for the repository.
|
||||
Membership can be requested by submitting a PR to kubernetes/org.
|
||||
[Example](https://github.com/kubernetes/org/pull/1467)
|
||||
|
||||
## Updating CI Jobs
|
||||
Whenever a new Kubernetes minor version is released, our kubernetes-csi CI jobs
|
||||
must be updated.
|
||||
|
||||
[Our CI jobs](https://testgrid.k8s.io/sig-storage-csi-ci) have the
|
||||
naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
|
||||
|
||||
1. Jobs should be actively monitored to find and fix failures in sidecars and
|
||||
infrastructure changes early in the development cycle. Test failures are sent
|
||||
to kubernetes-sig-storage-test-failures@googlegroups.com.
|
||||
1. "-on-master" jobs are the closest reflection to the new Kubernetes version.
|
||||
1. Fixes to our prow.sh CI script can be tested in the [CSI hostpath
|
||||
repo](https://github.com/kubernetes-csi/csi-driver-host-path) by modifying
|
||||
[prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/HEAD/release-tools/prow.sh)
|
||||
along with any overrides in
|
||||
[.prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/HEAD/.prow.sh)
|
||||
to mirror the failing environment. Once e2e tests are passing (verify-unit tests
|
||||
will fail), then the prow.sh changes can be submitted to [csi-release-tools](https://github.com/kubernetes-csi/csi-release-tools).
|
||||
1. Changes can then be updated in all the sidecar repos and hostpath driver repo
|
||||
by following the [update
|
||||
instructions](https://github.com/kubernetes-csi/csi-release-tools/blob/HEAD/README.md#sharing-and-updating).
|
||||
1. New pull and CI jobs are configured by adding new K8s versions to the top of
|
||||
[gen-jobs.sh](https://github.com/kubernetes/test-infra/blob/HEAD/config/jobs/kubernetes-csi/gen-jobs.sh).
|
||||
New pull jobs that have been unverified should be initially made optional by
|
||||
setting the new K8s version as
|
||||
[experimental](https://github.com/kubernetes/test-infra/blob/a1858f46d6014480b130789df58b230a49203a64/config/jobs/kubernetes-csi/gen-jobs.sh#L40).
|
||||
1. Once new pull and CI jobs have been verified, and the new Kubernetes version
|
||||
is released, we can make the optional jobs required, and also remove the
|
||||
Kubernetes versions that are no longer supported.
|
||||
|
||||
## Release Process
|
||||
1. Identify all issues and ongoing PRs that should go into the release, and
|
||||
drive them to resolution.
|
||||
1. Download the latest version of the
|
||||
[K8s release notes generator](https://github.com/kubernetes/release/tree/HEAD/cmd/release-notes)
|
||||
1. Create a
|
||||
[Github personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
||||
with `repo:public_repo` access
|
||||
1. Generate release notes for the release. Replace arguments with the relevant
|
||||
information.
|
||||
* Clean up old cached information (also needed if you are generating release
|
||||
notes for multiple repos)
|
||||
```bash
|
||||
rm -rf /tmp/k8s-repo
|
||||
```
|
||||
* For new minor releases on master:
|
||||
```bash
|
||||
GITHUB_TOKEN=<token> release-notes \
|
||||
--discover=mergebase-to-latest \
|
||||
--org=kubernetes-csi \
|
||||
--repo=external-provisioner \
|
||||
--required-author="" \
|
||||
--markdown-links \
|
||||
--output out.md
|
||||
```
|
||||
* For new patch releases on a release branch:
|
||||
```bash
|
||||
GITHUB_TOKEN=<token> release-notes \
|
||||
--discover=patch-to-latest \
|
||||
--branch=release-1.1 \
|
||||
--org=kubernetes-csi \
|
||||
--repo=external-provisioner \
|
||||
--required-author="" \
|
||||
--markdown-links \
|
||||
--output out.md
|
||||
```
|
||||
1. Compare the generated output to the new commits for the release to check if
|
||||
any notable change missed a release note.
|
||||
1. Reword release notes as needed. Make sure to check notes for breaking
|
||||
changes and deprecations.
|
||||
1. If release is a new major/minor version, create a new `CHANGELOG-<major>.<minor>.md`
|
||||
file. Otherwise, add the release notes to the top of the existing CHANGELOG
|
||||
file for that minor version.
|
||||
1. Submit a PR for the CHANGELOG changes.
|
||||
1. Submit a PR for README changes, in particular, Compatibility, Feature status,
|
||||
and any other sections that may need updating.
|
||||
1. Check that all [canary CI
|
||||
jobs](https://testgrid.k8s.io/sig-storage-csi-ci) are passing,
|
||||
and that test coverage is adequate for the changes that are going into the release.
|
||||
1. Check that the post-\<sidecar\>-push-images builds are succeeding.
|
||||
[Example](https://testgrid.k8s.io/sig-storage-image-build#post-external-snapshotter-push-images)
|
||||
1. Make sure that no new PRs have merged in the meantime, and no PRs are in
|
||||
flight and soon to be merged.
|
||||
1. Create a new release following a previous release as a template. Be sure to select the correct
|
||||
branch. This requires Github release permissions as required by the prerequisites.
|
||||
[external-provisioner example](https://github.com/kubernetes-csi/external-provisioner/releases/new)
|
||||
1. If release was a new major/minor version, create a new `release-<minor>`
|
||||
branch at that commit.
|
||||
1. Check [image build status](https://testgrid.k8s.io/sig-storage-image-build).
|
||||
1. Promote images from k8s-staging-sig-storage to registry.k8s.io/sig-storage. From
|
||||
the [k8s image
|
||||
repo](https://github.com/kubernetes/k8s.io/tree/HEAD/registry.k8s.io/images/k8s-staging-sig-storage),
|
||||
run `./generate.sh > images.yaml`, and send a PR with the updated images.
|
||||
Once merged, the image promoter will copy the images from staging to prod.
|
||||
1. Update [kubernetes-csi/docs](https://github.com/kubernetes-csi/docs) sidecar
|
||||
and feature pages with the new released version.
|
||||
1. After all the sidecars have been released, update
|
||||
CSI hostpath driver with the new sidecars in the [CSI repo](https://github.com/kubernetes-csi/csi-driver-host-path/tree/HEAD/deploy)
|
||||
and [k/k
|
||||
in-tree](https://github.com/kubernetes/kubernetes/tree/HEAD/test/e2e/testing-manifests/storage-csi/hostpath/hostpath)
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Image build jobs
|
||||
|
||||
The following jobs are triggered after tagging to produce the corresponding
|
||||
image(s):
|
||||
https://testgrid.k8s.io/sig-storage-image-build
|
||||
|
||||
Clicking on a failed build job opens that job in https://prow.k8s.io. Next to
|
||||
the job title is a rerun icon (circle with arrow). Clicking it opens a popup
|
||||
with a "rerun" button that maintainers with enough permissions can use. If in
|
||||
doubt, ask someone on #sig-release to rerun the job.
|
||||
|
||||
Another way to rerun a job is to search for it in https://prow.k8s.io and click
|
||||
the rerun icon in the resulting job list:
|
||||
https://prow.k8s.io/?job=canary-csi-test-push-images
|
||||
|
||||
#### Verify images
|
||||
|
||||
Canary and staged images can be viewed at https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage
|
||||
|
||||
Promoted images can be viewed at https://console.cloud.google.com/gcr/images/k8s-artifacts-prod/us/sig-storage
|
||||
|
||||
## Adding support for a new Kubernetes release
|
||||
|
||||
1. Add the new release to `k8s_versions` in
|
||||
https://github.com/kubernetes/test-infra/blob/090dec5dd535d5f61b7ba52e671a810f5fc13dfd/config/jobs/kubernetes-csi/gen-jobs.sh#L25
|
||||
to enable generating a job for it. Set `experimental_k8s_version`
|
||||
in
|
||||
https://github.com/kubernetes/test-infra/blob/090dec5dd535d5f61b7ba52e671a810f5fc13dfd/config/jobs/kubernetes-csi/gen-jobs.sh#L40
|
||||
to ensure that the new jobs aren't run for PRs unless explicitly
|
||||
requested. Generate and submit the new jobs.
|
||||
1. Create a test PR to try out the new job in some repo with `/test
|
||||
pull-kubernetes-csi-<repo>-<x.y>-on-kubernetes-<x.y>` where x.y
|
||||
matches the Kubernetes release. Alternatively, run .prow.sh in that
|
||||
repo locally with `CSI_PROW_KUBERNETES_VERSION=x.y.z`.
|
||||
1. Optional: update to a [new
|
||||
release](https://github.com/kubernetes-sigs/kind/tags) of kind with
|
||||
pre-built images for the new Kubernetes release. This is optional
|
||||
if the current version of kind is able to build images for the new
|
||||
Kubernetes release. However, jobs require less resources when they
|
||||
don't need to build those images from the Kubernetes source code.
|
||||
This change needs to be tried out in a PR against a component
|
||||
first, then get submitted against csi-release-tools.
|
||||
1. Optional: propagate the updated csi-release-tools to all components
|
||||
with the script from
|
||||
https://github.com/kubernetes-csi/csi-release-tools/issues/7#issuecomment-707025402
|
||||
1. Once it is likely to work in all components, unset
|
||||
`experimental_k8s_version` and submit the updated jobs.
|
||||
1. Once all sidecars for the new Kubernetes release are released,
|
||||
either bump the version number of the images in the existing
|
||||
[csi-driver-host-path
|
||||
deployments](https://github.com/kubernetes-csi/csi-driver-host-path/tree/HEAD/deploy)
|
||||
and/or create a new deployment, depending on what Kubernetes
|
||||
release an updated sidecar is compatible with. If no new deployment
|
||||
is needed, then add a symlink to document that there intentionally
|
||||
isn't a separate deployment. This symlink is not needed for Prow
|
||||
testing because that will use "kubernetes-latest" as fallback.
|
||||
Update that link when creating a new deployment.
|
||||
1. Create a new csi-driver-host-path release.
|
||||
1. Bump `CSI_PROW_DRIVER_VERSION` in prow.sh to that new release and
|
||||
(eventually) roll that change out to all repos by updating
|
||||
`release-tools` in them. This is used when testing manually. The
|
||||
Prow jobs override that value, so also update
|
||||
`hostpath_driver_version` in
|
||||
https://github.com/kubernetes/test-infra/blob/91b04e6af3a40a9bcff25aa030850a4721e2dd2b/config/jobs/kubernetes-csi/gen-jobs.sh#L46-L47
|
13
boilerplate/boilerplate.Dockerfile.txt
Normal file
13
boilerplate/boilerplate.Dockerfile.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright YEAR The Kubernetes 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.
|
13
boilerplate/boilerplate.Makefile.txt
Normal file
13
boilerplate/boilerplate.Makefile.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright YEAR The Kubernetes 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.
|
13
boilerplate/boilerplate.bzl.txt
Normal file
13
boilerplate/boilerplate.bzl.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright YEAR The Kubernetes 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.
|
15
boilerplate/boilerplate.go.txt
Normal file
15
boilerplate/boilerplate.go.txt
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright YEAR The Kubernetes 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.
|
||||
*/
|
200
boilerplate/boilerplate.py
Executable file
200
boilerplate/boilerplate.py
Executable file
@ -0,0 +1,200 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import difflib
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import date
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"filenames",
|
||||
help="list of files to check, all files if unspecified",
|
||||
nargs='*')
|
||||
|
||||
# Rootdir defaults to the directory **above** the repo-infra dir.
|
||||
rootdir = os.path.dirname(__file__) + "./../../"
|
||||
rootdir = os.path.abspath(rootdir)
|
||||
parser.add_argument(
|
||||
"--rootdir", default=rootdir, help="root directory to examine")
|
||||
|
||||
default_boilerplate_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
parser.add_argument(
|
||||
"--boilerplate-dir", default=default_boilerplate_dir)
|
||||
|
||||
parser.add_argument(
|
||||
"-v", "--verbose",
|
||||
help="give verbose output regarding why a file does not pass",
|
||||
action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
verbose_out = sys.stderr if args.verbose else open("/dev/null", "w")
|
||||
|
||||
def get_refs():
|
||||
refs = {}
|
||||
|
||||
for path in glob.glob(os.path.join(args.boilerplate_dir, "boilerplate.*.txt")):
|
||||
extension = os.path.basename(path).split(".")[1]
|
||||
|
||||
ref_file = open(path, 'r')
|
||||
ref = ref_file.read().splitlines()
|
||||
ref_file.close()
|
||||
refs[extension] = ref
|
||||
|
||||
return refs
|
||||
|
||||
def file_passes(filename, refs, regexs):
|
||||
try:
|
||||
f = open(filename, 'r')
|
||||
except Exception as exc:
|
||||
print("Unable to open %s: %s" % (filename, exc), file=verbose_out)
|
||||
return False
|
||||
|
||||
data = f.read()
|
||||
f.close()
|
||||
|
||||
basename = os.path.basename(filename)
|
||||
extension = file_extension(filename)
|
||||
if extension != "":
|
||||
ref = refs[extension]
|
||||
else:
|
||||
ref = refs[basename]
|
||||
|
||||
# remove build tags from the top of Go files
|
||||
if extension == "go":
|
||||
p = regexs["go_build_constraints"]
|
||||
(data, found) = p.subn("", data, 1)
|
||||
|
||||
# remove shebang from the top of shell files
|
||||
if extension == "sh" or extension == "py":
|
||||
p = regexs["shebang"]
|
||||
(data, found) = p.subn("", data, 1)
|
||||
|
||||
data = data.splitlines()
|
||||
|
||||
# if our test file is smaller than the reference it surely fails!
|
||||
if len(ref) > len(data):
|
||||
print('File %s smaller than reference (%d < %d)' %
|
||||
(filename, len(data), len(ref)),
|
||||
file=verbose_out)
|
||||
return False
|
||||
|
||||
# trim our file to the same number of lines as the reference file
|
||||
data = data[:len(ref)]
|
||||
|
||||
p = regexs["year"]
|
||||
for d in data:
|
||||
if p.search(d):
|
||||
print('File %s is missing the year' % filename, file=verbose_out)
|
||||
return False
|
||||
|
||||
# Replace all occurrences of the regex "CURRENT_YEAR|...|2016|2015|2014" with "YEAR"
|
||||
p = regexs["date"]
|
||||
for i, d in enumerate(data):
|
||||
(data[i], found) = p.subn('YEAR', d)
|
||||
if found != 0:
|
||||
break
|
||||
|
||||
# if we don't match the reference at this point, fail
|
||||
if ref != data:
|
||||
print("Header in %s does not match reference, diff:" % filename, file=verbose_out)
|
||||
if args.verbose:
|
||||
print(file=verbose_out)
|
||||
for line in difflib.unified_diff(ref, data, 'reference', filename, lineterm=''):
|
||||
print(line, file=verbose_out)
|
||||
print(file=verbose_out)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def file_extension(filename):
|
||||
return os.path.splitext(filename)[1].split(".")[-1].lower()
|
||||
|
||||
skipped_dirs = ['Godeps', 'third_party', '_gopath', '_output', '.git',
|
||||
'cluster/env.sh', 'vendor', 'test/e2e/generated/bindata.go',
|
||||
'repo-infra/verify/boilerplate/test', '.glide']
|
||||
|
||||
def normalize_files(files):
|
||||
newfiles = []
|
||||
for pathname in files:
|
||||
if any(x in pathname for x in skipped_dirs):
|
||||
continue
|
||||
newfiles.append(pathname)
|
||||
return newfiles
|
||||
|
||||
def get_files(extensions):
|
||||
files = []
|
||||
if len(args.filenames) > 0:
|
||||
files = args.filenames
|
||||
else:
|
||||
for root, dirs, walkfiles in os.walk(args.rootdir):
|
||||
# don't visit certain dirs. This is just a performance improvement
|
||||
# as we would prune these later in normalize_files(). But doing it
|
||||
# cuts down the amount of filesystem walking we do and cuts down
|
||||
# the size of the file list
|
||||
for d in skipped_dirs:
|
||||
if d in dirs:
|
||||
dirs.remove(d)
|
||||
|
||||
for name in walkfiles:
|
||||
pathname = os.path.join(root, name)
|
||||
files.append(pathname)
|
||||
|
||||
files = normalize_files(files)
|
||||
|
||||
outfiles = []
|
||||
for pathname in files:
|
||||
basename = os.path.basename(pathname)
|
||||
extension = file_extension(pathname)
|
||||
if extension in extensions or basename in extensions:
|
||||
outfiles.append(pathname)
|
||||
return outfiles
|
||||
|
||||
def get_regexs():
|
||||
regexs = {}
|
||||
# Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing
|
||||
regexs["year"] = re.compile( 'YEAR' )
|
||||
# dates can be 2014, 2015, 2016, ..., CURRENT_YEAR, company holder names can be anything
|
||||
years = range(2014, date.today().year + 1)
|
||||
regexs["date"] = re.compile( '(%s)' % "|".join(map(lambda l: str(l), years)) )
|
||||
# strip // +build \n\n build constraints
|
||||
regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE)
|
||||
# strip #!.* from shell scripts
|
||||
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
|
||||
return regexs
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
regexs = get_regexs()
|
||||
refs = get_refs()
|
||||
filenames = get_files(refs.keys())
|
||||
|
||||
for filename in filenames:
|
||||
if not file_passes(filename, refs, regexs):
|
||||
print(filename, file=sys.stdout)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
13
boilerplate/boilerplate.py.txt
Normal file
13
boilerplate/boilerplate.py.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright YEAR The Kubernetes 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.
|
13
boilerplate/boilerplate.sh.txt
Normal file
13
boilerplate/boilerplate.sh.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright YEAR The Kubernetes 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.
|
324
build.make
Normal file
324
build.make
Normal file
@ -0,0 +1,324 @@
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
# force the usage of /bin/bash instead of /bin/sh
|
||||
SHELL := /bin/bash
|
||||
|
||||
.PHONY: build-% build container-% container push-% push clean test
|
||||
|
||||
# A space-separated list of all commands in the repository, must be
|
||||
# set in main Makefile of a repository.
|
||||
# CMDS=
|
||||
|
||||
# Normally, commands are expected in "cmd". That can be changed for a
|
||||
# repository to something else by setting CMDS_DIR before including build.make.
|
||||
CMDS_DIR ?= cmd
|
||||
|
||||
# This is the default. It can be overridden in the main Makefile after
|
||||
# including build.make.
|
||||
REGISTRY_NAME?=quay.io/k8scsi
|
||||
|
||||
# Can be set to -mod=vendor to ensure that the "vendor" directory is used.
|
||||
GOFLAGS_VENDOR=
|
||||
|
||||
# Revision that gets built into each binary via the main.version
|
||||
# string. Uses the `git describe` output based on the most recent
|
||||
# version tag with a short revision suffix or, if nothing has been
|
||||
# tagged yet, just the revision.
|
||||
#
|
||||
# Beware that tags may also be missing in shallow clones as done by
|
||||
# some CI systems (like TravisCI, which pulls only 50 commits).
|
||||
REV=$(shell git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD)
|
||||
|
||||
# A space-separated list of image tags under which the current build is to be pushed.
|
||||
# Determined dynamically.
|
||||
IMAGE_TAGS=
|
||||
|
||||
# A "canary" image gets built if the current commit is the head of the remote "master" branch.
|
||||
# That branch does not exist when building some other branch in TravisCI.
|
||||
IMAGE_TAGS+=$(shell if [ "$$(git rev-list -n1 HEAD)" = "$$(git rev-list -n1 origin/master 2>/dev/null)" ]; then echo "canary"; fi)
|
||||
|
||||
# A "X.Y.Z-canary" image gets built if the current commit is the head of a "origin/release-X.Y.Z" branch.
|
||||
# The actual suffix does not matter, only the "release-" prefix is checked.
|
||||
IMAGE_TAGS+=$(shell git branch -r --points-at=HEAD | grep 'origin/release-' | grep -v -e ' -> ' | sed -e 's;.*/release-\(.*\);\1-canary;')
|
||||
|
||||
# A release image "vX.Y.Z" gets built if there is a tag of that format for the current commit.
|
||||
# --abbrev=0 suppresses long format, only showing the closest tag.
|
||||
IMAGE_TAGS+=$(shell tagged="$$(git describe --tags --match='v*' --abbrev=0)"; if [ "$$tagged" ] && [ "$$(git rev-list -n1 HEAD)" = "$$(git rev-list -n1 $$tagged)" ]; then echo $$tagged; fi)
|
||||
|
||||
# Images are named after the command contained in them.
|
||||
IMAGE_NAME=$(REGISTRY_NAME)/$*
|
||||
|
||||
ifdef V
|
||||
# Adding "-alsologtostderr" assumes that all test binaries contain glog. This is not guaranteed.
|
||||
TESTARGS = -v -args -alsologtostderr -v 5
|
||||
else
|
||||
TESTARGS =
|
||||
endif
|
||||
|
||||
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
|
||||
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
|
||||
|
||||
# BUILD_PLATFORMS contains a set of tuples [os arch buildx_platform suffix base_image addon_image]
|
||||
# separated by semicolon. An empty variable or empty entry (= just a
|
||||
# semicolon) builds for the default platform of the current Go
|
||||
# toolchain.
|
||||
BUILD_PLATFORMS =
|
||||
|
||||
# Add go ldflags using LDFLAGS at the time of compilation.
|
||||
IMPORTPATH_LDFLAGS = -X main.version=$(REV)
|
||||
EXT_LDFLAGS = -extldflags "-static"
|
||||
LDFLAGS =
|
||||
FULL_LDFLAGS = $(LDFLAGS) $(IMPORTPATH_LDFLAGS) $(EXT_LDFLAGS)
|
||||
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
|
||||
# defined by BUILD_PLATFORMS.
|
||||
$(CMDS:%=build-%): build-%: check-go-version-go
|
||||
mkdir -p bin
|
||||
# os_arch_seen captures all of the $$os-$$arch-$$buildx_platform seen for the current binary
|
||||
# that we want to build, if we've seen an $$os-$$arch-$$buildx_platform before it means that
|
||||
# we don't need to build it again, this is done to avoid building
|
||||
# the windows binary multiple times (see the default value of $$BUILD_PLATFORMS)
|
||||
export os_arch_seen="" && echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
|
||||
os_arch_seen_pre=$${os_arch_seen%%$$os-$$arch-$$buildx_platform*}; \
|
||||
if ! [ $${#os_arch_seen_pre} = $${#os_arch_seen} ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ! (set -x; cd ./$(CMDS_DIR)/$* && CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '$(FULL_LDFLAGS)' -o "$(abspath ./bin)/$*$$suffix" .); then \
|
||||
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
os_arch_seen+=";$$os-$$arch-$$buildx_platform"; \
|
||||
done
|
||||
|
||||
$(CMDS:%=container-%): container-%: build-%
|
||||
docker build -t $*:latest -f $(shell if [ -e ./$(CMDS_DIR)/$*/Dockerfile ]; then echo ./$(CMDS_DIR)/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
|
||||
|
||||
$(CMDS:%=push-%): push-%: container-%
|
||||
set -ex; \
|
||||
push_image () { \
|
||||
docker tag $*:latest $(IMAGE_NAME):$$tag; \
|
||||
docker push $(IMAGE_NAME):$$tag; \
|
||||
}; \
|
||||
for tag in $(IMAGE_TAGS); do \
|
||||
if [ "$$tag" = "canary" ] || echo "$$tag" | grep -q -e '-canary$$'; then \
|
||||
: "creating or overwriting canary image"; \
|
||||
push_image; \
|
||||
elif docker pull $(IMAGE_NAME):$$tag 2>&1 | tee /dev/stderr | grep -q "manifest for $(IMAGE_NAME):$$tag not found"; then \
|
||||
: "creating release image"; \
|
||||
push_image; \
|
||||
else \
|
||||
: "release image $(IMAGE_NAME):$$tag already exists, skipping push"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
build: $(CMDS:%=build-%)
|
||||
container: $(CMDS:%=container-%)
|
||||
push: $(CMDS:%=push-%)
|
||||
|
||||
# Additional parameters are needed when pushing to a local registry,
|
||||
# see https://github.com/docker/buildx/issues/94.
|
||||
# However, that then runs into https://github.com/docker/cli/issues/2396.
|
||||
#
|
||||
# What works for local testing is:
|
||||
# make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=<your account on dockerhub.io> BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x"
|
||||
DOCKER_BUILDX_CREATE_ARGS ?=
|
||||
|
||||
# This target builds a multiarch image for one command using Moby BuildKit builder toolkit.
|
||||
# Docker Buildx is included in Docker 19.03.
|
||||
#
|
||||
# ./$(CMDS_DIR)/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
|
||||
# It is currently optional: if no such file exists, Windows images are not included,
|
||||
# even when Windows is listed in BUILD_PLATFORMS. That way, projects can test that
|
||||
# Windows binaries can be built before adding a Dockerfile for it.
|
||||
#
|
||||
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
|
||||
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
|
||||
# the tag for the resulting multiarch image.
|
||||
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
|
||||
set -ex; \
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled; \
|
||||
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest --driver-opt image=moby/buildkit:v0.10.6; \
|
||||
trap "docker buildx rm multiarchimage-buildertest" EXIT; \
|
||||
dockerfile_linux=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile ]; then echo ./$(CMDS_DIR)/$*/Dockerfile; else echo Dockerfile; fi); \
|
||||
dockerfile_windows=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile.Windows ]; then echo ./$(CMDS_DIR)/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
|
||||
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
|
||||
if ! [ -f "$$dockerfile_windows" ]; then \
|
||||
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *[^ ]* *.exe *[^ ]* *[^ ]*//g' -e 's/; *;/;/g' -e 's/;[ ]*$$//')"; \
|
||||
fi; \
|
||||
pushMultiArch () { \
|
||||
tag=$$1; \
|
||||
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
|
||||
escaped_base_image=$${base_image/:/-}; \
|
||||
escaped_buildx_platform=$${buildx_platform//\//-}; \
|
||||
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \
|
||||
docker buildx build --push \
|
||||
--tag $(IMAGE_NAME):$$escaped_buildx_platform-$$os-$$escaped_base_image$$tag \
|
||||
--platform=$$os/$$buildx_platform \
|
||||
--file $$(eval echo \$${dockerfile_$$os}) \
|
||||
--build-arg binary=./bin/$*$$suffix \
|
||||
--build-arg ARCH=$$arch \
|
||||
--build-arg BASE_IMAGE=$$base_image \
|
||||
--build-arg ADDON_IMAGE=$$addon_image \
|
||||
--label revision=$(REV) \
|
||||
.; \
|
||||
done; \
|
||||
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
|
||||
escaped_base_image=$${base_image/:/-}; \
|
||||
escaped_buildx_platform=$${buildx_platform//\//-}; \
|
||||
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \
|
||||
echo $(IMAGE_NAME):$$escaped_buildx_platform-$$os-$$escaped_base_image$$tag; \
|
||||
done); \
|
||||
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
|
||||
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \
|
||||
if [ $$os = "windows" ]; then \
|
||||
escaped_base_image=$${base_image/:/-}; \
|
||||
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi; \
|
||||
image=$(IMAGE_NAME):$$arch-$$os-$$escaped_base_image$$tag; \
|
||||
os_version=$$(docker manifest inspect mcr.microsoft.com/windows/$${base_image} | grep "os.version" | head -n 1 | awk '{print $$2}' | sed -e 's/"//g') || true; \
|
||||
docker manifest annotate --os-version $$os_version $(IMAGE_NAME):$$tag $$image; \
|
||||
fi; \
|
||||
done; \
|
||||
docker manifest push -p $(IMAGE_NAME):$$tag; \
|
||||
}; \
|
||||
if [ $(PULL_BASE_REF) = "master" ]; then \
|
||||
: "creating or overwriting canary image"; \
|
||||
pushMultiArch canary; \
|
||||
elif echo $(PULL_BASE_REF) | grep -q -e 'release-*' ; then \
|
||||
: "creating or overwriting canary image for release branch"; \
|
||||
release_canary_tag=$$(echo $(PULL_BASE_REF) | cut -f2 -d '-')-canary; \
|
||||
pushMultiArch $$release_canary_tag; \
|
||||
elif docker pull $(IMAGE_NAME):$(PULL_BASE_REF) 2>&1 | tee /dev/stderr | grep -q "manifest for $(IMAGE_NAME):$(PULL_BASE_REF) not found"; then \
|
||||
: "creating release image"; \
|
||||
pushMultiArch $(PULL_BASE_REF); \
|
||||
else \
|
||||
: "ERROR: release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists: a new tag is required!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: check-pull-base-ref
|
||||
check-pull-base-ref:
|
||||
if ! [ "$(PULL_BASE_REF)" ]; then \
|
||||
echo >&2 "ERROR: PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: push-multiarch
|
||||
push-multiarch: $(CMDS:%=push-multiarch-%)
|
||||
|
||||
clean:
|
||||
-rm -rf bin
|
||||
|
||||
test: check-go-version-go
|
||||
|
||||
.PHONY: test-go
|
||||
test: test-go
|
||||
test-go:
|
||||
@ echo; echo "### $@:"
|
||||
go test $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
|
||||
|
||||
.PHONY: test-vet
|
||||
test: test-vet
|
||||
test-vet:
|
||||
@ echo; echo "### $@:"
|
||||
go vet $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
|
||||
|
||||
.PHONY: test-fmt
|
||||
test: test-fmt
|
||||
test-fmt:
|
||||
@ echo; echo "### $@:"
|
||||
files=$$(find . -name '*.go' | grep -v './vendor' $(TEST_FMT_FILTER_CMD)); \
|
||||
if [ $$(gofmt -d $$files | wc -l) -ne 0 ]; then \
|
||||
echo "formatting errors:"; \
|
||||
gofmt -d $$files; \
|
||||
false; \
|
||||
fi
|
||||
|
||||
# This test only runs when dep >= 0.5 is installed, which is the case for the CI setup.
|
||||
# When using 'go mod', we allow the test to be skipped in the Prow CI under some special
|
||||
# circumstances, because it depends on accessing all remote repos and thus
|
||||
# running it all the time would defeat the purpose of vendoring:
|
||||
# - not handling a PR or
|
||||
# - the fabricated merge commit leaves go.mod, go.sum and vendor dir unchanged
|
||||
# - release-tools also didn't change (changing rules or Go version might lead to
|
||||
# a different result and thus must be tested)
|
||||
# - import statements not changed (because if they change, go.mod might have to be updated)
|
||||
#
|
||||
# "git diff" is intelligent enough to annotate changes inside the "import" block in
|
||||
# the start of the diff hunk:
|
||||
#
|
||||
# diff --git a/rpc/common.go b/rpc/common.go
|
||||
# index bb4a5c4..5fa4271 100644
|
||||
# --- a/rpc/common.go
|
||||
# +++ b/rpc/common.go
|
||||
# @@ -21,7 +21,6 @@ import (
|
||||
# "fmt"
|
||||
# "time"
|
||||
#
|
||||
# - "google.golang.org/grpc"
|
||||
# "google.golang.org/grpc/codes"
|
||||
# "google.golang.org/grpc/status"
|
||||
#
|
||||
# We rely on that to find such changes.
|
||||
#
|
||||
# Vendoring is optional when using go.mod.
|
||||
.PHONY: test-vendor
|
||||
test: test-vendor
|
||||
test-vendor:
|
||||
@ echo; echo "### $@:"
|
||||
@ ./release-tools/verify-vendor.sh
|
||||
|
||||
.PHONY: test-subtree
|
||||
test: test-subtree
|
||||
test-subtree:
|
||||
@ echo; echo "### $@:"
|
||||
./release-tools/verify-subtree.sh release-tools
|
||||
|
||||
# Components can extend the set of directories which must pass shellcheck.
|
||||
# The default is to check only the release-tools directory itself.
|
||||
TEST_SHELLCHECK_DIRS=release-tools
|
||||
.PHONY: test-shellcheck
|
||||
test: test-shellcheck
|
||||
test-shellcheck:
|
||||
@ echo; echo "### $@:"
|
||||
@ ret=0; \
|
||||
if ! command -v docker; then \
|
||||
echo "skipped, no Docker"; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
|
||||
echo; \
|
||||
echo "$$dir:"; \
|
||||
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
|
||||
done; \
|
||||
exit $$ret
|
||||
|
||||
# Targets in the makefile can depend on check-go-version-<path to go binary>
|
||||
# to trigger a warning if the x.y version of that binary does not match
|
||||
# what the project uses. Make ensures that this is only checked once per
|
||||
# invocation.
|
||||
.PHONY: check-go-version-%
|
||||
check-go-version-%:
|
||||
./release-tools/verify-go-version.sh "$*"
|
||||
|
||||
# Test for spelling errors.
|
||||
.PHONY: test-spelling
|
||||
test-spelling:
|
||||
@ echo; echo "### $@:"
|
||||
@ ./release-tools/verify-spelling.sh "$(pwd)"
|
||||
|
||||
# Test the boilerplates of the files.
|
||||
.PHONY: test-boilerplate
|
||||
test-boilerplate:
|
||||
@ echo; echo "### $@:"
|
||||
@ ./release-tools/verify-boilerplate.sh "$(pwd)"
|
20
cloudbuild.sh
Executable file
20
cloudbuild.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Copyright 2021 The Kubernetes 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.
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. release-tools/prow.sh
|
||||
|
||||
gcr_cloud_build
|
47
cloudbuild.yaml
Normal file
47
cloudbuild.yaml
Normal file
@ -0,0 +1,47 @@
|
||||
# A configuration file for multi-arch image building with the Google cloud build service.
|
||||
#
|
||||
# Repos using this file must:
|
||||
# - import csi-release-tools
|
||||
# - add a symlink cloudbuild.yaml -> release-tools/cloudbuild.yaml
|
||||
# - add a .cloudbuild.sh which can be a custom file or a symlink
|
||||
# to release-tools/cloudbuild.sh
|
||||
# - accept "binary" as build argument in their Dockerfile(s) (see
|
||||
# https://github.com/pohly/node-driver-registrar/blob/3018101987b0bb6da2a2657de607174d6e3728f7/Dockerfile#L4-L6)
|
||||
# because binaries will get built for different architectures and then
|
||||
# get copied from the built host into the container image
|
||||
#
|
||||
# See https://github.com/kubernetes/test-infra/blob/HEAD/config/jobs/image-pushing/README.md
|
||||
# for more details on image pushing process in Kubernetes.
|
||||
#
|
||||
# To promote release images, see https://github.com/kubernetes/k8s.io/tree/HEAD/registry.k8s.io/images/k8s-staging-sig-storage.
|
||||
|
||||
# This must be specified in seconds. If omitted, defaults to 600s (10 mins).
|
||||
# Building three images in external-snapshotter takes more than an hour.
|
||||
timeout: 7200s
|
||||
# This prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF,
|
||||
# or any new substitutions added in the future.
|
||||
options:
|
||||
substitution_option: ALLOW_LOOSE
|
||||
steps:
|
||||
# The image must contain bash and curl. Ideally it should also contain
|
||||
# the desired version of Go (currently defined in release-tools/prow.sh),
|
||||
# but that just speeds up the build and is not required.
|
||||
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20230623-56e06d7c18'
|
||||
entrypoint: ./.cloudbuild.sh
|
||||
env:
|
||||
- GIT_TAG=${_GIT_TAG}
|
||||
- PULL_BASE_REF=${_PULL_BASE_REF}
|
||||
- REGISTRY_NAME=gcr.io/${_STAGING_PROJECT}
|
||||
- HOME=/root
|
||||
substitutions:
|
||||
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
|
||||
# can be used as a substitution.
|
||||
_GIT_TAG: '12345'
|
||||
# _PULL_BASE_REF will contain the ref that was pushed to trigger this build -
|
||||
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
|
||||
_PULL_BASE_REF: 'master'
|
||||
# The default gcr.io staging project for Kubernetes-CSI
|
||||
# (=> https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL).
|
||||
# Might be overridden in the Prow build job for a repo which wants
|
||||
# images elsewhere.
|
||||
_STAGING_PROJECT: 'k8s-staging-sig-storage'
|
3
code-of-conduct.md
Normal file
3
code-of-conduct.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Kubernetes Community Code of Conduct
|
||||
|
||||
Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md)
|
170
contrib/get_supported_version_csi-sidecar.py
Normal file
170
contrib/get_supported_version_csi-sidecar.py
Normal file
@ -0,0 +1,170 @@
|
||||
# Copyright 2023 The Kubernetes 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 argparse
|
||||
import datetime
|
||||
import re
|
||||
from collections import defaultdict
|
||||
import subprocess
|
||||
import shutil
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
def check_gh_command():
|
||||
"""
|
||||
Pretty much everything is processed from `gh`
|
||||
Check that the `gh` command is in the path before anything else
|
||||
"""
|
||||
if not shutil.which('gh'):
|
||||
print("Error: The `gh` command is not available in the PATH.")
|
||||
print("Please install the GitHub CLI (https://cli.github.com/) and try again.")
|
||||
exit(1)
|
||||
|
||||
def duration_ago(dt):
|
||||
"""
|
||||
Humanize duration outputs
|
||||
"""
|
||||
delta = relativedelta(datetime.datetime.now(), dt)
|
||||
if delta.years > 0:
|
||||
return f"{delta.years} year{'s' if delta.years > 1 else ''} ago"
|
||||
elif delta.months > 0:
|
||||
return f"{delta.months} month{'s' if delta.months > 1 else ''} ago"
|
||||
elif delta.days > 0:
|
||||
return f"{delta.days} day{'s' if delta.days > 1 else ''} ago"
|
||||
elif delta.hours > 0:
|
||||
return f"{delta.hours} hour{'s' if delta.hours > 1 else ''} ago"
|
||||
elif delta.minutes > 0:
|
||||
return f"{delta.minutes} minute{'s' if delta.minutes > 1 else ''} ago"
|
||||
else:
|
||||
return "just now"
|
||||
|
||||
def parse_version(version):
|
||||
"""
|
||||
Parse version assuming it is in the form of v1.2.3
|
||||
"""
|
||||
pattern = r"v(\d+)\.(\d+)\.(\d+)"
|
||||
match = re.match(pattern, version)
|
||||
if match:
|
||||
major, minor, patch = map(int, match.groups())
|
||||
return (major, minor, patch)
|
||||
|
||||
def end_of_life_grouped_versions(versions):
|
||||
"""
|
||||
Calculate the end of life date for a minor release version according to : https://kubernetes-csi.github.io/docs/project-policies.html#support
|
||||
|
||||
The input is an array of tuples of:
|
||||
* grouped versions (e.g. 1.0, 1.1)
|
||||
* array of that contains all versions and their release date (e.g. 1.0.0, 01-01-2013)
|
||||
|
||||
versions structure example :
|
||||
[((3, 5), [('v3.5.0', datetime.datetime(2023, 4, 27, 22, 28, 6))]),
|
||||
((3, 4),
|
||||
[('v3.4.1', datetime.datetime(2023, 4, 5, 17, 41, 15)),
|
||||
('v3.4.0', datetime.datetime(2022, 12, 27, 23, 43, 41))])]
|
||||
"""
|
||||
supported_versions = []
|
||||
# Prepare dates for later calculation
|
||||
now = datetime.datetime.now()
|
||||
one_year = datetime.timedelta(days=365)
|
||||
three_months = datetime.timedelta(days=90)
|
||||
|
||||
# get the newer versions on top
|
||||
sorted_versions_list = sorted(versions.items(), key=lambda x: x[0], reverse=True)
|
||||
|
||||
# the latest version is always supported no matter the release date
|
||||
latest = sorted_versions_list.pop(0)
|
||||
supported_versions.append(latest[1][-1])
|
||||
|
||||
for v in sorted_versions_list:
|
||||
first_release = v[1][-1]
|
||||
last_release = v[1][0]
|
||||
# if the release is less than a year old we support the latest patch version
|
||||
if now - first_release[1] < one_year:
|
||||
supported_versions.append(last_release)
|
||||
# if the main release is older than a year and has a recent path, this is supported
|
||||
elif now - last_release[1] < three_months:
|
||||
supported_versions.append(last_release)
|
||||
return supported_versions
|
||||
|
||||
def get_release_docker_image(repo, version):
|
||||
"""
|
||||
Extract docker image name from the release page documentation
|
||||
"""
|
||||
output = subprocess.check_output(['gh', 'release', '-R', repo, 'view', version], text=True)
|
||||
#Extract matching image name excluding `
|
||||
match = re.search(r"docker pull ([\.\/\-\:\w\d]*)", output)
|
||||
docker_image = match.group(1) if match else ''
|
||||
return((version, docker_image))
|
||||
|
||||
def get_versions_from_releases(repo):
|
||||
"""
|
||||
Using `gh` cli get the github releases page details then
|
||||
create a list of grouped version on major.minor
|
||||
and for each give all major.minor.patch with release dates
|
||||
"""
|
||||
# Run the `gh release` command to get the release list
|
||||
output = subprocess.check_output(['gh', 'release', '-R', repo, 'list'], text=True)
|
||||
# Parse the output and group by major and minor version numbers
|
||||
versions = defaultdict(lambda: [])
|
||||
for line in output.strip().split('\n'):
|
||||
parts = line.split('\t')
|
||||
# pprint.pprint(parts)
|
||||
version = parts[0]
|
||||
parsed_version = parse_version(version)
|
||||
if parsed_version is None:
|
||||
continue
|
||||
major, minor, patch = parsed_version
|
||||
|
||||
published = datetime.datetime.strptime(parts[3], '%Y-%m-%dT%H:%M:%SZ')
|
||||
versions[(major, minor)].append((version, published))
|
||||
return(versions)
|
||||
|
||||
|
||||
def main():
|
||||
manual = """
|
||||
This script lists the supported versions Github releases according to https://kubernetes-csi.github.io/docs/project-policies.html#support
|
||||
It has been designed to help to update the tables from : https://kubernetes-csi.github.io/docs/sidecar-containers.html\n\n
|
||||
It can take multiple repos as argument, for all CSI sidecars details you can run:
|
||||
./get_supported_version_csi-sidecar.py -R kubernetes-csi/external-attacher -R kubernetes-csi/external-provisioner -R kubernetes-csi/external-resizer -R kubernetes-csi/external-snapshotter -R kubernetes-csi/livenessprobe -R kubernetes-csi/node-driver-registrar -R kubernetes-csi/external-health-monitor\n
|
||||
With the output you can then update the documentation manually.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=manual)
|
||||
parser.add_argument('--repo', '-R', required=True, action='append', dest='repos', help='The name of the repository in the format owner/repo.')
|
||||
parser.add_argument('--display', '-d', action='store_true', help='(default) Display EOL versions with their dates', default=True)
|
||||
parser.add_argument('--doc', '-D', action='store_true', help='Helper to https://kubernetes-csi.github.io/docs/ that prints Docker image for each EOL version')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Verify pre-reqs
|
||||
check_gh_command()
|
||||
|
||||
# Process all repos
|
||||
for repo in args.repos:
|
||||
versions = get_versions_from_releases(repo)
|
||||
eol_versions = end_of_life_grouped_versions(versions)
|
||||
|
||||
if args.display:
|
||||
print(f"Supported versions with release date and age of `{repo}`:\n")
|
||||
for version in eol_versions:
|
||||
print(f"{version[0]}\t{version[1].strftime('%Y-%m-%d')}\t{duration_ago(version[1])}")
|
||||
|
||||
# TODO : generate proper doc output for the tables of: https://kubernetes-csi.github.io/docs/sidecar-containers.html
|
||||
if args.doc:
|
||||
print("\nSupported Versions with docker images for each end of life version:\n")
|
||||
for version in eol_versions:
|
||||
_, image = get_release_docker_image(repo, version[0])
|
||||
print(f"{version[0]}\t{image}")
|
||||
print()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
149
filter-junit.go
Normal file
149
filter-junit.go
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This command filters a JUnit file such that only tests with a name
|
||||
matching a regular expression are passed through. By concatenating
|
||||
multiple input files it is possible to merge them into a single file.
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"flag"
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
output = flag.String("o", "-", "junit file to write, - for stdout")
|
||||
tests = flag.String("t", "", "regular expression matching the test names that are to be included in the output")
|
||||
)
|
||||
|
||||
/*
|
||||
* TestResults represents a JUnit file. Due to how encoding/xml works, we have
|
||||
* represent all fields that we want to be passed through. It's therefore
|
||||
* not a complete solution, but good enough for Ginkgo + Spyglass.
|
||||
*
|
||||
* Before Kubernetes 1.25 and ginkgo v2, we directly had <testsuite> in the
|
||||
* JUnit file. Now we get <testsuites> and inside it the <testsuite>.
|
||||
*/
|
||||
type TestResults struct {
|
||||
XMLName string `xml:"testsuites"`
|
||||
TestSuite TestSuite `xml:"testsuite"`
|
||||
}
|
||||
|
||||
type TestSuite struct {
|
||||
XMLName string `xml:"testsuite"`
|
||||
TestCases []TestCase `xml:"testcase"`
|
||||
}
|
||||
|
||||
type TestCase struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Time string `xml:"time,attr"`
|
||||
SystemOut string `xml:"system-out,omitempty"`
|
||||
SystemErr string `xml:"system-err,omitempty"`
|
||||
Failure string `xml:"failure,omitempty"`
|
||||
Skipped SkipReason `xml:"skipped,omitempty"`
|
||||
}
|
||||
|
||||
// SkipReason deals with the special <skipped></skipped>:
|
||||
// if present, we must re-encode it, even if empty.
|
||||
type SkipReason string
|
||||
|
||||
func (s *SkipReason) UnmarshalText(text []byte) error {
|
||||
*s = SkipReason(text)
|
||||
if *s == "" {
|
||||
*s = " "
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SkipReason) MarshalText() ([]byte, error) {
|
||||
if s == " " {
|
||||
return []byte{}, nil
|
||||
}
|
||||
return []byte(s), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var junit TestSuite
|
||||
var data []byte
|
||||
|
||||
flag.Parse()
|
||||
|
||||
re := regexp.MustCompile(*tests)
|
||||
|
||||
// Read all input files.
|
||||
for _, input := range flag.Args() {
|
||||
if input == "-" {
|
||||
if _, err := os.Stdin.Read(data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
data, err = os.ReadFile(input)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if err := xml.Unmarshal(data, &junit); err != nil {
|
||||
if err.Error() != "expected element type <testsuite> but have <testsuites>" {
|
||||
panic(err)
|
||||
}
|
||||
// Fall back to Ginkgo v2 format.
|
||||
var junitv2 TestResults
|
||||
if err := xml.Unmarshal(data, &junitv2); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
junit.TestCases = append(junit.TestCases, junitv2.TestSuite.TestCases...)
|
||||
}
|
||||
}
|
||||
|
||||
// Keep only matching testcases. Testcases skipped in all test runs are only stored once.
|
||||
filtered := map[string]TestCase{}
|
||||
for _, testcase := range junit.TestCases {
|
||||
if !re.MatchString(testcase.Name) {
|
||||
continue
|
||||
}
|
||||
entry, ok := filtered[testcase.Name]
|
||||
if !ok || // not present yet
|
||||
entry.Skipped != "" && testcase.Skipped == "" { // replaced skipped test with real test run
|
||||
filtered[testcase.Name] = testcase
|
||||
}
|
||||
}
|
||||
junit.TestCases = nil
|
||||
for _, testcase := range filtered {
|
||||
junit.TestCases = append(junit.TestCases, testcase)
|
||||
}
|
||||
|
||||
// Re-encode.
|
||||
data, err := xml.MarshalIndent(junit, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Write to output.
|
||||
if *output == "-" {
|
||||
if _, err := os.Stdout.Write(data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
if err := os.WriteFile(*output, data, 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
139
go-get-kubernetes.sh
Executable file
139
go-get-kubernetes.sh
Executable file
@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
# This script can be used while converting a repo from "dep" to "go mod"
|
||||
# by calling it after "go mod init" or to update the Kubernetes packages
|
||||
# in a repo that has already been converted. Only packages that are
|
||||
# part of kubernetes/kubernetes and thus part of a Kubernetes release
|
||||
# are modified. Other k8.io packages (like k8s.io/klog, k8s.io/utils)
|
||||
# need to be updated separately.
|
||||
|
||||
set -o pipefail
|
||||
|
||||
cmd=$0
|
||||
|
||||
function help () {
|
||||
cat <<EOF
|
||||
$cmd -p <kubernetes version = x.y.z>
|
||||
|
||||
Update all components from kubernetes/kubernetes to that version.
|
||||
|
||||
By default, replace statements are added for all Kubernetes packages,
|
||||
whether they are used or not. This is useful when preparing a
|
||||
repository for using k8s.io/kubernetes, because those replace
|
||||
statements are needed to avoid "unknown revision v0.0.0" errors
|
||||
(https://github.com/kubernetes/kubernetes/issues/79384).
|
||||
|
||||
With the optional -p flag, all unused replace statements are
|
||||
pruned. This makes go.mod smaller, but isn't required.
|
||||
|
||||
The replace statements are needed for "go get -u ./..." which
|
||||
otherwise ends up updating Kubernetes packages like client-go to
|
||||
incompatible versions (in that case, a very old 1.x release which
|
||||
happens to have a "higher" version number than the current
|
||||
0.<Kubernetes minor version>.<Kubernetes patch version> numbers.
|
||||
EOF
|
||||
}
|
||||
|
||||
prune=false
|
||||
|
||||
while getopts "ph" o; do
|
||||
case "$o" in
|
||||
h) help; exit 0;;
|
||||
p) prune=true;;
|
||||
*) help; exit 1;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
die () {
|
||||
echo >&2 "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
k8s="$1"
|
||||
|
||||
# If the repo imports k8s.io/kubernetes (directly or indirectly), then
|
||||
# "go mod" will try to find "v0.0.0" versions because
|
||||
# k8s.io/kubernetes has those in it's go.mod file
|
||||
# (https://github.com/kubernetes/kubernetes/blob/2bd9643cee5b3b3a5ecbd3af49d09018f0773c77/go.mod#L146-L157).
|
||||
# (https://github.com/kubernetes/kubernetes/issues/79384).
|
||||
#
|
||||
# We need to replicate the replace statements to override those fake
|
||||
# versions also in our go.mod file (idea and some code from
|
||||
# https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597).
|
||||
mods=$( (set -x; curl --silent --show-error --fail "https://raw.githubusercontent.com/kubernetes/kubernetes/v${k8s}/go.mod") |
|
||||
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
|
||||
) || die "failed to determine Kubernetes staging modules"
|
||||
for mod in $mods; do
|
||||
if $prune && ! (env GO111MODULE=on go mod graph) | grep "$mod@" > /dev/null; then
|
||||
echo "Kubernetes module $mod is not used, skipping"
|
||||
# Remove the module from go.mod "replace" that was added by an older version of this script.
|
||||
(set -x; env GO111MODULE=on go mod edit "-dropreplace=$mod") || die "'go mod edit' failed"
|
||||
continue
|
||||
fi
|
||||
# The presence of a potentially incomplete go.mod file affects this command,
|
||||
# so move elsewhere.
|
||||
modinfo=$(set -x; cd /; env GO111MODULE=on go mod download -json "$mod@kubernetes-${k8s}") ||
|
||||
die "failed to determine version of $mod: $modinfo"
|
||||
v=$(echo "$modinfo" | sed -n 's|.*"Version": "\(.*\)".*|\1|p')
|
||||
(set -x; env GO111MODULE=on go mod edit "-replace=$mod=$mod@$v") || die "'go mod edit' failed"
|
||||
done
|
||||
|
||||
packages=
|
||||
|
||||
# Beware that we have to work with packages, not modules (i.e. no -m
|
||||
# flag), because some modules trigger a "no Go code except tests"
|
||||
# error. Getting their packages works.
|
||||
if ! packages=$( (set -x; env GO111MODULE=on go list all) | grep ^k8s.io/ | sed -e 's; *;;'); then
|
||||
cat >&2 <<EOF
|
||||
|
||||
Warning: "GO111MODULE=on go list all" failed, trying individual packages instead.
|
||||
|
||||
EOF
|
||||
if ! packages=$( (set -x; env GO111MODULE=on go list -f '{{ join .Deps "\n" }}' ./...) | grep ^k8s.io/); then
|
||||
cat >&2 <<EOF
|
||||
|
||||
ERROR: could not obtain package list, both of these commands failed:
|
||||
GO111MODULE=on go list all
|
||||
GO111MODULE=on go list -f '{{ join .Deps "\n" }}' ./pkg/...
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
deps=
|
||||
for package in $packages; do
|
||||
# Some k8s.io packages do not come from Kubernetes staging and
|
||||
# thus have different versioning (or none at all...). We need to
|
||||
# skip those. We know what packages are from staging because we
|
||||
# now have "replace" statements for them in go.mod.
|
||||
#
|
||||
# shellcheck disable=SC2001
|
||||
module=$(echo "$package" | sed -e 's;k8s.io/\([^/]*\)/.*;k8s.io/\1;')
|
||||
if grep -q -w "$module *=>" go.mod; then
|
||||
deps="$deps $(echo "$package" | sed -e "s;\$;@kubernetes-$k8s;" -e 's;^k8s.io/kubernetes\(/.*\)@kubernetes-;k8s.io/kubernetes\1@v;')"
|
||||
fi
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
(set -x; env GO111MODULE=on go get $deps 2>&1) || die "go get failed"
|
||||
echo "SUCCESS"
|
32
pull-test.sh
Executable file
32
pull-test.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright 2021 The Kubernetes 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.
|
||||
|
||||
# This script is called by pull Prow jobs for the csi-release-tools
|
||||
# repo to ensure that the changes in the PR work when imported into
|
||||
# some other repo.
|
||||
|
||||
set -ex
|
||||
|
||||
# It must be called inside the updated csi-release-tools repo.
|
||||
CSI_RELEASE_TOOLS_DIR="$(pwd)"
|
||||
|
||||
# Update the other repo.
|
||||
cd "$PULL_TEST_REPO_DIR"
|
||||
git subtree pull --squash --prefix=release-tools "$CSI_RELEASE_TOOLS_DIR" master
|
||||
git log -n2
|
||||
|
||||
# Now fall through to testing.
|
||||
exec ./.prow.sh
|
23
update-vendor.sh
Executable file
23
update-vendor.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
if [ -f Gopkg.toml ]; then
|
||||
echo "Repo uses 'dep' for vendoring."
|
||||
(set -x; dep ensure)
|
||||
elif [ -f go.mod ]; then
|
||||
release-tools/verify-go-version.sh "go"
|
||||
(set -x; env GO111MODULE=on go mod tidy && env GO111MODULE=on go mod vendor)
|
||||
fi
|
148
util.sh
Executable file
148
util.sh
Executable file
@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2014 The Kubernetes 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.
|
||||
|
||||
function kube::util::sourced_variable {
|
||||
# Call this function to tell shellcheck that a variable is supposed to
|
||||
# be used from other calling context. This helps quiet an "unused
|
||||
# variable" warning from shellcheck and also document your code.
|
||||
true
|
||||
}
|
||||
|
||||
kube::util::sortable_date() {
|
||||
date "+%Y%m%d-%H%M%S"
|
||||
}
|
||||
|
||||
# arguments: target, item1, item2, item3, ...
|
||||
# returns 0 if target is in the given items, 1 otherwise.
|
||||
kube::util::array_contains() {
|
||||
local search="$1"
|
||||
local element
|
||||
shift
|
||||
for element; do
|
||||
if [[ "${element}" == "${search}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Example: kube::util::trap_add 'echo "in trap DEBUG"' DEBUG
|
||||
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
|
||||
kube::util::trap_add() {
|
||||
local trap_add_cmd
|
||||
trap_add_cmd=$1
|
||||
shift
|
||||
|
||||
for trap_add_name in "$@"; do
|
||||
local existing_cmd
|
||||
local new_cmd
|
||||
|
||||
# Grab the currently defined trap commands for this trap
|
||||
existing_cmd=$(trap -p "${trap_add_name}" | awk -F"'" '{print $2}')
|
||||
|
||||
if [[ -z "${existing_cmd}" ]]; then
|
||||
new_cmd="${trap_add_cmd}"
|
||||
else
|
||||
new_cmd="${trap_add_cmd};${existing_cmd}"
|
||||
fi
|
||||
|
||||
# Assign the test. Disable the shellcheck warning telling that trap
|
||||
# commands should be single quoted to avoid evaluating them at this
|
||||
# point instead evaluating them at run time. The logic of adding new
|
||||
# commands to a single trap requires them to be evaluated right away.
|
||||
# shellcheck disable=SC2064
|
||||
trap "${new_cmd}" "${trap_add_name}"
|
||||
done
|
||||
}
|
||||
|
||||
kube::util::download_file() {
|
||||
local -r url=$1
|
||||
local -r destination_file=$2
|
||||
|
||||
rm "${destination_file}" 2&> /dev/null || true
|
||||
|
||||
for i in $(seq 5)
|
||||
do
|
||||
if ! curl -fsSL --retry 3 --keepalive-time 2 "${url}" -o "${destination_file}"; then
|
||||
echo "Downloading ${url} failed. $((5-i)) retries left."
|
||||
sleep 1
|
||||
else
|
||||
echo "Downloading ${url} succeed"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Wait for background jobs to finish. Return with
|
||||
# an error status if any of the jobs failed.
|
||||
kube::util::wait-for-jobs() {
|
||||
local fail=0
|
||||
local job
|
||||
for job in $(jobs -p); do
|
||||
wait "${job}" || fail=$((fail + 1))
|
||||
done
|
||||
return ${fail}
|
||||
}
|
||||
|
||||
# kube::util::join <delim> <list...>
|
||||
# Concatenates the list elements with the delimiter passed as first parameter
|
||||
#
|
||||
# Ex: kube::util::join , a b c
|
||||
# -> a,b,c
|
||||
function kube::util::join {
|
||||
local IFS="$1"
|
||||
shift
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
# kube::util::check-file-in-alphabetical-order <file>
|
||||
# Check that the file is in alphabetical order
|
||||
#
|
||||
function kube::util::check-file-in-alphabetical-order {
|
||||
local failure_file="$1"
|
||||
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
|
||||
{
|
||||
echo
|
||||
echo "${failure_file} is not in alphabetical order. Please sort it:"
|
||||
echo
|
||||
echo " LC_ALL=C sort -o ${failure_file} ${failure_file}"
|
||||
echo
|
||||
} >&2
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
# Some useful colors.
|
||||
if [[ -z "${color_start-}" ]]; then
|
||||
declare -r color_start="\033["
|
||||
declare -r color_red="${color_start}0;31m"
|
||||
declare -r color_yellow="${color_start}0;33m"
|
||||
declare -r color_green="${color_start}0;32m"
|
||||
declare -r color_blue="${color_start}1;34m"
|
||||
declare -r color_cyan="${color_start}1;36m"
|
||||
declare -r color_norm="${color_start}0m"
|
||||
|
||||
kube::util::sourced_variable "${color_start}"
|
||||
kube::util::sourced_variable "${color_red}"
|
||||
kube::util::sourced_variable "${color_yellow}"
|
||||
kube::util::sourced_variable "${color_green}"
|
||||
kube::util::sourced_variable "${color_blue}"
|
||||
kube::util::sourced_variable "${color_cyan}"
|
||||
kube::util::sourced_variable "${color_norm}"
|
||||
fi
|
||||
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
54
verify-boilerplate.sh
Executable file
54
verify-boilerplate.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 The Kubernetes 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "Verifying boilerplate"
|
||||
|
||||
if [[ -z "$(command -v python)" ]]; then
|
||||
echo "Cannot find python. Make link to python3..."
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
|
||||
fi
|
||||
|
||||
# The csi-release-tools directory (absolute path).
|
||||
TOOLS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
|
||||
# Directory to check. Default is the parent of the tools themselves.
|
||||
ROOT="${1:-${TOOLS}/..}"
|
||||
|
||||
boiler="${TOOLS}/boilerplate/boilerplate.py"
|
||||
|
||||
mapfile -t files_need_boilerplate < <("${boiler}" --rootdir="${ROOT}" --verbose)
|
||||
|
||||
# Run boilerplate.py unit tests
|
||||
unitTestOut="$(mktemp)"
|
||||
trap cleanup EXIT
|
||||
cleanup() {
|
||||
rm "${unitTestOut}"
|
||||
}
|
||||
|
||||
# Run boilerplate check
|
||||
if [[ ${#files_need_boilerplate[@]} -gt 0 ]]; then
|
||||
for file in "${files_need_boilerplate[@]}"; do
|
||||
echo "Boilerplate header is wrong for: ${file}"
|
||||
done
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Done"
|
52
verify-go-version.sh
Executable file
52
verify-go-version.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
GO="$1"
|
||||
|
||||
if [ ! "$GO" ]; then
|
||||
echo >&2 "usage: $0 <path to go binary>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
die () {
|
||||
echo "ERROR: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
version=$("$GO" version) || die "determining version of $GO failed"
|
||||
# shellcheck disable=SC2001
|
||||
majorminor=$(echo "$version" | sed -e 's/.*go\([0-9]*\)\.\([0-9]*\).*/\1.\2/')
|
||||
# SC1091: Not following: release-tools/prow.sh was not specified as input (see shellcheck -x).
|
||||
# shellcheck disable=SC1091
|
||||
expected=$(. release-tools/prow.sh >/dev/null && echo "$CSI_PROW_GO_VERSION_BUILD")
|
||||
|
||||
if [ "$majorminor" != "$expected" ]; then
|
||||
cat >&2 <<EOF
|
||||
|
||||
======================================================
|
||||
WARNING
|
||||
|
||||
This projects is tested with Go v$expected.
|
||||
Your current Go version is v$majorminor.
|
||||
This may or may not be close enough.
|
||||
|
||||
In particular test-gofmt and test-vendor
|
||||
are known to be sensitive to the version of
|
||||
Go.
|
||||
======================================================
|
||||
|
||||
EOF
|
||||
fi
|
146
verify-shellcheck.sh
Executable file
146
verify-shellcheck.sh
Executable file
@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2018 The Kubernetes 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# The csi-release-tools directory.
|
||||
TOOLS="$(dirname "${BASH_SOURCE[0]}")"
|
||||
. "${TOOLS}/util.sh"
|
||||
|
||||
# Directory to check. Default is the parent of the tools themselves.
|
||||
ROOT="${1:-${TOOLS}/..}"
|
||||
|
||||
# required version for this script, if not installed on the host we will
|
||||
# use the official docker image instead. keep this in sync with SHELLCHECK_IMAGE
|
||||
SHELLCHECK_VERSION="0.6.0"
|
||||
# upstream shellcheck latest stable image as of January 10th, 2019
|
||||
SHELLCHECK_IMAGE="koalaman/shellcheck-alpine:v0.6.0@sha256:7d4d712a2686da99d37580b4e2f45eb658b74e4b01caf67c1099adc294b96b52"
|
||||
|
||||
# fixed name for the shellcheck docker container so we can reliably clean it up
|
||||
SHELLCHECK_CONTAINER="k8s-shellcheck"
|
||||
|
||||
# disabled lints
|
||||
disabled=(
|
||||
# this lint disallows non-constant source, which we use extensively without
|
||||
# any known bugs
|
||||
1090
|
||||
# this lint prefers command -v to which, they are not the same
|
||||
2230
|
||||
)
|
||||
# comma separate for passing to shellcheck
|
||||
join_by() {
|
||||
local IFS="$1";
|
||||
shift;
|
||||
echo "$*";
|
||||
}
|
||||
SHELLCHECK_DISABLED="$(join_by , "${disabled[@]}")"
|
||||
readonly SHELLCHECK_DISABLED
|
||||
|
||||
# creates the shellcheck container for later use
|
||||
create_container () {
|
||||
# TODO(bentheelder): this is a performance hack, we create the container with
|
||||
# a sleep MAX_INT32 so that it is effectively paused.
|
||||
# We then repeatedly exec to it to run each shellcheck, and later rm it when
|
||||
# we're done.
|
||||
# This is incredibly much faster than creating a container for each shellcheck
|
||||
# call ...
|
||||
docker run --name "${SHELLCHECK_CONTAINER}" -d --rm -v "${ROOT}:${ROOT}" -w "${ROOT}" --entrypoint="sleep" "${SHELLCHECK_IMAGE}" 2147483647
|
||||
}
|
||||
# removes the shellcheck container
|
||||
remove_container () {
|
||||
docker rm -f "${SHELLCHECK_CONTAINER}" &> /dev/null || true
|
||||
}
|
||||
|
||||
# ensure we're linting the source tree
|
||||
cd "${ROOT}"
|
||||
|
||||
# find all shell scripts excluding ./_*, ./.git/*, ./vendor*,
|
||||
# and anything git-ignored
|
||||
all_shell_scripts=()
|
||||
while IFS=$'\n' read -r script;
|
||||
do git check-ignore -q "$script" || all_shell_scripts+=("$script");
|
||||
done < <(find . -name "*.sh" \
|
||||
-not \( \
|
||||
-path ./_\* -o \
|
||||
-path ./.git\* -o \
|
||||
-path ./vendor\* \
|
||||
\))
|
||||
|
||||
# detect if the host machine has the required shellcheck version installed
|
||||
# if so, we will use that instead.
|
||||
HAVE_SHELLCHECK=false
|
||||
if command -v shellcheck &>/dev/null; then
|
||||
detected_version="$(shellcheck --version | grep 'version: .*')"
|
||||
if [[ "${detected_version}" = "version: ${SHELLCHECK_VERSION}" ]]; then
|
||||
HAVE_SHELLCHECK=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# tell the user which we've selected and possibly set up the container
|
||||
if ${HAVE_SHELLCHECK}; then
|
||||
echo "Using host shellcheck ${SHELLCHECK_VERSION} binary."
|
||||
else
|
||||
echo "Using shellcheck ${SHELLCHECK_VERSION} docker image."
|
||||
# remove any previous container, ensure we will attempt to cleanup on exit,
|
||||
# and create the container
|
||||
remove_container
|
||||
kube::util::trap_add 'remove_container' EXIT
|
||||
if ! output="$(create_container 2>&1)"; then
|
||||
{
|
||||
echo "Failed to create shellcheck container with output: "
|
||||
echo ""
|
||||
echo "${output}"
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# lint each script, tracking failures
|
||||
errors=()
|
||||
for f in "${all_shell_scripts[@]}"; do
|
||||
set +o errexit
|
||||
if ${HAVE_SHELLCHECK}; then
|
||||
failedLint=$(shellcheck --exclude="${SHELLCHECK_DISABLED}" "${f}")
|
||||
else
|
||||
failedLint=$(docker exec -t ${SHELLCHECK_CONTAINER} \
|
||||
shellcheck --exclude="${SHELLCHECK_DISABLED}" "${f}")
|
||||
fi
|
||||
set -o errexit
|
||||
if [[ -n "${failedLint}" ]]; then
|
||||
errors+=( "${failedLint}" )
|
||||
fi
|
||||
done
|
||||
|
||||
# Check to be sure all the packages that should pass lint are.
|
||||
if [ ${#errors[@]} -eq 0 ]; then
|
||||
echo 'Congratulations! All shell files are passing lint.'
|
||||
else
|
||||
{
|
||||
echo "Errors from shellcheck:"
|
||||
for err in "${errors[@]}"; do
|
||||
echo "$err"
|
||||
done
|
||||
echo
|
||||
echo 'Please review the above warnings. You can test via "./hack/verify-shellcheck"'
|
||||
echo 'If the above warnings do not make sense, you can exempt them from shellcheck'
|
||||
echo 'checking by adding the "shellcheck disable" directive'
|
||||
echo '(https://github.com/koalaman/shellcheck/wiki/Directive#disable).'
|
||||
echo
|
||||
} >&2
|
||||
false
|
||||
fi
|
59
verify-spelling.sh
Executable file
59
verify-spelling.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
TOOL_VERSION="v0.3.4"
|
||||
|
||||
# The csi-release-tools directory (absolute path).
|
||||
TOOLS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
|
||||
# Directory to check. Default is the parent of the tools themselves.
|
||||
ROOT="${1:-${TOOLS}/..}"
|
||||
|
||||
# create a temporary directory
|
||||
TMP_DIR=$(mktemp -d)
|
||||
|
||||
# cleanup
|
||||
exitHandler() (
|
||||
echo "Cleaning up..."
|
||||
rm -rf "${TMP_DIR}"
|
||||
)
|
||||
trap exitHandler EXIT
|
||||
|
||||
if [[ -z "$(command -v misspell)" ]]; then
|
||||
echo "Cannot find misspell. Installing misspell..."
|
||||
# perform go get in a temp dir as we are not tracking this version in a go module
|
||||
# if we do the go get in the repo, it will create / update a go.mod and go.sum
|
||||
cd "${TMP_DIR}"
|
||||
GO111MODULE=on GOBIN="${TMP_DIR}" go install "github.com/client9/misspell/cmd/misspell@${TOOL_VERSION}"
|
||||
export PATH="${TMP_DIR}:${PATH}"
|
||||
fi
|
||||
|
||||
# check spelling
|
||||
RES=0
|
||||
echo "Checking spelling..."
|
||||
ERROR_LOG="${TMP_DIR}/errors.log"
|
||||
cd "${ROOT}"
|
||||
git ls-files | grep -v vendor | xargs misspell > "${ERROR_LOG}"
|
||||
if [[ -s "${ERROR_LOG}" ]]; then
|
||||
sed 's/^/error: /' "${ERROR_LOG}" # add 'error' to each line to highlight in e2e status
|
||||
echo "Found spelling errors!"
|
||||
RES=1
|
||||
fi
|
||||
exit "${RES}"
|
41
verify-subtree.sh
Executable file
41
verify-subtree.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
# This script verifies that the content of a directory managed
|
||||
# by "git subtree" has not been modified locally. It does that
|
||||
# by looking for commits that modify the files with the
|
||||
# subtree prefix (aka directory) while ignoring merge
|
||||
# commits. Merge commits are where "git subtree" pulls the
|
||||
# upstream files into the directory.
|
||||
#
|
||||
# Theoretically a developer can subvert this check by modifying files
|
||||
# in a merge commit, but in practice that shouldn't happen.
|
||||
|
||||
DIR="$1"
|
||||
if [ ! "$DIR" ]; then
|
||||
echo "usage: $0 <directory>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REV=$(git log -n1 --remove-empty --format=format:%H --no-merges -- "$DIR")
|
||||
if [ "$REV" ]; then
|
||||
echo "Directory '$DIR' contains non-upstream changes:"
|
||||
echo
|
||||
git log --no-merges -- "$DIR"
|
||||
exit 1
|
||||
else
|
||||
echo "$DIR is a clean copy of upstream."
|
||||
fi
|
60
verify-vendor.sh
Executable file
60
verify-vendor.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Kubernetes 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.
|
||||
|
||||
if [ -f Gopkg.toml ]; then
|
||||
echo "Repo uses 'dep' for vendoring."
|
||||
case "$(dep version 2>/dev/null | grep 'version *:')" in
|
||||
*v0.[56789]*)
|
||||
if dep check; then
|
||||
echo "vendor up-to-date"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*) echo "skipping check, dep >= 0.5 required";;
|
||||
esac
|
||||
elif [ -f go.mod ]; then
|
||||
echo "Repo uses 'go mod'."
|
||||
# shellcheck disable=SC2235
|
||||
if [ "${JOB_NAME}" ] &&
|
||||
( [ "${JOB_TYPE}" != "presubmit" ] ||
|
||||
[ "$( (git diff "${PULL_BASE_SHA}..HEAD" -- go.mod go.sum vendor release-tools;
|
||||
git diff "${PULL_BASE_SHA}..HEAD" | grep -e '^@@.*@@ import (' -e '^[+-]import') |
|
||||
wc -l)" -eq 0 ] ); then
|
||||
echo "Skipping vendor check because the Prow pre-submit job does not affect dependencies."
|
||||
elif ! (set -x; env GO111MODULE=on go mod tidy); then
|
||||
echo "ERROR: vendor check failed."
|
||||
exit 1
|
||||
elif [ "$(git status --porcelain -- go.mod go.sum | wc -l)" -gt 0 ]; then
|
||||
echo "ERROR: go module files *not* up-to-date, they did get modified by 'GO111MODULE=on go mod tidy':";
|
||||
git diff -- go.mod go.sum
|
||||
exit 1
|
||||
elif [ -d vendor ]; then
|
||||
if ! (set -x; env GO111MODULE=on go mod vendor); then
|
||||
echo "ERROR: vendor check failed."
|
||||
exit 1
|
||||
elif [ "$(git status --porcelain -- vendor | wc -l)" -gt 0 ]; then
|
||||
echo "ERROR: vendor directory *not* up-to-date, it did get modified by 'GO111MODULE=on go mod vendor':"
|
||||
git status -- vendor
|
||||
git diff -- vendor
|
||||
exit 1
|
||||
else
|
||||
echo "Go dependencies and vendor directory up-to-date."
|
||||
fi
|
||||
else
|
||||
echo "Go dependencies up-to-date."
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user