Skip to content

Commit b505911

Browse files
committed
move-package script
1 parent 5aaa00b commit b505911

File tree

1 file changed

+113
-118
lines changed

1 file changed

+113
-118
lines changed

hack/move-api-packages.sh

+113-118
Original file line numberDiff line numberDiff line change
@@ -5,141 +5,136 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
55

66

77
function fixup_imports() {
8-
echo "Moving $1 to $2..."
8+
echo "rewriting imports $1/$2 to github.com/openshift/api/$2..."
99
startingPath=${OS_ROOT}/pkg/$1/api
1010
endingPath=${OS_ROOT}/pkg/$1/apis/$2
11-
startingPackagePrefix="github.com/openshift/origin/pkg/$1/api"
11+
startingPackage="github.com/openshift/origin/pkg/$1/$2"
12+
endingPackage="github.com/openshift/api/$2"
1213
set +e
1314

14-
files=$(find . -path ./tools -prune -name "*generated*" -prune -o -type f -name "*.go" -print0 | xargs -0 grep " \"${startingPackagePrefix}\"" -l)
15-
echo $files | xargs sed -i "s| \"${startingPackagePrefix}\"| $1api \"${startingPackagePrefix}\"|g"
16-
echo $files | xargs sed -i "s|api\.|$1api\.|g"
17-
echo $files | xargs sed -i "s|k$1api\.|kapi\.|g"
18-
echo $files | xargs sed -i "s|o$1api\.|oapi\.|g"
19-
echo $files | xargs sed -i "s|s2i$1api\.|s2iapi\.|g"
20-
echo $files | xargs sed -i "s|authorization$1api\.|authorizationapi\.|g"
21-
echo $files | xargs sed -i "s|build$1api\.|buildapi\.|g"
22-
echo $files | xargs sed -i "s|deploy$1api\.|deployapi\.|g"
23-
echo $files | xargs sed -i "s|image$1api\.|imageapi\.|g"
24-
echo $files | xargs sed -i "s|oauth$1api\.|oauthapi\.|g"
25-
echo $files | xargs sed -i "s|project$1api\.|projectapi\.|g"
26-
echo $files | xargs sed -i "s|quota$1api\.|quotaapi\.|g"
27-
echo $files | xargs sed -i "s|route$1api\.|routeapi\.|g"
28-
echo $files | xargs sed -i "s|sdn$1api\.|sdnapi\.|g"
29-
echo $files | xargs sed -i "s|security$1api\.|securityapi\.|g"
30-
echo $files | xargs sed -i "s|template$1api\.|templateapi\.|g"
31-
echo $files | xargs sed -i "s|user$1api\.|userapi\.|g"
32-
echo $files | xargs sed -i "s|auth$1api\.|authapi\.|g"
33-
echo $files | xargs sed -i "s|config$1api\.|configapi\.|g"
34-
echo $files | xargs sed -i "s|clientcmd$1api\.|clientcmdapi\.|g"
35-
echo $files | xargs sed -i "s|server$1api\.|serverapi\.|g"
36-
echo $files | xargs sed -i "s|meta$1api\.|metaapi\.|g"
37-
echo $files | xargs sed -i "s|kapi$1api\.|kapi\.|g"
38-
echo $files | xargs sed -i "s|meta$1apiv1\.|metaapiv1\.|g"
39-
echo $files | xargs sed -i "s|kapi$1apiv1\.|kapiv1\.|g"
40-
files=$(find . -path ./tools -prune -name "*generated*" -prune -o -type f -name "*.go" -print0 | xargs -0 grep " \"${startingPackagePrefix}/v1\"" -l)
41-
echo $files | xargs sed -i "s| \"${startingPackagePrefix}/v1\"| $1apiv1 \"${startingPackagePrefix}/v1\"|g"
42-
echo $files | xargs sed -i "s|v1\.|$1apiv1\.|g"
43-
echo $files | xargs sed -i "s|meta$1apiv1\.|metav1\.|g"
44-
echo $files | xargs sed -i "s|kapi$1apiv1\.|kapiv1\.|g"
45-
echo $files | xargs sed -i "s|k$1apiv1\.|kv1\.|g"
15+
# echo "find . -path ./tools -prune -name \"*generated*\" -prune -o -type f -name \"*.go\" -print0 | xargs -0 grep \" \\\"${startingPackage}\\\"\" -l"
16+
# find . -path ./tools -prune -name "*generated*" -prune -o -type f -name "*.go" -print0 | xargs -0 grep "\"${startingPackage}\"" -l
17+
files=$(find . -path ./tools -prune -name "*generated*" -prune -o -type f -name "*.go" -print0 | xargs -0 grep "\"${startingPackage}\"" -l)
18+
# echo $files
19+
echo $files | xargs sed -i "s|\"${startingPackage}\"|\"${endingPackage}\"|g"
20+
# echo $files | xargs sed -i "s|api\.|$1api\.|g"
21+
# echo $files | xargs sed -i "s|k$1api\.|kapi\.|g"
22+
# echo $files | xargs sed -i "s|o$1api\.|oapi\.|g"
23+
# echo $files | xargs sed -i "s|s2i$1api\.|s2iapi\.|g"
24+
# echo $files | xargs sed -i "s|authorization$1api\.|authorizationapi\.|g"
25+
# echo $files | xargs sed -i "s|build$1api\.|buildapi\.|g"
26+
# echo $files | xargs sed -i "s|deploy$1api\.|deployapi\.|g"
27+
# echo $files | xargs sed -i "s|image$1api\.|imageapi\.|g"
28+
# echo $files | xargs sed -i "s|oauth$1api\.|oauthapi\.|g"
29+
# echo $files | xargs sed -i "s|project$1api\.|projectapi\.|g"
30+
# echo $files | xargs sed -i "s|quota$1api\.|quotaapi\.|g"
31+
# echo $files | xargs sed -i "s|route$1api\.|routeapi\.|g"
32+
# echo $files | xargs sed -i "s|sdn$1api\.|sdnapi\.|g"
33+
# echo $files | xargs sed -i "s|security$1api\.|securityapi\.|g"
34+
# echo $files | xargs sed -i "s|template$1api\.|templateapi\.|g"
35+
# echo $files | xargs sed -i "s|user$1api\.|userapi\.|g"
36+
# echo $files | xargs sed -i "s|auth$1api\.|authapi\.|g"
37+
# echo $files | xargs sed -i "s|config$1api\.|configapi\.|g"
38+
# echo $files | xargs sed -i "s|clientcmd$1api\.|clientcmdapi\.|g"
39+
# echo $files | xargs sed -i "s|server$1api\.|serverapi\.|g"
40+
# echo $files | xargs sed -i "s|meta$1api\.|metaapi\.|g"
41+
# echo $files | xargs sed -i "s|kapi$1api\.|kapi\.|g"
42+
# echo $files | xargs sed -i "s|meta$1apiv1\.|metaapiv1\.|g"
43+
# echo $files | xargs sed -i "s|kapi$1apiv1\.|kapiv1\.|g"
44+
# files=$(find . -path ./tools -prune -name "*generated*" -prune -o -type f -name "*.go" -print0 | xargs -0 grep " \"${startingPackagePrefix}/v1\"" -l)
45+
# echo $files | xargs sed -i "s| \"${startingPackagePrefix}/v1\"| $1apiv1 \"${startingPackagePrefix}/v1\"|g"
46+
# echo $files | xargs sed -i "s|v1\.|$1apiv1\.|g"
47+
# echo $files | xargs sed -i "s|meta$1apiv1\.|metav1\.|g"
48+
# echo $files | xargs sed -i "s|kapi$1apiv1\.|kapiv1\.|g"
49+
# echo $files | xargs sed -i "s|k$1apiv1\.|kv1\.|g"
4650

4751
set -e
4852
}
4953

