Skip to content

Commit

Permalink
Integrate GOPATH hacks to codegen anywhere (#59)
Browse files Browse the repository at this point in the history
* Integrate GOPATH hacks to codegen anywhere

* Run hack/update-codegen.sh
  • Loading branch information
antoineco authored Dec 3, 2020
1 parent 93be700 commit 4fa31da
Show file tree
Hide file tree
Showing 738 changed files with 14 additions and 191,328 deletions.
File renamed without changes.
11 changes: 2 additions & 9 deletions hack/tools.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// +build tools

/*
Copyright 2020 The Knative Authors.
Copyright 2020 The Knative 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
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,
Expand All @@ -21,11 +21,4 @@ package tools
import (
_ "knative.dev/hack"
_ "knative.dev/pkg/hack"

// Test images from eventing
_ "knative.dev/eventing/test/test_images/event-sender"
_ "knative.dev/eventing/test/test_images/heartbeats"
_ "knative.dev/eventing/test/test_images/performance"
_ "knative.dev/eventing/test/test_images/print"
_ "knative.dev/eventing/test/test_images/recordevents"
)
36 changes: 12 additions & 24 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Copyright 2018 The Knative Authors
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,45 +18,33 @@ set -o errexit
set -o nounset
set -o pipefail

export GO111MODULE=on
source $(dirname $0)/../vendor/knative.dev/hack/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=

if [ -z "${GOPATH:-}" ]; then
export GOPATH=$(go env GOPATH)
fi

source $(dirname $0)/../vendor/knative.dev/hack/library.sh

CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/k8s.io/code-generator 2>/dev/null || echo ../../../k8s.io/code-generator)}
echo "=== Update Codegen for $MODULE_NAME"

KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)}

chmod +x ${CODEGEN_PKG}/generate-groups.sh
chmod +x ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh

# Sources and Bindings
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,client,informer,lister" \
"knative.dev/eventing-gitlab/pkg/client" "knative.dev/eventing-gitlab/pkg/apis" \
knative.dev/eventing-gitlab/pkg/client knative.dev/eventing-gitlab/pkg/apis \
"sources:v1alpha1 bindings:v1alpha1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate.go.txt
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

group "Knative Codegen"

# Knative Injection
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
"knative.dev/eventing-gitlab/pkg/client" "knative.dev/eventing-gitlab/pkg/apis" \
knative.dev/eventing-gitlab/pkg/client knative.dev/eventing-gitlab/pkg/apis \
"sources:v1alpha1 bindings:v1alpha1" \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate.go.txt
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt

# Depends on generate-groups.sh to install bin/deepcopy-gen
${GOPATH}/bin/deepcopy-gen \
-O zz_generated.deepcopy \
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate.go.txt \
-i knative.dev/eventing-gitlab/pkg/apis
group "Update deps post-codegen"

# Make sure our dependencies are up-to-date
${REPO_ROOT_DIR}/hack/update-deps.sh
11 changes: 0 additions & 11 deletions vendor/cloud.google.com/go/.gitignore

This file was deleted.

Loading

0 comments on commit 4fa31da

Please sign in to comment.