Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
4850314a
Commit
4850314a
authored
Oct 26, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add script to check for updates to the files for generation
parent
37122c26
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
8 deletions
+144
-8
init.sh
hack/lib/init.sh
+4
-1
verify-api-groups.sh
hack/verify-api-groups.sh
+127
-0
register.go
pkg/apis/abac/register.go
+4
-2
register.go
pkg/apis/abac/v0/register.go
+4
-2
register.go
pkg/apis/abac/v1beta1/register.go
+5
-3
No files found.
hack/lib/init.sh
View file @
4850314a
...
@@ -66,7 +66,10 @@ storage.k8s.io/v1beta1\
...
@@ -66,7 +66,10 @@ storage.k8s.io/v1beta1\
# not all group versions are exposed by the server. This list contains those
# not all group versions are exposed by the server. This list contains those
# which are not available so we don't generate clients or swagger for them
# which are not available so we don't generate clients or swagger for them
KUBE_NONSERVER_GROUP_VERSIONS
=
"
KUBE_NONSERVER_GROUP_VERSIONS
=
"
imagepolicy.k8s.io/v1alpha1
abac.authorization.kubernetes.io/v0
\
abac.authorization.kubernetes.io/v1beta1
\
componentconfig/v1alpha1
\
imagepolicy.k8s.io/v1alpha1
\
"
"
# This emulates "readlink -f" which is not available on MacOS X.
# This emulates "readlink -f" which is not available on MacOS X.
...
...
hack/verify-api-groups.sh
0 → 100755
View file @
4850314a
#!/bin/bash
# Copyright 2016 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.
# locate all API groups by their packages and versions
set
-o
errexit
set
-o
nounset
set
-o
pipefail
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/..
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
prefix
=
"
${
KUBE_ROOT
%
"k8s.io/kubernetes"
}
"
register_files
=()
while
IFS
=
read
-d
$'
\0
'
-r
file
;
do
register_files+
=(
"
${
file
}
"
)
done
< <
(
find
"
${
KUBE_ROOT
}
"
/pkg/apis
-name
register.go
-print0
)
# every register file should contain a GroupName. Gather the different representations.
# 1. group directory name for go2idl client gen
# 2. external group versions for init.sh all APIs list
# 3. install packages for inclusion in import_known_versions files
group_dirnames
=()
external_group_versions
=()
expected_install_packages
=()
for
register_file
in
"
${
register_files
[@]
}
"
;
do
package
=
"
${
register_file
#
"
${
prefix
}
"
}
"
package
=
"
${
package
%
"/register.go"
}
"
group_dirname
=
"
${
package
#
"k8s.io/kubernetes/pkg/apis/"
}
"
group_dirname
=
"
${
group_dirname
%%
"/*"
}
"
group_name
=
""
if
grep
-q
'GroupName = "'
"
${
register_file
}
"
;
then
group_name
=
$(
grep
-q
'GroupName = "'
"
${
register_file
}
"
|
cut
-d
\"
-f2
-
)
else
echo
"
${
register_file
}
is missing
\"
const GroupName =
\"
"
exit
1
fi
# does the dirname doesn't have a slash, then it's the internal package.
# if does have one, then its an external
if
[[
"
${
group_dirname
#*
'/'
}
"
==
"
${
group_dirname
}
"
]]
;
then
group_dirnames+
=(
"
${
group_dirname
}
"
)
expected_install_packages+
=(
"
${
package
}
"
)
else
version
=
$(
echo
"
${
group_dirname
}
"
|
cut
-d
/
-f2
-
)
external_group_versions+
=(
"
${
group_name
}
/
${
version
}
"
)
fi
done
# check to make sure that client gen is getting
# groups_without_codegen is the list of group we EXPECT to not have the client generated for
# them. This happens for types that aren't served from the API server
groups_without_codegen
=(
"abac"
"componentconfig"
"imagepolicy"
)
client_gen_file
=
"
${
KUBE_ROOT
}
/cmd/libs/go2idl/client-gen/main.go"
for
group_dirname
in
"
${
group_dirnames
[@]
}
"
;
do
if
!
grep
-q
"
${
group_dirname
}
/"
"
${
client_gen_file
}
"
;
then
found
=
0
for
group_without_codegen
in
"
${
groups_without_codegen
[@]
}
"
;
do
if
[[
"
${
group_without_codegen
}
"
==
"
${
group_dirname
}
"
]]
;
then
found
=
1
fi
done
if
[
"
${
found
}
"
-ne
"1"
]
;
then
echo
"need to add
${
group_dirname
}
/ to
${
client_gen_file
}
"
exit
1
fi
fi
done
# import_known_versions checks to be sure we'll get installed
# groups_without_codegen is the list of group we EXPECT to not have the client generated for
# them. This happens for types that aren't served from the API server
packages_without_install
=(
"k8s.io/kubernetes/pkg/apis/abac"
)
known_version_files
=(
"pkg/master/import_known_versions.go"
"pkg/client/clientset_generated/internal_clientset/import_known_versions.go"
)
for
expected_install_package
in
"
${
expected_install_packages
[@]
}
"
;
do
found
=
0
for
package_without_install
in
"
${
packages_without_install
[@]
}
"
;
do
if
[
"
${
package_without_install
}
"
==
"
${
expected_install_package
}
"
]
;
then
found
=
1
fi
done
if
[[
"
${
found
}
"
-eq
"1"
]]
;
then
continue
fi
for
known_version_file
in
"
${
known_version_files
[@]
}
"
;
do
if
!
grep
-q
"
${
expected_install_package
}
/install"
${
known_version_files
}
;
then
echo
"missing
${
expected_install_package
}
/install from
${
known_version_files
}
"
exit
1
fi
done
done
# check all groupversions to make sure they're in the init.sh file. This isn't perfect, but its slightly
# better than nothing
for
external_group_version
in
"
${
external_group_versions
[@]
}
"
;
do
if
!
grep
-q
"
${
external_group_version
}
"
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
;
then
echo
"missing
${
external_group_version
}
from hack/lib/init.sh:/KUBE_AVAILABLE_GROUP_VERSIONS or hack/init.sh:/KUBE_NONSERVER_GROUP_VERSIONS"
exit
1
fi
done
\ No newline at end of file
pkg/apis/abac/register.go
View file @
4850314a
...
@@ -23,7 +23,9 @@ import (
...
@@ -23,7 +23,9 @@ import (
)
)
// Group is the API group for abac
// Group is the API group for abac
const
Group
=
"abac.authorization.kubernetes.io"
const
GroupName
=
"abac.authorization.kubernetes.io"
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
GroupName
,
Version
:
runtime
.
APIVersionInternal
}
// Scheme is the default instance of runtime.Scheme to which types in the abac API group are registered.
// Scheme is the default instance of runtime.Scheme to which types in the abac API group are registered.
// TODO: remove this, abac should not have its own scheme.
// TODO: remove this, abac should not have its own scheme.
...
@@ -43,7 +45,7 @@ var (
...
@@ -43,7 +45,7 @@ var (
)
)
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
unversioned
.
GroupVersion
{
Group
:
Group
,
Version
:
runtime
.
APIVersionInternal
}
,
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
Policy
{},
&
Policy
{},
)
)
return
nil
return
nil
...
...
pkg/apis/abac/v0/register.go
View file @
4850314a
...
@@ -22,8 +22,10 @@ import (
...
@@ -22,8 +22,10 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
)
)
const
GroupName
=
"abac.authorization.kubernetes.io"
// GroupVersion is the API group and version for abac v0
// GroupVersion is the API group and version for abac v0
var
GroupVersion
=
unversioned
.
GroupVersion
{
Group
:
api
.
Group
,
Version
:
"v0"
}
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v0"
}
func
init
()
{
func
init
()
{
// TODO: Delete this init function, abac should not have its own scheme.
// TODO: Delete this init function, abac should not have its own scheme.
...
@@ -43,7 +45,7 @@ var (
...
@@ -43,7 +45,7 @@ var (
)
)
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
GroupVersion
,
scheme
.
AddKnownTypes
(
Scheme
GroupVersion
,
&
Policy
{},
&
Policy
{},
)
)
return
nil
return
nil
...
...
pkg/apis/abac/v1beta1/register.go
View file @
4850314a
...
@@ -22,8 +22,10 @@ import (
...
@@ -22,8 +22,10 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
)
)
// GroupVersion is the API group and version for abac v1beta1
const
GroupName
=
"abac.authorization.kubernetes.io"
var
GroupVersion
=
unversioned
.
GroupVersion
{
Group
:
api
.
Group
,
Version
:
"v1beta1"
}
// SchemeGroupVersion is the API group and version for abac v1beta1
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1beta1"
}
func
init
()
{
func
init
()
{
// TODO: delete this, abac should not have its own scheme.
// TODO: delete this, abac should not have its own scheme.
...
@@ -39,7 +41,7 @@ var (
...
@@ -39,7 +41,7 @@ var (
)
)
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
GroupVersion
,
scheme
.
AddKnownTypes
(
Scheme
GroupVersion
,
&
Policy
{},
&
Policy
{},
)
)
return
nil
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment