Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informers and listers for the advanced usages #642

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ release:

.PHONY: generate
generate:
hack/generate-client.sh
hack/update-codegen.sh
hack/generate-fakes.sh
hack/generate-copyright.sh

Expand Down
16 changes: 16 additions & 0 deletions hack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Assorted scripts for development

This directory contains several scripts useful in the development process of Shipwright Build.

- `build-logs.sh` Collect the log of specific BuildRun Pod in the cluster.
- `generate-copyright.sh` Generate the Shipwright Copyright header for all required files.
- `generate-fakes.sh` Use Go counterfeiter to generate fakes.
- `install-counterfeiter.sh` Install the Go counterfeiter.
- `install-kind.sh` Install the latest verified Kubernetes cluster by KinD.
- `install-kubectl.sh` Install the kubectl command line.
- `install-operator-sdk.sh` Install the verified oeprator-sdk command line.
- `install-registry.sh` Install the local container registry in the KinD cluster.
- `install-tekton.sh` Install the latest verified Tekton Pipeline release.
- `release.sh` Creates a new release of Shipwright Build.
- `update-codegen.sh` Updates auto-generated client libraries.
- `verify-codegen.sh` Verifies that auto-generated client libraries are up-to-date.
6 changes: 3 additions & 3 deletions hack/generate-client.sh → hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ echo "The code-generator package is imported via the pkg/kubecodegen dir"
echo "To modify the current version, please modify this in the go.mod"
echo ""

GOFLAGS="" GOPATH=${GOPATH} /bin/bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client" \
github.com/shipwright-io/build/pkg/client/build \
GOFLAGS="" GOPATH=${GOPATH} /bin/bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/shipwright-io/build/pkg/client \
github.com/shipwright-io/build/pkg/apis \
build:v1alpha1 \
"build:v1alpha1" \
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
47 changes: 47 additions & 0 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Copyright The Shipwright Contributors
#
# SPDX-License-Identifier: Apache-2.0

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
readonly REPO_ROOT_DIR
readonly TMP_DIFFROOT="$(mktemp -d ${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX)"

cleanup() {
rm -rf "${TMP_DIFFROOT}"
}

trap "cleanup" EXIT SIGINT

cleanup

# Save working tree state
mkdir -p "${TMP_DIFFROOT}/pkg"
cp -aR "${REPO_ROOT_DIR}/pkg" "${TMP_DIFFROOT}"

mkdir -p "${TMP_DIFFROOT}/vendor"
cp -aR "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}"

"${REPO_ROOT_DIR}/hack/update-codegen.sh"
echo "Diffing ${REPO_ROOT_DIR} against freshly generated codegen"
ret=0
diff -Naupr "${REPO_ROOT_DIR}/pkg" "${TMP_DIFFROOT}/pkg" || ret=1
diff -Naupr "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}/vendor" || ret=1

# Restore working tree state
rm -fr "${REPO_ROOT_DIR}/pkg"
rm -fr "${REPO_ROOT_DIR}/vendor"
cp -aR "${TMP_DIFFROOT}"/* "${REPO_ROOT_DIR}"

if [[ $ret -eq 0 ]]
then
echo "${REPO_ROOT_DIR} up to date."
else
echo "${REPO_ROOT_DIR} is out of date. Please run hack/update-codegen.sh"
exit 1
fi
10 changes: 10 additions & 0 deletions pkg/apis/build/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ var (
// AddToScheme is used in the generated kube code
AddToScheme = SchemeBuilder.AddToScheme
)

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading