Skip to content

Commit

Permalink
Refactor to clean up names.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Sep 16, 2014
1 parent 506f51b commit dc5a4a8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func main() {
glog.Fatalf("-etcd_servers flag is required.")
}

capabilities.InitializeCapabilities(capabilities.Capabilities{
capabilities.Initialize(capabilities.Capabilities{
AllowPrivileged: *allowPrivileged,
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func main() {

etcd.SetLogger(util.NewLogger("etcd "))

capabilities.InitializeCapabilities(capabilities.Capabilities{
capabilities.Initialize(capabilities.Capabilities{
AllowPrivileged: *allowPrivileged,
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func validateContainers(containers []api.Container, volumes util.StringSet) errs
for i := range containers {
cErrs := errs.ErrorList{}
ctr := &containers[i] // so we can set default values
capabilities := capabilities.GetCapabilities()
capabilities := capabilities.Get()
if len(ctr.Name) == 0 {
cErrs = append(cErrs, errs.NewFieldRequired("name", ctr.Name))
} else if !util.IsDNSLabel(ctr.Name) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestValidateVolumeMounts(t *testing.T) {

func TestValidateContainers(t *testing.T) {
volumes := util.StringSet{}
capabilities.SetCapabilitiesForTests(capabilities.Capabilities{
capabilities.SetForTests(capabilities.Capabilities{
AllowPrivileged: true,
})

Expand All @@ -203,7 +203,7 @@ func TestValidateContainers(t *testing.T) {
t.Errorf("expected success: %v", errs)
}

capabilities.SetCapabilitiesForTests(capabilities.Capabilities{
capabilities.SetForTests(capabilities.Capabilities{
AllowPrivileged: false,
})
errorCases := map[string][]api.Container{
Expand Down
8 changes: 4 additions & 4 deletions pkg/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ var once sync.Once
var capabilities *Capabilities

// Initialize the capability set. This can only be done once per binary, subsequent calls are ignored.
func InitializeCapabilities(c Capabilities) {
func Initialize(c Capabilities) {
// Only do this once
once.Do(func() {
capabilities = &c
})
}

// SetCapabilitiesForTests. Convenience method for testing. This should only be called from tests.
func SetCapabilitiesForTests(c Capabilities) {
func SetForTests(c Capabilities) {
capabilities = &c
}

// Returns a read-only copy of the system capabilities.
func GetCapabilities() Capabilities {
func Get() Capabilities {
if capabilities == nil {
InitializeCapabilities(Capabilities{
Initialize(Capabilities{
AllowPrivileged: false,
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (kl *Kubelet) runContainer(pod *Pod, container *api.Container, podVolumes v
return "", err
}
privileged := false
if capabilities.GetCapabilities().AllowPrivileged {
if capabilities.Get().AllowPrivileged {
privileged = container.Privileged
} else if container.Privileged {
return "", fmt.Errorf("Container requested privileged mode, but it is disallowed globally.")
Expand Down

0 comments on commit dc5a4a8

Please sign in to comment.