-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to synchronize schemes that have been removed
Signed-off-by: Shiming Zhang <[email protected]>
- Loading branch information
Showing
5 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
auger | ||
build | ||
vendor | ||
_tmp | ||
|
||
# IDEs | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright 2024 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. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/etcd-io/auger/pkg/scheme" | ||
oldscheme "github.com/etcd-io/auger/pkg/old/scheme" | ||
) | ||
|
||
func init() { | ||
oldscheme.AddToScheme(scheme.Scheme) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 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 -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
ROOT_DIR="$(realpath "${DIR}/..")" | ||
|
||
function clone_or_checkout() { | ||
local repo=https://github.com/kubernetes/api | ||
local version=$1 | ||
local dest=$2 | ||
|
||
if [[ -d "${dest}" ]]; then | ||
echo "Checking out ${repo}#${version} to ${dest}" | ||
pushd "${dest}" | ||
git fetch origin | ||
git checkout "${version}" | ||
popd | ||
else | ||
echo "Cloning ${repo}#${version} to ${dest}" | ||
git clone --branch "${version}" --depth 1 "${repo}" "${dest}" | ||
fi | ||
} | ||
|
||
function find_package() { | ||
local dir=$1 | ||
find "${dir}" | grep register.go | sed "s#/register.go##g" | sed "s#${dir}/##g" || : | ||
} | ||
|
||
apiset=() | ||
|
||
function append_api() { | ||
local api=$1 | ||
if [[ ! " ${apiset[@]} " =~ " ${api} " ]]; then | ||
apiset+=("${api}") | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
|
||
function clone_api() { | ||
local release=$1 | ||
local skip=$2 | ||
version="release-1.${release}" | ||
version_dir="${ROOT_DIR}/_tmp/k8s-api/${version}" | ||
clone_or_checkout "${version}" "${version_dir}" | ||
for api in $(find_package "${version_dir}"); do | ||
if append_api "${api}" ; then | ||
if [[ "${release}" -eq "${skip}" ]]; then | ||
continue | ||
fi | ||
dir_api="${ROOT_DIR}/pkg/old/apis/${api}" | ||
echo "Copying ${version_dir}/${api}/*.go to ${dir_api}" | ||
mkdir -p "${dir_api}" | ||
cp "${version_dir}/${api}"/*.go "${dir_api}" | ||
echo "# k8s.io/api/${api} | ||
Copying from release 1.${release} | ||
Generated by ./hack/clone_old_apis.sh | ||
" > "${dir_api}/README.md" | ||
fi | ||
done | ||
} | ||
|
||
last_release=${1} | ||
|
||
for release in $(seq ${last_release} -1 9); do | ||
clone_api "${release}" "${last_release}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 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 -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
ROOT_DIR="$(realpath "${DIR}/..")" | ||
|
||
function find_package() { | ||
local dir=$1 | ||
find "${dir}" | grep register.go | sed "s#/register.go##g" | sed "s#${dir}/##g" || : | ||
} | ||
|
||
function gen() { | ||
cat <<EOF | ||
/* | ||
Copyright 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. | ||
*/ | ||
package scheme | ||
// Don't edit this file directly. It is generated by gen_old_scheme.sh. | ||
import ( | ||
EOF | ||
|
||
for pkg in $(find_package "${ROOT_DIR}/pkg/old/apis"); do | ||
echo "github.com/etcd-io/auger/pkg/old/apis/${pkg}" | awk -F '/' '{print " "$7$8, "\""$1"\/"$2"\/"$3"\/"$4"\/"$5"\/"$6"\/"$7"\/"$8"\""}' | ||
done | ||
|
||
cat <<EOF | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
// AddToScheme adds all types of this clientset into the given scheme. | ||
func AddToScheme(scheme *runtime.Scheme) { | ||
EOF | ||
|
||
for pkg in $(find_package "${ROOT_DIR}/pkg/old/apis"); do | ||
echo "${pkg}" | awk -F '/' '{print " _ = " $1$2"\.AddToScheme(scheme)"}' | ||
done | ||
|
||
cat <<EOF | ||
} | ||
EOF | ||
} | ||
|
||
gen |