Documentation ¶
Index ¶
- Constants
- Variables
- func CheckParameterValidate(inputs []string) bool
- func CheckQuotaPathValidate(kubeClient *kubernetes.Clientset, path string) error
- func CreateCertPEM(option CertOption, ca *KeyPairArtifacts, begin, end time.Time, isClient bool) ([]byte, []byte, error)
- func CreateDest(dest string) error
- func CreateEvent(recorder record.EventRecorder, objectRef *v1.ObjectReference, eventType string, ...)
- func Decrypt(s string, keyring []byte) ([]byte, error)
- func FindSuggestionByErrorMessage(errMsg, errorType string) string
- func Fsync(f *os.File) error
- func GetFileContent(fileName string) string
- func GetMetaData(resource string) (string, error)
- func GetMetrics(path string) (*csi.NodeGetVolumeStatsResponse, error)
- func GetNodeAddr(client kubernetes.Interface, node string, port string) (string, error)
- func GetNodeIP(client kubernetes.Interface, nodeID string) (net.IP, error)
- func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet *kubernetes.Clientset) (string, error)
- func GetPvNameFormPodMnt(mntPath string) string
- func GetRegionAndInstanceID() (string, string, error)
- func GetRegionIDAndInstanceID(nodeName string) (string, string, error)
- func IsDir(path string) bool
- func IsDirEmpty(name string) (bool, error)
- func IsDirTmpfs(path string) bool
- func IsFileExisting(filename string) bool
- func IsHostFileExist(path string) bool
- func IsLikelyNotMountPoint(file string) (bool, error)
- func IsMountPointRunv(mountPoint string) bool
- func IsMounted(mountPath string) bool
- func NewClientTLSFromFile(serverName, caFile, certFile, keyFile string) (credentials.TransportCredentials, error)
- func NewEcsClient(ac AccessControl) (ecsClient *ecs.Client)
- func NewEventRecorder() record.EventRecorder
- func NewServerTLSFromFile(caFile, certFile, keyFile string) (credentials.TransportCredentials, error)
- func PKCS5UnPadding(origData []byte) []byte
- func Ping(ipAddress string) (*ping.Statistics, error)
- func ReadJSONFile(file string) (map[string]string, error)
- func RetryGetMetaData(resource string) string
- func Run(cmd string) (string, error)
- func RunTimeout(cmd string, timeout int) error
- func Umount(mountPath string) error
- func WriteAndSyncFile(filename string, data []byte, perm os.FileMode) error
- func WriteJSONFile(obj interface{}, file string) error
- func WriteJosnFile(obj interface{}, file string) error
- type AKInfo
- type AccessControl
- type AccessControlMode
- type CertOption
- type CommandRunFunc
- type DefaultOptions
- type KeyPairArtifacts
- type ManageTokens
- type Mounter
- type Result
- type RoleAuth
Constants ¶
const ( // DiskAttachDetach ... DiskAttachDetach = "diskAttachDetach" // DiskProvision ... DiskProvision = "diskProvision" // DiskMount ... DiskMount = "diskMount" // DiskDelete ... DiskDelete = "diskDelete" // NasFilesystemCreate ... NasFilesystemCreate = "nasFilesystemCreate" // NasFilesystemDelete ... NasFilesystemDelete = "nasFilesystemDelete" // NasMountTargetCreate ... NasMountTargetCreate = "nasMountTargetCreate" // NasMountTargetDelete ... NasMountTargetDelete = "nasMountTargetDelete" )
const ( // UserAKID is user AK ID UserAKID = "/etc/.volumeak/akId" // UserAKSecret is user AK Secret UserAKSecret = "/etc/.volumeak/akSecret" // MetadataURL is metadata url MetadataURL = "http://100.100.100.200/latest/meta-data/" // RegionIDTag is region id RegionIDTag = "region-id" // InstanceIDTag is instance id InstanceIDTag = "instance-id" // DefaultRegion is default region DefaultRegion = "cn-hangzhou" // CsiPluginRunTimeFlagFile tag CsiPluginRunTimeFlagFile = "../alibabacloudcsiplugin.json" // RuncRunTimeTag tag RuncRunTimeTag = "runc" // RunvRunTimeTag tag RunvRunTimeTag = "runv" // ServiceType tag ServiceType = "SERVICE_TYPE" // PluginService represents the csi-plugin type. PluginService = "plugin" // ProvisionerService represents the csi-provisioner type. ProvisionerService = "provisioner" // InstallSnapshotCRD tag InstallSnapshotCRD = "INSTALL_SNAPSHOT_CRD" // MetadataMaxRetrycount ... MetadataMaxRetrycount = 4 // NsenterCmd is the nsenter command NsenterCmd = "/nsenter --mount=/proc/1/ns/mnt --ipc=/proc/1/ns/ipc --net=/proc/1/ns/net --uts=/proc/1/ns/uts " )
const (
// ConfigPath the secret mount file
ConfigPath = "/var/addon/token-config"
)
Variables ¶
var DiskAttachDetachErrors = map[string]*errorInfo{ "had volume node affinity conflict": { // contains filtered or unexported fields }, "can't find disk:": { // contains filtered or unexported fields }, "instance does not support this disk category.": { // contains filtered or unexported fields }, "The specified disk is not a portable disk.": { // contains filtered or unexported fields }, }
DiskAttachDetachErrors are errors throwed by disk attach
var DiskDeleteErrors = map[string]*errorInfo{}
DiskDeleteErrors are errors throwed by disk delete
var DiskMountErrors = map[string]*errorInfo{}
DiskMountErrors are errors throwed by disk mount
var DiskProvisionErrors = map[string]*errorInfo{ "disk size is not supported.": { // contains filtered or unexported fields }, }
DiskProvisionErrors are errors throwed by ecs create disk api
var KubeletRootDir = "/var/lib/kubelet"
KubeletRootDir kubelet root dir;
var KubernetesAlicloudIdentity = fmt.Sprintf("Kubernetes.Alicloud/CsiPlugin")
KubernetesAlicloudIdentity set a identity label
var MountPathWithTLS = "/tls"
MountPathWithTLS tls mount path;
var NasFilesystemCreateErrors = map[string]*errorInfo{}
NasFilesystemCreateErrors are errors throwed by nas create
var NasFilesystemDeleteErrors = map[string]*errorInfo{}
NasFilesystemDeleteErrors are errors throwed by nas filesystem delete
var NasMountTargetCreateErrors = map[string]*errorInfo{}
NasMountTargetCreateErrors are errors throwed by nas mount target create
var NasMountTargetDeleteErrors = map[string]*errorInfo{}
NasMountTargetDeleteErrors are errors throwed by nas mount target delete
Functions ¶
func CheckParameterValidate ¶ added in v1.1.5
CheckParameterValidate is check parameter validating in csi-plugin
func CheckQuotaPathValidate ¶ added in v1.1.5
func CheckQuotaPathValidate(kubeClient *kubernetes.Clientset, path string) error
CheckQuotaPathValidate is check quota path validating in csi-plugin
func CreateCertPEM ¶ added in v1.1.5
func CreateCertPEM(option CertOption, ca *KeyPairArtifacts, begin, end time.Time, isClient bool) ([]byte, []byte, error)
CreateCertPEM function is create cacert pem
func CreateEvent ¶ added in v1.1.1
func CreateEvent(recorder record.EventRecorder, objectRef *v1.ObjectReference, eventType string, reason string, err string)
CreateEvent is create events
func FindSuggestionByErrorMessage ¶ added in v1.1.0
FindSuggestionByErrorMessage get new error message by error type & error message
func Fsync ¶ added in v1.1.5
Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform.
func GetFileContent ¶ added in v1.0.4
GetFileContent get file content
func GetMetaData ¶
GetMetaData get metadata from ecs meta-server
func GetMetrics ¶ added in v1.0.3
func GetMetrics(path string) (*csi.NodeGetVolumeStatsResponse, error)
GetMetrics get path metric
func GetNodeAddr ¶ added in v1.1.5
GetNodeAddr get node address
func GetPodRunTime ¶ added in v1.0.4
func GetPodRunTime(req *csi.NodePublishVolumeRequest, clientSet *kubernetes.Clientset) (string, error)
GetPodRunTime Get Pod runtimeclass config Default as runc.
func GetPvNameFormPodMnt ¶ added in v1.1.5
GetPvNameFormPodMnt get pv name
func GetRegionAndInstanceID ¶ added in v1.0.1
GetRegionAndInstanceID get region and instanceID object
func GetRegionIDAndInstanceID ¶ added in v1.0.1
GetRegionIDAndInstanceID get regionID and instanceID object
func IsDirEmpty ¶ added in v1.0.1
IsDirEmpty return status of dir empty or not
func IsDirTmpfs ¶ added in v1.1.5
IsDirTmpfs check path is tmpfs mounted or not
func IsFileExisting ¶
IsFileExisting check file exist in volume driver or not
func IsHostFileExist ¶ added in v1.1.5
IsHostFileExist is check host file is existing in lvm
func IsLikelyNotMountPoint ¶ added in v1.1.5
IsLikelyNotMountPoint return status of mount point,this function fix IsMounted return 0 bug
func IsMountPointRunv ¶ added in v1.0.4
IsMountPointRunv check the mountpoint is runv style
func NewClientTLSFromFile ¶ added in v1.1.5
func NewClientTLSFromFile(serverName, caFile, certFile, keyFile string) (credentials.TransportCredentials, error)
NewClientTLSFromFile function is new client with tls
func NewEcsClient ¶ added in v1.0.1
func NewEcsClient(ac AccessControl) (ecsClient *ecs.Client)
NewEcsClient create a ecsClient object
func NewEventRecorder ¶ added in v1.1.0
func NewEventRecorder() record.EventRecorder
NewEventRecorder is create snapshots event recorder
func NewServerTLSFromFile ¶ added in v1.1.5
func NewServerTLSFromFile(caFile, certFile, keyFile string) (credentials.TransportCredentials, error)
NewServerTLSFromFile function is new server with tls
func PKCS5UnPadding ¶ added in v1.0.5
PKCS5UnPadding get pkc
func Ping ¶ added in v1.1.1
func Ping(ipAddress string) (*ping.Statistics, error)
Ping check network like shell ping command
func ReadJSONFile ¶ added in v1.0.1
ReadJSONFile return a json object
func RetryGetMetaData ¶ added in v1.1.5
RetryGetMetaData ...
func WriteAndSyncFile ¶ added in v1.1.5
WriteAndSyncFile behaves just like ioutil.WriteFile in the standard library, but calls Sync before closing the file. WriteAndSyncFile guarantees the data is synced if there is no error returned.
func WriteJSONFile ¶ added in v1.0.1
WriteJSONFile write a json object
func WriteJosnFile ¶
WriteJosnFile save json data to file
Types ¶
type AKInfo ¶ added in v1.0.5
type AKInfo struct { // AccessKeyId access key id AccessKeyID string `json:"access.key.id"` // AccessKeySecret access key secret AccessKeySecret string `json:"access.key.secret"` // SecurityToken security token SecurityToken string `json:"security.token"` // Expiration expiration duration Expiration string `json:"expiration"` // Keyring key ring Keyring string `json:"keyring"` // RoleAccessKeyId key RoleAccessKeyID string `json:"role.access.key.id"` // RoleAccessKeySecret key RoleAccessKeySecret string `json:"role.access.key.secret"` // RoleArn key RoleArn string `json:"role.arn"` }
AKInfo access key info
type AccessControl ¶ added in v1.1.6
type AccessControl struct { AccessKeyID string AccessKeySecret string StsToken string RoleArn string Config *sdk.Config Credential auth.Credential UseMode AccessControlMode }
AccessControl is access control option
func GetAccessControl ¶ added in v1.1.6
func GetAccessControl() AccessControl
GetAccessControl 1、Read default ak from local file. 2、If local default ak is not exist, then read from STS.
func GetDefaultRoleAK ¶ added in v1.1.5
func GetDefaultRoleAK() AccessControl
GetDefaultRoleAK 返回角色扮演账号AK, SK, role arn
func GetLocalAK ¶
func GetLocalAK() AccessControl
GetLocalAK read ossfs ak from local or from secret file
type AccessControlMode ¶ added in v1.1.6
type AccessControlMode int
AccessControlMode is int, represents different modes
const ( AccessKey AccessControlMode = iota ManagedToken EcsRAMRole Credential RoleArnToken )
AccessControlMode includes AccessKey, ManagedToken, EcsRamRole, Credential, RoleArnToken, five types of access control
type CertOption ¶ added in v1.1.5
type CertOption struct { CAName string CAOrganizations []string DNSNames []string CommonName string }
CertOption is cert option
type CommandRunFunc ¶ added in v1.1.1
CommandRunFunc define the run function in utils for ut
type DefaultOptions ¶
type DefaultOptions struct { Global struct { KubernetesClusterTag string AccessKeyID string `json:"accessKeyID"` AccessKeySecret string `json:"accessKeySecret"` Region string `json:"region"` } }
DefaultOptions used for global ak
type KeyPairArtifacts ¶ added in v1.1.5
type KeyPairArtifacts struct { Cert *x509.Certificate Key *rsa.PrivateKey CertPEM []byte KeyPEM []byte }
KeyPairArtifacts is cert struct
func CreateCACert ¶ added in v1.1.5
func CreateCACert(option CertOption, begin, end time.Time) (*KeyPairArtifacts, error)
CreateCACert function is create cacert
type ManageTokens ¶ added in v1.1.5
type ManageTokens struct { // AccessKeyId key AccessKeyID string // AccessKeySecret key AccessKeySecret string // SecurityToken key SecurityToken string // RoleAccessKeyId key RoleAccessKeyID string // RoleAccessKeySecret key RoleAccessKeySecret string // RoleArn key RoleArn string }
ManageTokens 定义资源账号 和 角色扮演账号
type Mounter ¶ added in v1.0.1
type Mounter interface { // If the folder doesn't exist, it will call 'mkdir -p' EnsureFolder(target string) error // If the block doesn't exist, create it EnsureBlock(target string) error // Format formats the source with the given filesystem type Format(source, fsType string) error // Mount mounts source to target with the given fstype and options. Mount(source, target, fsType string, options ...string) error // Mount mounts source to target for block file. MountBlock(source, target string, options ...string) error // Unmount unmounts the given target Unmount(target string) error // IsFormatted checks whether the source device is formatted or not. It // returns true if the source device is already formatted. IsFormatted(source string) (bool, error) // IsMounted checks whether the target path is a correct mount (i.e: // propagated). It returns true if it's mounted. An error is returned in // case of system errors or if it's mounted incorrectly. IsMounted(target string) (bool, error) SafePathRemove(target string) error HasMountRefs(mountPath string, mountRefs []string) bool }
Mounter is responsible for formatting and mounting volumes
func NewMounter ¶ added in v1.0.1
func NewMounter() Mounter
NewMounter returns a new mounter instance