diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index 52fc28d96..df19898bf 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -12,6 +12,7 @@ - Rook-Operator no longer creates the resources CRD's or TPR's at the runtime. Instead, those resources are provisioned during deployment via `helm` or `kubectl`. - The 'rook' image is now based on the ceph-container project's 'daemon-base' image so that Rook no longer has to manage installs of Ceph in image. +- Rook CRD code generation is now working with BSD (Mac) and GNU sed. ## Breaking Changes diff --git a/build/codegen/codegen.sh b/build/codegen/codegen.sh index 874108f63..6169d9ea4 100755 --- a/build/codegen/codegen.sh +++ b/build/codegen/codegen.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -# Copyright 2016 The Rook Authors. All rights reserved. +# Copyright 2018 The Rook Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,9 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# shellcheck disable=SC2086,SC2089,SC2090 +# Disables quote checks, which is needed because of the SED variable here. + scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd ${scriptdir}/../../vendor/k8s.io/code-generator && ./generate-groups.sh \ +cd "${scriptdir}/../../vendor/k8s.io/code-generator" && ./generate-groups.sh \ all \ github.com/rook/rook/pkg/client \ github.com/rook/rook/pkg/apis \ @@ -24,9 +27,18 @@ cd ${scriptdir}/../../vendor/k8s.io/code-generator && ./generate-groups.sh \ # this seems busted in the release-1.8 branch # --go-header-file ${SCRIPT_ROOT}/build/codegen/header.txt +SED="sed -i.bak" + # workaround https://github.com/openshift/origin/issues/10357 -find ${scriptdir}/../../pkg/client -name "clientset_generated.go" -exec sed -i '' 's/fakePtr := testing.Fake{}/cs := \&Clientset{}/g' {} + -find ${scriptdir}/../../pkg/client -name "clientset_generated.go" -exec sed -i '' 's/fakePtr.AddReactor/cs.Fake.AddReactor/g' {} + -find ${scriptdir}/../../pkg/client -name "clientset_generated.go" -exec sed -i '' 's/fakePtr.AddWatchReactor/cs.Fake.AddWatchReactor/g' {} + -find ${scriptdir}/../../pkg/client -name "clientset_generated.go" -exec sed -i '' 's/return &Clientset{fakePtr, \&fakediscovery.FakeDiscovery{Fake: &fakePtr}}/cs.discovery = \&fakediscovery.FakeDiscovery{Fake: \&cs.Fake}\ +find "${scriptdir}/../../pkg/client" -name "clientset_generated.go" -exec \ + $SED 's/fakePtr := testing.Fake\([{]\)}/cs := \&Clientset\1}/g' {} + +find "${scriptdir}/../../pkg/client" -name "clientset_generated.go" -exec \ + $SED 's/fakePtr.AddReactor/cs.Fake.AddReactor/g' {} + +find "${scriptdir}/../../pkg/client" -name "clientset_generated.go" -exec \ + $SED 's/fakePtr.AddWatchReactor/cs.Fake.AddWatchReactor/g' {} + +# shellcheck disable=SC1004 +# Disables backslash+linefeed is literal check. +find "${scriptdir}/../../pkg/client" -name "clientset_generated.go" -exec \ + $SED 's/return \&Clientset{fakePtr, \&fakediscovery.FakeDiscovery{Fake: \&fakePtr}}/cs.discovery = \&fakediscovery.FakeDiscovery{Fake: \&cs.Fake}\ return cs/g' {} + +find "${scriptdir}/../../pkg/client" -name "clientset_generated.go.bak" -delete diff --git a/build/codegen/header.txt b/build/codegen/header.txt index dbc310344..e8ae8ec8f 100644 --- a/build/codegen/header.txt +++ b/build/codegen/header.txt @@ -1,5 +1,5 @@ /* -Copyright 2017 The Rook Authors. All rights reserved. +Copyright 2018 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.