50-
function move() {
51-
echo "Moving $1 to $2..."
52-
startingPath=${OS_ROOT}/pkg/$1/api
53-
endingPath=${OS_ROOT}/pkg/$1/apis/$2
54-
startingPackagePrefix="github.com/openshift/origin/pkg/$1/api"
55-
endingPackagePrefix="github.com/openshift/origin/pkg/$1/apis/$2"
56-
57-
mkdir -p ${endingPath}
58-
mv ${startingPath}/* ${endingPath}
59-
find ${endingPath} -maxdepth 1 -name "*.go" | xargs sed -i "s|package api|package $2|g"
60-
find ${endingPath} -maxdepth 1 -name "*.go" | xargs sed -i "s|Convert_api_|Convert_$2_|g"
61-
find ${endingPath} -maxdepth 1 -name "*.go" | xargs sed -i "s|_To_api_|_To_$2_|g"
62-
find ${endingPath} -maxdepth 1 -name "*.go" | xargs sed -i "s|autoConvert_api_|autoConvert_$2_|g"
63-
find ${endingPath}/v1 -maxdepth 1 -name "*.go" | xargs sed -i "s|Convert_api_|Convert_$2_|g"
64-
find ${endingPath}/v1 -maxdepth 1 -name "*.go" | xargs sed -i "s|_To_api_|_To_$2_|g"
65-
find ${endingPath}/v1 -maxdepth 1 -name "*.go" | xargs sed -i "s|autoConvert_api_|autoConvert_$2_|g"
66-
67-
find ${OS_ROOT} -path ./vendor -prune -o -path ./cmd/service-catalog -prune -o -path ./cmd/cluster-capacity -prune -o -name "*.go" -print0 | xargs -0 sed -i "s|${startingPackagePrefix}|${endingPackagePrefix}|g"
68-
# find ${OS_ROOT} -path ./vendor -prune -o -path ./cmd/service-catalog -prune -o -path ./cmd/cluster-capacity -prune -o -name "*.sh" -print0 | xargs -0 sed -i "s|${startingPackagePrefix}|${endingPackagePrefix}|g"
54+
function remove() {
55+
echo "Removing $1/v1/types.go ..."
56+
rm pkg/$1/types.go
6957
}
7058

71-
fixup_imports authorization authorization
72-
fixup_imports build build
73-
fixup_imports deploy apps
74-
fixup_imports image image
75-
fixup_imports oauth oauth
76-
fixup_imports project project
77-
fixup_imports quota quota
78-
fixup_imports route route
79-
fixup_imports sdn network
80-
fixup_imports security security
81-
fixup_imports template template
82-
fixup_imports user user
83-
84-
move authorization authorization
85-
move build build
86-
move deploy apps
87-
move image image
88-
move oauth oauth
89-
move project project
90-
move quota quota
91-
move route route
92-
move sdn network
93-
move security security
94-
move template template
95-
move user user
59+
fixup_imports apps/apis apps/v1
60+
fixup_imports authorization/apis authorization/v1
61+
fixup_imports build/apis build/v1
62+
fixup_imports image/apis image/docker10
63+
fixup_imports image/apis image/dockerpre012
64+
fixup_imports image/apis image/v1
65+
fixup_imports network/apis network/v1
66+
fixup_imports oauth/apis oauth/v1
67+
fixup_imports project/apis project/v1
68+
fixup_imports quota/apis quota/v1
69+
fixup_imports route/apis route/v1
70+
fixup_imports security/apis security/v1
71+
fixup_imports template/apis template/v1
72+
fixup_imports user/apis user/v1
73+
74+
75+
remove apps/apis/apps/v1
76+
remove authorization/apis/authorization/v1
77+
remove build/apis/build/v1
78+
remove image/apis/image/v1
79+
remove network/apis/network/v1
80+
remove oauth/apis/oauth/v1
81+
remove project/apis/project/v1
82+
remove quota/apis/quota/v1
83+
remove route/apis/route/v1
84+
remove security/apis/security/v1
85+
remove template/apis/template/v1
86+
remove user/apis/user/v1
87+
88+
rm pkg/image/apis/image/docker10/dockertypes.go
89+
rm pkg/image/apis/image/dockerpre012/dockertypes.go
90+
9691

9792
# one offs
98-
sed -i "s|DeepCopy_api_PolicyRule|DeepCopy_authorization_PolicyRule|g" pkg/authorization/authorizer/scope/converter.go
99-
sed -i "s|Convert_v1_ResourceQuotaStatus_To_quota_ResourceQuotaStatus|Convert_v1_ResourceQuotaStatus_To_api_ResourceQuotaStatus|g" pkg/quota/apis/quota/v1/conversion.go
100-
sed -i "s|Convert_quota_ResourceQuotaStatus_To_v1_ResourceQuotaStatus|Convert_api_ResourceQuotaStatus_To_v1_ResourceQuotaStatus|g" pkg/quota/apis/quota/v1/conversion.go
101-
sed -i '13d' pkg/project/apis/project/validation/validation.go
102-
sed -i '18d' pkg/diagnostics/networkpod/util/util.go
103-
sed -i '23d' pkg/project/registry/project/proxy/proxy.go
104-
sed -i '16d' pkg/dockerregistry/testutil/fakeopenshift.go
105-
sed -i "s|authorizationapi.Convert_api_ClusterRole_To_rbac_ClusterRole|authorizationapi.Convert_authorization_ClusterRole_To_rbac_ClusterRole|g" pkg/authorization/controller/authorizationsync/normalize.go
106-
sed -i "s|authorizationapi.Convert_api_ClusterRoleBinding_To_rbac_ClusterRoleBinding|authorizationapi.Convert_authorization_ClusterRoleBinding_To_rbac_ClusterRoleBinding|g" pkg/authorization/controller/authorizationsync/normalize.go
107-
sed -i "s|authorizationapi.Convert_api_Role_To_rbac_Role|authorizationapi.Convert_authorization_Role_To_rbac_Role|g" pkg/authorization/controller/authorizationsync/normalize.go
108-
sed -i "s|authorizationapi.Convert_api_RoleBinding_To_rbac_RoleBinding|authorizationapi.Convert_authorization_RoleBinding_To_rbac_RoleBinding|g" pkg/authorization/controller/authorizationsync/normalize.go
109-
sed -i "s|_api_Route|_route_Route|g" pkg/api/install/install.go
110-
sed -i "s|_api_Build|_build_Build|g" pkg/api/install/install.go
111-
sed -i "s|_api_OAuth|_oauth_OAuth|g" pkg/api/install/install.go
112-
sed -i "s|_api_Project|_project_Project|g" pkg/api/install/install.go
113-
sed -i "s|_api_Template|_template_Template|g" pkg/api/install/install.go
114-
sed -i "s|_api_BrokerTemplateInstance|_template_BrokerTemplateInstance|g" pkg/api/install/install.go
115-
sed -i "s|_api_DeploymentConfig|_apps_DeploymentConfig|g" pkg/api/install/install.go
116-
sed -i "s|_api_Image|_image_Image|g" pkg/api/install/install.go
117-
sed -i "s|_api_ClusterPolic|_authorization_ClusterPolic|g" pkg/api/install/install.go
118-
sed -i "s|_api_Polic|_authorization_Polic|g" pkg/api/install/install.go
119-
sed -i "s|_api_ClusterRole|_authorization_ClusterRole|g" pkg/api/install/install.go
120-
sed -i "s|_api_Role|_authorization_Role|g" pkg/api/install/install.go
121-
sed -i "s|_api_IsPersonalSubjectAccessRevie|_authorization_IsPersonalSubjectAccessRevie|g" pkg/api/install/install.go
122-
sed -i "s|_api_User|_user_User|g" pkg/api/install/install.go
123-
sed -i "s|_api_Identity|_user_Identity|g" pkg/api/install/install.go
124-
sed -i "s|_api_Group|_user_Group|g" pkg/api/install/install.go
125-
126-
127-
hack/update-generated-conversions.sh
128-
hack/update-generated-deep-copies.sh
129-
hack/update-generated-defaulters.sh
130-
hack/update-generated-clientsets.sh
131-
hack/update-generated-informers.sh
132-
hack/update-generated-listers.sh
133-
OS_BUILD_ENV_PRESERVE=api:docs:pkg ./hack/env hack/update-generated-protobuf.sh
134-
hack/update-generated-openapi.sh
93+
#sed -i "s|DeepCopy_api_PolicyRule|DeepCopy_authorization_PolicyRule|g" pkg/authorization/authorizer/scope/converter.go
94+
#sed -i "s|Convert_v1_ResourceQuotaStatus_To_quota_ResourceQuotaStatus|Convert_v1_ResourceQuotaStatus_To_api_ResourceQuotaStatus|g" pkg/quota/apis/quota/v1/conversion.go
95+
#sed -i "s|Convert_quota_ResourceQuotaStatus_To_v1_ResourceQuotaStatus|Convert_api_ResourceQuotaStatus_To_v1_ResourceQuotaStatus|g" pkg/quota/apis/quota/v1/conversion.go
96+
#sed -i '13d' pkg/project/apis/project/validation/validation.go
97+
#sed -i '18d' pkg/diagnostics/networkpod/util/util.go
98+
#sed -i '23d' pkg/project/registry/project/proxy/proxy.go
99+
#sed -i '16d' pkg/dockerregistry/testutil/fakeopenshift.go
100+
#sed -i "s|authorizationapi.Convert_api_ClusterRole_To_rbac_ClusterRole|authorizationapi.Convert_authorization_ClusterRole_To_rbac_ClusterRole|g" pkg/authorization/controller/authorizationsync/normalize.go
101+
#sed -i "s|authorizationapi.Convert_api_ClusterRoleBinding_To_rbac_ClusterRoleBinding|authorizationapi.Convert_authorization_ClusterRoleBinding_To_rbac_ClusterRoleBinding|g" pkg/authorization/controller/authorizationsync/normalize.go
102+
#sed -i "s|authorizationapi.Convert_api_Role_To_rbac_Role|authorizationapi.Convert_authorization_Role_To_rbac_Role|g" pkg/authorization/controller/authorizationsync/normalize.go
103+
#sed -i "s|authorizationapi.Convert_api_RoleBinding_To_rbac_RoleBinding|authorizationapi.Convert_authorization_RoleBinding_To_rbac_RoleBinding|g" pkg/authorization/controller/authorizationsync/normalize.go
104+
#sed -i "s|_api_Route|_route_Route|g" pkg/api/install/install.go
105+
#sed -i "s|_api_Build|_build_Build|g" pkg/api/install/install.go
106+
#sed -i "s|_api_OAuth|_oauth_OAuth|g" pkg/api/install/install.go
107+
#sed -i "s|_api_Project|_project_Project|g" pkg/api/install/install.go
108+
#sed -i "s|_api_Template|_template_Template|g" pkg/api/install/install.go
109+
#sed -i "s|_api_BrokerTemplateInstance|_template_BrokerTemplateInstance|g" pkg/api/install/install.go
110+
#sed -i "s|_api_DeploymentConfig|_apps_DeploymentConfig|g" pkg/api/install/install.go
111+
#sed -i "s|_api_Image|_image_Image|g" pkg/api/install/install.go
112+
#sed -i "s|_api_ClusterPolic|_authorization_ClusterPolic|g" pkg/api/install/install.go
113+
#sed -i "s|_api_Polic|_authorization_Polic|g" pkg/api/install/install.go
114+
#sed -i "s|_api_ClusterRole|_authorization_ClusterRole|g" pkg/api/install/install.go
115+
#sed -i "s|_api_Role|_authorization_Role|g" pkg/api/install/install.go
116+
#sed -i "s|_api_IsPersonalSubjectAccessRevie|_authorization_IsPersonalSubjectAccessRevie|g" pkg/api/install/install.go
117+
#sed -i "s|_api_User|_user_User|g" pkg/api/install/install.go
118+
#sed -i "s|_api_Identity|_user_Identity|g" pkg/api/install/install.go
119+
#sed -i "s|_api_Group|_user_Group|g" pkg/api/install/install.go
120+
121+
122+
#hack/update-generated-conversions.sh
123+
#hack/update-generated-deep-copies.sh
124+
#hack/update-generated-defaulters.sh
125+
#hack/update-generated-clientsets.sh
126+
#hack/update-generated-informers.sh
127+
#hack/update-generated-listers.sh
128+
#OS_BUILD_ENV_PRESERVE=api:docs:pkg ./hack/env hack/update-generated-protobuf.sh
129+
#hack/update-generated-openapi.sh
135130

136131
set +e
137132
hack/verify-gofmt.sh | xargs -n 1 gofmt -s -w
138133
set -e
139134

140-
nice make
135+
#nice make
141136

142137

143138
# remove the old to avoid extra files.
144-
rm -rf api/protobuf-spec
145-
hack/update-generated-swagger-spec.sh
139+
#rm -rf api/protobuf-spec
140+
#hack/update-generated-swagger-spec.sh

0 commit comments

Comments
 (0)