本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.Volume.HostPath方法的典型用法代码示例。如果您正苦于以下问题:Golang Volume.HostPath方法的具体用法?Golang Volume.HostPath怎么用?Golang Volume.HostPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/api.Volume
的用法示例。
在下文中一共展示了Volume.HostPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writePodVolume
func writePodVolume(m map[string]interface{}, item *api.Volume) {
if x, ok := m["name"].(string); ok {
item.Name = x
}
if n, ok := extractSingleMap(m["host_path"]); ok {
item.HostPath = &api.HostPathVolumeSource{}
if x, ok := n["path"].(string); ok {
item.HostPath.Path = x
}
}
if n, ok := extractSingleMap(m["empty_dir"]); ok {
item.EmptyDir = &api.EmptyDirVolumeSource{}
if x, ok := n["medium"].(string); ok {
item.EmptyDir.Medium = api.StorageMedium(x)
}
}
if n, ok := extractSingleMap(m["gce_persistent_disk"]); ok {
item.GCEPersistentDisk = &api.GCEPersistentDiskVolumeSource{}
if x, ok := n["pd_name"].(string); ok {
item.GCEPersistentDisk.PDName = x
}
if x, ok := n["fs_type"].(string); ok {
item.GCEPersistentDisk.FSType = x
}
if x, ok := n["partition"].(int); ok {
item.GCEPersistentDisk.Partition = x
}
if x, ok := n["read_only"].(bool); ok {
item.GCEPersistentDisk.ReadOnly = x
}
}
if n, ok := extractSingleMap(m["aws_elastic_block_store"]); ok {
item.AWSElasticBlockStore = &api.AWSElasticBlockStoreVolumeSource{}
if x, ok := n["volume_id"].(string); ok {
item.AWSElasticBlockStore.VolumeID = x
}
if x, ok := n["fs_type"].(string); ok {
item.AWSElasticBlockStore.FSType = x
}
if x, ok := n["partition"].(int); ok {
item.AWSElasticBlockStore.Partition = x
}
if x, ok := n["read_only"].(bool); ok {
item.AWSElasticBlockStore.ReadOnly = x
}
}
if n, ok := extractSingleMap(m["git_repo"]); ok {
item.GitRepo = &api.GitRepoVolumeSource{}
if x, ok := n["repository"].(string); ok {
item.GitRepo.Repository = x
}
if x, ok := n["revision"].(string); ok {
item.GitRepo.Revision = x
}
if x, ok := n["directory"].(string); ok {
item.GitRepo.Directory = x
}
}
if n, ok := extractSingleMap(m["secret"]); ok {
item.Secret = &api.SecretVolumeSource{}
if x, ok := n["secret_name"].(string); ok {
item.Secret.SecretName = x
}
}
// TODO:
// NFS *NFSVolumeSource
// ISCSI *ISCSIVolumeSource
// Glusterfs *GlusterfsVolumeSource
// PersistentVolumeClaim *PersistentVolumeClaimVolumeSource
// RBD *RBDVolumeSource
// FlexVolume *FlexVolumeSource
// Cinder *CinderVolumeSource
// CephFS *CephFSVolumeSource
// Flocker *FlockerVolumeSource
// DownwardAPI *DownwardAPIVolumeSource
// FC *FCVolumeSource
// AzureFile *AzureFileVolumeSource
// ConfigMap *ConfigMapVolumeSource
}
示例2: setVolumeSourceByType
func setVolumeSourceByType(kv *kapi.Volume, opts *AddVolumeOptions) error {
switch strings.ToLower(opts.Type) {
case "emptydir":
kv.EmptyDir = &kapi.EmptyDirVolumeSource{}
case "hostpath":
kv.HostPath = &kapi.HostPathVolumeSource{
Path: opts.Path,
}
case "secret":
kv.Secret = &kapi.SecretVolumeSource{
SecretName: opts.SecretName,
}
case "configmap":
kv.ConfigMap = &kapi.ConfigMapVolumeSource{
LocalObjectReference: kapi.LocalObjectReference{
Name: opts.ConfigMapName,
},
}
case "persistentvolumeclaim", "pvc":
kv.PersistentVolumeClaim = &kapi.PersistentVolumeClaimVolumeSource{
ClaimName: opts.ClaimName,
}
default:
return fmt.Errorf("invalid volume type: %s", opts.Type)
}
return nil
}