2015-03-26 19:50:36 +00:00
|
|
|
/*
|
2015-05-01 16:19:44 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors All rights reserved.
|
2015-03-26 19:50:36 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package volume
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
|
|
|
)
|
|
|
|
|
2015-05-18 20:22:30 +00:00
|
|
|
func GetAccessModesAsString(modes []api.PersistentVolumeAccessMode) string {
|
2015-03-26 19:50:36 +00:00
|
|
|
modesAsString := ""
|
|
|
|
|
|
|
|
if contains(modes, api.ReadWriteOnce) {
|
2015-03-30 22:07:53 +00:00
|
|
|
appendAccessMode(&modesAsString, "RWO")
|
2015-03-26 19:50:36 +00:00
|
|
|
}
|
|
|
|
if contains(modes, api.ReadOnlyMany) {
|
2015-03-30 22:07:53 +00:00
|
|
|
appendAccessMode(&modesAsString, "ROX")
|
2015-03-26 19:50:36 +00:00
|
|
|
}
|
|
|
|
if contains(modes, api.ReadWriteMany) {
|
2015-03-30 22:07:53 +00:00
|
|
|
appendAccessMode(&modesAsString, "RWX")
|
2015-03-26 19:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return modesAsString
|
|
|
|
}
|
|
|
|
|
2015-03-30 22:07:53 +00:00
|
|
|
func appendAccessMode(modes *string, mode string) {
|
|
|
|
if *modes != "" {
|
|
|
|
*modes += ","
|
2015-03-26 19:50:36 +00:00
|
|
|
}
|
2015-03-30 22:07:53 +00:00
|
|
|
*modes += mode
|
2015-03-26 19:50:36 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 20:22:30 +00:00
|
|
|
func contains(modes []api.PersistentVolumeAccessMode, mode api.PersistentVolumeAccessMode) bool {
|
2015-03-26 19:50:36 +00:00
|
|
|
for _, m := range modes {
|
|
|
|
if m == mode {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|