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
98eb5922
Commit
98eb5922
authored
Jan 19, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make kube-apiserver admission flag disable other plugins
parent
5c9e020d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
admission.go
pkg/kubeapiserver/options/admission.go
+6
-1
admission_test.go
pkg/kubeapiserver/options/admission_test.go
+35
-0
No files found.
pkg/kubeapiserver/options/admission.go
View file @
98eb5922
...
@@ -116,8 +116,13 @@ func (a *AdmissionOptions) ApplyTo(
...
@@ -116,8 +116,13 @@ func (a *AdmissionOptions) ApplyTo(
if
a
.
PluginNames
!=
nil
{
if
a
.
PluginNames
!=
nil
{
// pass PluginNames to generic AdmissionOptions
// pass PluginNames to generic AdmissionOptions
a
.
GenericAdmission
.
EnablePlugins
=
a
.
PluginNames
a
.
GenericAdmission
.
EnablePlugins
,
a
.
GenericAdmission
.
DisablePlugins
=
computePluginNames
(
a
.
PluginNames
,
a
.
GenericAdmission
.
RecommendedPluginOrder
)
}
}
return
a
.
GenericAdmission
.
ApplyTo
(
c
,
informers
,
kubeAPIServerClientConfig
,
scheme
,
pluginInitializers
...
)
return
a
.
GenericAdmission
.
ApplyTo
(
c
,
informers
,
kubeAPIServerClientConfig
,
scheme
,
pluginInitializers
...
)
}
}
// explicitly disable all plugins that are not in the enabled list
func
computePluginNames
(
explicitlyEnabled
[]
string
,
all
[]
string
)
(
enabled
[]
string
,
disabled
[]
string
)
{
return
explicitlyEnabled
,
sets
.
NewString
(
all
...
)
.
Difference
(
sets
.
NewString
(
explicitlyEnabled
...
))
.
List
()
}
pkg/kubeapiserver/options/admission_test.go
View file @
98eb5922
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
options
package
options
import
(
import
(
"reflect"
"testing"
"testing"
)
)
...
@@ -51,3 +52,37 @@ func TestValidate(t *testing.T) {
...
@@ -51,3 +52,37 @@ func TestValidate(t *testing.T) {
t
.
Errorf
(
"Unexpected err: %v"
,
errs
)
t
.
Errorf
(
"Unexpected err: %v"
,
errs
)
}
}
}
}
func
TestComputeEnabledAdmission
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
all
[]
string
enabled
[]
string
expectedDisabled
[]
string
}{
{
name
:
"matches"
,
all
:
[]
string
{
"one"
,
"two"
},
enabled
:
[]
string
{
"one"
,
"two"
},
expectedDisabled
:
[]
string
{},
},
{
name
:
"choose one"
,
all
:
[]
string
{
"one"
,
"two"
},
enabled
:
[]
string
{
"one"
},
expectedDisabled
:
[]
string
{
"two"
},
},
}
for
_
,
tc
:=
range
tests
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
actualEnabled
,
actualDisabled
:=
computePluginNames
(
tc
.
enabled
,
tc
.
all
)
if
e
,
a
:=
tc
.
enabled
,
actualEnabled
;
!
reflect
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
if
e
,
a
:=
tc
.
expectedDisabled
,
actualDisabled
;
!
reflect
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
})
}
}
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