Admission control attributes has access to resource name

This commit is contained in:
derekwaynecarr
2015-06-17 16:40:36 -04:00
parent 5e25827919
commit f6fb72ec51
12 changed files with 71 additions and 56 deletions

View File

@@ -24,6 +24,7 @@ import (
type attributesRecord struct {
kind string
namespace string
name string
resource string
subresource string
operation Operation
@@ -31,10 +32,11 @@ type attributesRecord struct {
userInfo user.Info
}
func NewAttributesRecord(object runtime.Object, kind, namespace, resource, subresource string, operation Operation, userInfo user.Info) Attributes {
func NewAttributesRecord(object runtime.Object, kind, namespace, name, resource, subresource string, operation Operation, userInfo user.Info) Attributes {
return &attributesRecord{
kind: kind,
namespace: namespace,
name: name,
resource: resource,
subresource: subresource,
operation: operation,
@@ -51,6 +53,10 @@ func (record *attributesRecord) GetNamespace() string {
return record.namespace
}
func (record *attributesRecord) GetName() string {
return record.name
}
func (record *attributesRecord) GetResource() string {
return record.resource
}

View File

@@ -98,7 +98,7 @@ func TestAdmit(t *testing.T) {
},
}
for _, test := range tests {
err := test.chain.Admit(NewAttributesRecord(nil, "", "", "", "", test.operation, nil))
err := test.chain.Admit(NewAttributesRecord(nil, "", "", "", "", "", test.operation, nil))
accepted := (err == nil)
if accepted != test.accept {
t.Errorf("%s: unexpected result of admit call: %v\n", test.name, accepted)

View File

@@ -24,6 +24,10 @@ import (
// Attributes is an interface used by AdmissionController to get information about a request
// that is used to make an admission decision.
type Attributes interface {
// GetName returns the name of the object as presented in the request. On a CREATE operation, the client
// may omit name and rely on the server to generate the name. If that is the case, this method will return
// the empty string
GetName() string
// GetNamespace is the namespace associated with the request (if any)
GetNamespace() string
// GetResource is the name of the resource being requested. This is not the kind. For example: pods