Skip to content

Commit

Permalink
Use client-pkg code
Browse files Browse the repository at this point in the history
  • Loading branch information
cardil committed Apr 16, 2024
1 parent 6ebd9ab commit e1ac74f
Show file tree
Hide file tree
Showing 369 changed files with 9,475 additions and 3,308 deletions.
2 changes: 0 additions & 2 deletions .codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ ignore:
- "hack"
- "pkg/client"
- "test"
- "third_party"
- "vendor"
4 changes: 2 additions & 2 deletions cmd/kn/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"github.com/spf13/cobra"
"gotest.tools/v3/assert"

"knative.dev/client/lib/test"
"knative.dev/client-pkg/pkg/util"
"knative.dev/client-pkg/pkg/util/test"
"knative.dev/client/pkg/kn/config"
"knative.dev/client/pkg/kn/root"
"knative.dev/client/pkg/util"
)

func TestValidatePlugin(t *testing.T) {
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module knative.dev/client

go 1.21

// TODO: remove when https://github.com/knative/client-pkg/pull/177 is merged
//replace knative.dev/client-pkg => github.com/cardil/knative-client-pkg v0.0.0-20240416095801-87f6a5d7889a

replace knative.dev/client-pkg => ../knative-client-pkg

require (
github.com/google/go-cmp v0.6.0
github.com/hashicorp/golang-lru v1.0.2 // indirect
Expand All @@ -15,7 +20,7 @@ require (
golang.org/x/term v0.18.0
gotest.tools/v3 v3.3.0
k8s.io/api v0.29.2
k8s.io/apiextensions-apiserver v0.29.2
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/apimachinery v0.29.2
k8s.io/cli-runtime v0.29.2
k8s.io/client-go v0.29.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,6 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec h1:gG8AzUJDHrYONInTv0wm1gSPzWp3n8tooewl+yGpe/I=
knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec/go.mod h1:PYodo1bmKTrxnNCfLJa6a8wdg3QQH0XTOPlZJwrY64A=
knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba h1:uX9UsYNHJQDpqVSMVijhSljmCSLZm5ocPdQJ4jrkyig=
knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba/go.mod h1:19sfPiy4dK2jBIHgszOTk43qOvfCXz1GTIncRY3trB8=
knative.dev/hack v0.0.0-20240327150553-47368d631660 h1:tW6NgyjMnSXBS75+k+Xh5uNiLhJ9TFswS9hrkC3OQOc=
Expand Down
19 changes: 10 additions & 9 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ source_lint() {
go_build() {
echo "🚧 Compile"
# Env var exported by hack/build-flags.sh
go build -mod=vendor -ldflags "${KN_BUILD_LD_FLAGS:-}" -o kn ./cmd/...
go build -ldflags "${KN_BUILD_LD_FLAGS:-}" -o kn ./cmd/...

if file kn | grep -q -i "Windows"; then
mv kn kn.exe
Expand Down Expand Up @@ -287,19 +287,19 @@ cross_build() {

export CGO_ENABLED=0
echo " 🐧 kn-linux-amd64"
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/... || failed=1
GOOS=linux GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/... || failed=1
echo " 💪 kn-linux-arm64"
GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-arm64 ./cmd/... || failed=1
GOOS=linux GOARCH=arm64 go build -ldflags "${ld_flags}" -o ./kn-linux-arm64 ./cmd/... || failed=1
echo " 🍏 kn-darwin-amd64"
GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-darwin-amd64 ./cmd/... || failed=1
GOOS=darwin GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-darwin-amd64 ./cmd/... || failed=1
echo " 🍎 kn-darwin-arm64"
GOOS=darwin GOARCH=arm64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-darwin-arm64 ./cmd/... || failed=1
GOOS=darwin GOARCH=arm64 go build -ldflags "${ld_flags}" -o ./kn-darwin-arm64 ./cmd/... || failed=1
echo " 🎠 kn-windows-amd64.exe"
GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-windows-amd64.exe ./cmd/... || failed=1
GOOS=windows GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-windows-amd64.exe ./cmd/... || failed=1
echo " Z kn-linux-s390x"
GOOS=linux GOARCH=s390x go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-s390x ./cmd/... || failed=1
GOOS=linux GOARCH=s390x go build -ldflags "${ld_flags}" -o ./kn-linux-s390x ./cmd/... || failed=1
echo " P kn-linux-ppc64le"
GOOS=linux GOARCH=ppc64le go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-ppc64le ./cmd/... || failed=1
GOOS=linux GOARCH=ppc64le go build -ldflags "${ld_flags}" -o ./kn-linux-ppc64le ./cmd/... || failed=1

return ${failed}
}
Expand Down Expand Up @@ -368,7 +368,8 @@ if has_flag --debug; then
fi

# Shared funcs from hack repo
source "$(basedir)"/vendor/knative.dev/hack/library.sh
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script library.sh)"

# Shared funcs with CI
while IFS= read -r -d '' file; do
Expand Down
17 changes: 9 additions & 8 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# Documentation about this script and how to use it can be found
# at https://github.com/knative/hack

source $(dirname $0)/../vendor/knative.dev/hack/release.sh
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script release.sh)"

function build_release() {
# Env var exported by hack/build-flags.sh
Expand All @@ -26,19 +27,19 @@ function build_release() {

export CGO_ENABLED=0
echo "🚧 🐧 Building for Linux (amd64)"
GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/...
GOOS=linux GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-linux-amd64 ./cmd/...
echo "🚧 💪 Building for Linux (arm64)"
GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-arm64 ./cmd/...
GOOS=linux GOARCH=arm64 go build -ldflags "${ld_flags}" -o ./kn-linux-arm64 ./cmd/...
echo "🚧 🍏 Building for macOS"
GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-darwin-amd64 ./cmd/...
GOOS=darwin GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-darwin-amd64 ./cmd/...
echo "🚧 🍎 Building for macOS (arm64)"
GOOS=darwin GOARCH=arm64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-darwin-arm64 ./cmd/...
GOOS=darwin GOARCH=arm64 go build -ldflags "${ld_flags}" -o ./kn-darwin-arm64 ./cmd/...
echo "🚧 🎠 Building for Windows"
GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-windows-amd64.exe ./cmd/...
GOOS=windows GOARCH=amd64 go build -ldflags "${ld_flags}" -o ./kn-windows-amd64.exe ./cmd/...
echo "🚧 Z Building for Linux(s390x)"
GOOS=linux GOARCH=s390x go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-s390x ./cmd/...
GOOS=linux GOARCH=s390x go build -ldflags "${ld_flags}" -o ./kn-linux-s390x ./cmd/...
echo "🚧 P Building for Linux (ppc64le)"
GOOS=linux GOARCH=ppc64le go build -mod=vendor -ldflags "${ld_flags}" -o ./kn-linux-ppc64le ./cmd/...
GOOS=linux GOARCH=ppc64le go build -ldflags "${ld_flags}" -o ./kn-linux-ppc64le ./cmd/...
echo "🚧 🐳 Building the container image"

# Handle latest default tag in `ko` to be present only for latest releases.
Expand Down
2 changes: 1 addition & 1 deletion hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package tools

// This package imports things required by this repository, to force `go mod` to see them as dependencies
import (
_ "knative.dev/hack"
_ "knative.dev/hack/cmd/script"
_ "knative.dev/pkg/hack"

_ "k8s.io/code-generator"
Expand Down
24 changes: 3 additions & 21 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

source $(dirname $0)/../vendor/knative.dev/hack/codegen-library.sh
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script codegen-library.sh)"

# If we run with -mod=vendor here, then generate-groups.sh looks for vendor files in the wrong place.
export GOFLAGS=-mod=

echo "=== Update Codegen for $MODULE_NAME"

group "Kubernetes Codegen"

# generate the code with:
# --output-base because this script should also be able to run inside the vendor dir of
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
"${CODEGEN_PKG}"/generate-groups.sh "deepcopy" \
knative.dev/client/pkg/apis/client/v1alpha1/generated knative.dev/client/pkg/apis \
client:v1alpha1 \
--go-header-file "${REPO_ROOT_DIR}"/hack/boilerplate.go.txt

group "Update deps post-codegen"

# Make sure our dependencies are up-to-date
${REPO_ROOT_DIR}/hack/update-deps.sh
echo "=== Noop codegen for $MODULE_NAME"
3 changes: 2 additions & 1 deletion hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

source $(dirname $0)/../vendor/knative.dev/hack/library.sh
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script library.sh)"

go_update_deps "$@"
3 changes: 2 additions & 1 deletion hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set -o errexit
set -o nounset
set -o pipefail

source $(dirname $0)/../vendor/knative.dev/hack/library.sh
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script library.sh)"

"${REPO_ROOT_DIR}"/hack/build.sh --codegen
if output="$(git status --porcelain)" && [ -z "$output" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lib/printing/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package printing
import (
"fmt"

"knative.dev/client/pkg/printers"
"knative.dev/client-pkg/pkg/printers"
duckv1 "knative.dev/pkg/apis/duck/v1"
)

Expand Down
52 changes: 0 additions & 52 deletions pkg/dynamic/client_mock_test.go

This file was deleted.

Loading

0 comments on commit e1ac74f

Please sign in to comment.