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
6f7007af
Commit
6f7007af
authored
Jun 15, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make addition group registration easier
parent
4fdde68f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
19 deletions
+98
-19
resourceListing.json
api/swagger-spec/resourceListing.json
+14
-14
resource_config.go
pkg/genericapiserver/resource_config.go
+13
-0
resource_config_test.go
pkg/genericapiserver/resource_config_test.go
+61
-0
master.go
pkg/master/master.go
+0
-0
master_test.go
pkg/master/master_test.go
+10
-5
No files found.
api/swagger-spec/resourceListing.json
View file @
6f7007af
...
...
@@ -26,6 +26,14 @@
"description"
:
"get information of a group"
},
{
"path"
:
"/apis/apps/v1alpha1"
,
"description"
:
"API at /apis/apps/v1alpha1"
},
{
"path"
:
"/apis/apps"
,
"description"
:
"get information of a group"
},
{
"path"
:
"/apis/autoscaling/v1"
,
"description"
:
"API at /apis/autoscaling/v1"
},
...
...
@@ -46,27 +54,19 @@
"description"
:
"get information of a group"
},
{
"path"
:
"/apis/policy/v1alpha1"
,
"description"
:
"API at /apis/policy/v1alpha1"
},
{
"path"
:
"/apis/policy"
,
"description"
:
"get information of a group"
},
{
"path"
:
"/apis/apps/v1alpha1"
,
"description"
:
"API at /apis/apps/v1alpha1"
"path"
:
"/apis/certificates/v1alpha1"
,
"description"
:
"API at /apis/certificates/v1alpha1"
},
{
"path"
:
"/apis/
app
s"
,
"path"
:
"/apis/
certificate
s"
,
"description"
:
"get information of a group"
},
{
"path"
:
"/apis/
certificates
/v1alpha1"
,
"description"
:
"API at /apis/
certificates
/v1alpha1"
"path"
:
"/apis/
policy
/v1alpha1"
,
"description"
:
"API at /apis/
policy
/v1alpha1"
},
{
"path"
:
"/apis/
certificates
"
,
"path"
:
"/apis/
policy
"
,
"description"
:
"get information of a group"
},
{
...
...
pkg/genericapiserver/resource_config.go
View file @
6f7007af
...
...
@@ -27,6 +27,7 @@ type APIResourceConfigSource interface {
ResourceEnabled
(
resource
unversioned
.
GroupVersionResource
)
bool
AllResourcesForVersionEnabled
(
version
unversioned
.
GroupVersion
)
bool
AnyResourcesForVersionEnabled
(
version
unversioned
.
GroupVersion
)
bool
AnyResourcesForGroupEnabled
(
group
string
)
bool
}
// Specifies the overrides for various API group versions.
...
...
@@ -170,3 +171,15 @@ func (o *ResourceConfig) AnyResourcesForVersionEnabled(version unversioned.Group
return
versionOverride
.
Enable
}
func
(
o
*
ResourceConfig
)
AnyResourcesForGroupEnabled
(
group
string
)
bool
{
for
version
:=
range
o
.
GroupVersionResourceConfigs
{
if
version
.
Group
==
group
{
if
o
.
AnyResourcesForVersionEnabled
(
version
)
{
return
true
}
}
}
return
false
}
pkg/genericapiserver/resource_config_test.go
View file @
6f7007af
...
...
@@ -97,3 +97,64 @@ func TestDisabledVersion(t *testing.T) {
}
}
func
TestAnyResourcesForGroupEnabled
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
creator
func
()
APIResourceConfigSource
testGroup
string
expectedResult
bool
}{
{
name
:
"empty"
,
creator
:
func
()
APIResourceConfigSource
{
return
NewResourceConfig
()
},
testGroup
:
"one"
,
expectedResult
:
false
,
},
{
name
:
"present, but disabled"
,
creator
:
func
()
APIResourceConfigSource
{
ret
:=
NewResourceConfig
()
ret
.
DisableVersions
(
unversioned
.
GroupVersion
{
Group
:
"one"
,
Version
:
"version1"
})
return
ret
},
testGroup
:
"one"
,
expectedResult
:
false
,
},
{
name
:
"present, and one version enabled"
,
creator
:
func
()
APIResourceConfigSource
{
ret
:=
NewResourceConfig
()
ret
.
DisableVersions
(
unversioned
.
GroupVersion
{
Group
:
"one"
,
Version
:
"version1"
})
ret
.
EnableVersions
(
unversioned
.
GroupVersion
{
Group
:
"one"
,
Version
:
"version2"
})
return
ret
},
testGroup
:
"one"
,
expectedResult
:
true
,
},
{
name
:
"present, and one resource"
,
creator
:
func
()
APIResourceConfigSource
{
ret
:=
NewResourceConfig
()
ret
.
DisableVersions
(
unversioned
.
GroupVersion
{
Group
:
"one"
,
Version
:
"version1"
})
ret
.
EnableResources
(
unversioned
.
GroupVersionResource
{
Group
:
"one"
,
Version
:
"version2"
,
Resource
:
"foo"
})
return
ret
},
testGroup
:
"one"
,
expectedResult
:
true
,
},
}
for
_
,
tc
:=
range
tests
{
if
e
,
a
:=
tc
.
expectedResult
,
tc
.
creator
()
.
AnyResourcesForGroupEnabled
(
tc
.
testGroup
);
e
!=
a
{
t
.
Errorf
(
"%s: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
}
}
}
pkg/master/master.go
View file @
6f7007af
This diff is collapsed.
Click to expand it.
pkg/master/master_test.go
View file @
6f7007af
...
...
@@ -136,9 +136,14 @@ func newMaster(t *testing.T) (*Master, *etcdtesting.EtcdTestServer, Config, *ass
// limitedAPIResourceConfigSource only enables the core group, the extensions group, the batch group, and the autoscaling group.
func
limitedAPIResourceConfigSource
()
*
genericapiserver
.
ResourceConfig
{
ret
:=
genericapiserver
.
NewResourceConfig
()
ret
.
EnableVersions
(
apiv1
.
SchemeGroupVersion
,
extensionsapiv1beta1
.
SchemeGroupVersion
,
batchapiv1
.
SchemeGroupVersion
,
batchapiv2alpha1
.
SchemeGroupVersion
,
appsapi
.
SchemeGroupVersion
,
autoscalingapiv1
.
SchemeGroupVersion
)
ret
.
EnableVersions
(
apiv1
.
SchemeGroupVersion
,
extensionsapiv1beta1
.
SchemeGroupVersion
,
batchapiv1
.
SchemeGroupVersion
,
batchapiv2alpha1
.
SchemeGroupVersion
,
appsapi
.
SchemeGroupVersion
,
autoscalingapiv1
.
SchemeGroupVersion
,
)
return
ret
}
...
...
@@ -493,7 +498,7 @@ func TestDiscoveryAtAPIS(t *testing.T) {
},
}
assert
.
Equal
(
3
,
len
(
groupList
.
Groups
))
assert
.
Equal
(
4
,
len
(
groupList
.
Groups
))
for
_
,
group
:=
range
groupList
.
Groups
{
if
!
expectGroupNames
.
Has
(
group
.
Name
)
{
t
.
Errorf
(
"got unexpected group %s"
,
group
.
Name
)
...
...
@@ -520,7 +525,7 @@ func TestDiscoveryAtAPIS(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
assert
.
Equal
(
4
,
len
(
groupList
.
Groups
))
assert
.
Equal
(
5
,
len
(
groupList
.
Groups
))
expectGroupNames
.
Insert
(
"company.com"
)
expectVersions
[
"company.com"
]
=
[]
unversioned
.
GroupVersionForDiscovery
{
thirdPartyGV
}
...
...
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