mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
Replace hard-code input-dirs with automatic file scan mechanism
This commit is contained in:
27
hack/lib/generator-help.sh
Normal file
27
hack/lib/generator-help.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Utility command based on 'find' command. The pipeline is as following:
|
||||||
|
# 1. find all the go files; (exclude specific path: vendor etc)
|
||||||
|
# 2. find all the files containing specific tags in contents;
|
||||||
|
# 3. extract related dirs;
|
||||||
|
# 4. remove duplicated paths;
|
||||||
|
# 5. replace . with ${PRJ_PREFIX}
|
||||||
|
# 6. merge all dirs in array with delimiter ,;
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# find_dirs_containing_comment_tags("+k8s:")
|
||||||
|
# Return:
|
||||||
|
# sigs.k8s.io/descheduler/a,sigs.k8s.io/descheduler/b,sigs.k8s.io/descheduler/c
|
||||||
|
function find_dirs_containing_comment_tags() {
|
||||||
|
array=()
|
||||||
|
while IFS='' read -r line; do array+=("$line"); done < <( \
|
||||||
|
find . -type f -name \*.go -not -path "./vendor/*" -print0 \
|
||||||
|
| xargs -0 grep --color=never -l "$@" \
|
||||||
|
| xargs -n1 dirname \
|
||||||
|
| LC_ALL=C sort -u \
|
||||||
|
| sed "s|.|${PRJ_PREFIX}|" \
|
||||||
|
)
|
||||||
|
|
||||||
|
IFS=",";
|
||||||
|
printf '%s' "${array[*]}";
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
|
||||||
|
source "$(dirname "${BASH_SOURCE}")/lib/generator-help.sh"
|
||||||
|
|
||||||
go build -o "${OS_OUTPUT_BINPATH}/deepcopy-gen" "k8s.io/code-generator/cmd/deepcopy-gen"
|
go build -o "${OS_OUTPUT_BINPATH}/deepcopy-gen" "k8s.io/code-generator/cmd/deepcopy-gen"
|
||||||
|
|
||||||
${OS_OUTPUT_BINPATH}/deepcopy-gen \
|
${OS_OUTPUT_BINPATH}/deepcopy-gen \
|
||||||
--go-header-file "hack/boilerplate/boilerplate.go.txt" \
|
--go-header-file "hack/boilerplate/boilerplate.go.txt" \
|
||||||
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig,${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api,${PRJ_PREFIX}/pkg/api/v1alpha1,${PRJ_PREFIX}/pkg/framework/plugins/defaultevictor/,${PRJ_PREFIX}/pkg/framework/plugins/removefailedpods,${PRJ_PREFIX}/pkg/framework/plugins/nodeutilization,${PRJ_PREFIX}/pkg/framework/plugins/podlifetime,${PRJ_PREFIX}/pkg/framework/plugins/removeduplicates,${PRJ_PREFIX}/pkg/framework/plugins/removepodshavingtoomanyrestarts,${PRJ_PREFIX}/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity,${PRJ_PREFIX}/pkg/framework/plugins/removepodsviolatingnodeaffinity,${PRJ_PREFIX}/pkg/framework/plugins/removepodsviolatingnodetaints,${PRJ_PREFIX}/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint" \
|
--input-dirs "$(find_dirs_containing_comment_tags "+k8s:deepcopy-gen=")" \
|
||||||
--output-file-base zz_generated.deepcopy
|
--output-file-base zz_generated.deepcopy
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user