Update hack scripts to use new docker workflow.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-08-06 19:30:18 -05:00
parent c5d5914866
commit 7143058462
8 changed files with 170 additions and 82 deletions

View File

@ -4,7 +4,7 @@ set -euo pipefail
root_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
function tidy_cmd() {
echo 'go mod tidy'
echo 'go mod tidy -v'
}
function lint_cmd() {

View File

@ -1,5 +1,8 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
go test -race ./...
( cd pkg/client && go test -race ./... )
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
"$ROOT/hack/module.sh" test

29
hack/update-codegen.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
BASE_PKG="github.com/suzerain-io/placeholder-name"
CODEGEN_IMAGE=${CODEGEN_IMAGE:-gcr.io/tanzu-user-authentication/k8s-code-generator-1.19:latest}
function codegen() {
PKG="$1"
shift 1
docker run --rm -v "$ROOT:/go/src/$BASE_PKG" -w "/go/src/$BASE_PKG/$PKG" "${CODEGEN_IMAGE}" "$@" 2>&1 | sed "s|^|$1 ($PKG) > |"
}
codegen kubernetes/1.19/api generate-groups deepcopy,defaulter \
$BASE_PKG/kubernetes/1.19/api/generated \
$BASE_PKG/kubernetes/1.19/api/apis \
"placeholder:v1alpha1 crdsplaceholder:v1alpha1"
codegen kubernetes/1.19/api generate-internal-groups deepcopy,defaulter,conversion,openapi \
$BASE_PKG/kubernetes/1.19/api/generated \
$BASE_PKG/kubernetes/1.19/api/apis \
$BASE_PKG/kubernetes/1.19/api/apis \
"placeholder:v1alpha1 crdsplaceholder:v1alpha1"
codegen kubernetes/1.19/client-go generate-groups client,lister,informer \
$BASE_PKG/kubernetes/1.19/client-go \
$BASE_PKG/kubernetes/1.19/api/apis \
"placeholder:v1alpha1 crdsplaceholder:v1alpha1"

View File

@ -1,5 +1,9 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
go mod tidy
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix --timeout=10m
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
"$ROOT/hack/module.sh" tidy
"$ROOT/hack/update-codegen.sh"

46
hack/verify-codegen.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Copyright 2017 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 -euo pipefail
ROOT=$(dirname "${BASH_SOURCE[0]}")/..
DIFFROOT="${ROOT}/kubernetes"
TMP_DIFFROOT="${ROOT}/_tmp/kubernetes"
_tmp="${ROOT}/_tmp"
cleanup() {
rm -rf "${_tmp}"
}
trap "cleanup" EXIT SIGINT
cleanup
mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
"${ROOT}/hack/update-codegen.sh"
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]
then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
exit 1
fi

View File

@ -1,5 +1,9 @@
#!/usr/bin/env bash
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")"
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --modules-download-mode=readonly --timeout=10m
"$ROOT/hack/module.sh" lint
"$ROOT/hack/verify-codegen.sh"

View File

@ -19,16 +19,16 @@ import (
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return map[string]common.OpenAPIDefinition{
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfig": schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfig(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfigList": schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigList(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfigSpec": schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigSpec(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequest": schema_pkg_apis_placeholder_v1alpha1_LoginRequest(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestCredential": schema_pkg_apis_placeholder_v1alpha1_LoginRequestCredential(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestList": schema_pkg_apis_placeholder_v1alpha1_LoginRequestList(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestSpec": schema_pkg_apis_placeholder_v1alpha1_LoginRequestSpec(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestStatus": schema_pkg_apis_placeholder_v1alpha1_LoginRequestStatus(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestTokenCredential": schema_pkg_apis_placeholder_v1alpha1_LoginRequestTokenCredential(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.User": schema_pkg_apis_placeholder_v1alpha1_User(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfig": schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfig(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfigList": schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigList(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/crdsplaceholder/v1alpha1.LoginDiscoveryConfigSpec": schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigSpec(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequest": schema_api_apis_placeholder_v1alpha1_LoginRequest(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestCredential": schema_api_apis_placeholder_v1alpha1_LoginRequestCredential(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestList": schema_api_apis_placeholder_v1alpha1_LoginRequestList(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestSpec": schema_api_apis_placeholder_v1alpha1_LoginRequestSpec(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestStatus": schema_api_apis_placeholder_v1alpha1_LoginRequestStatus(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.LoginRequestTokenCredential": schema_api_apis_placeholder_v1alpha1_LoginRequestTokenCredential(ref),
"github.com/suzerain-io/placeholder-name/kubernetes/1.19/api/apis/placeholder/v1alpha1.User": schema_api_apis_placeholder_v1alpha1_User(ref),
"k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup": schema_pkg_apis_meta_v1_APIGroup(ref),
"k8s.io/apimachinery/pkg/apis/meta/v1.APIGroupList": schema_pkg_apis_meta_v1_APIGroupList(ref),
"k8s.io/apimachinery/pkg/apis/meta/v1.APIResource": schema_pkg_apis_meta_v1_APIResource(ref),
@ -84,7 +84,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
}
}
func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -123,7 +123,7 @@ func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfig(ref common.Re
}
}
func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigList(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -169,7 +169,7 @@ func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigList(ref commo
}
}
func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -195,7 +195,7 @@ func schema_pkg_apis_crdsplaceholder_v1alpha1_LoginDiscoveryConfigSpec(ref commo
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -238,7 +238,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequest(ref common.ReferenceCallb
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequestCredential(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequestCredential(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -279,7 +279,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequestCredential(ref common.Refe
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -326,7 +326,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequestList(ref common.ReferenceC
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -353,7 +353,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequestSpec(ref common.ReferenceC
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequestStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -386,7 +386,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequestStatus(ref common.Referenc
}
}
func schema_pkg_apis_placeholder_v1alpha1_LoginRequestTokenCredential(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_LoginRequestTokenCredential(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
@ -405,7 +405,7 @@ func schema_pkg_apis_placeholder_v1alpha1_LoginRequestTokenCredential(ref common
}
}
func schema_pkg_apis_placeholder_v1alpha1_User(ref common.ReferenceCallback) common.OpenAPIDefinition {
func schema_api_apis_placeholder_v1alpha1_User(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{

View File

@ -120,6 +120,7 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -147,6 +148,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8=
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=