Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
44419ce3
Unverified
Commit
44419ce3
authored
Jan 18, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72950 from ddebroy/csimig2
Enhance CSI translation plugin files with accessors and proper names
parents
54c4428e
e1d274a8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
16 deletions
+31
-16
README.md
staging/src/k8s.io/csi-translation-lib/README.md
+2
-2
aws_ebs.go
staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go
+13
-6
gce_pd.go
staging/src/k8s.io/csi-translation-lib/plugins/gce_pd.go
+14
-6
translate.go
staging/src/k8s.io/csi-translation-lib/translate.go
+2
-2
No files found.
staging/src/k8s.io/csi-translation-lib/README.md
View file @
44419ce3
...
...
@@ -4,8 +4,8 @@ This repository contains functions to be consumed by various Kubernetes and
out-of-tree CSI components like external provisioner to facilitate migration of
code from Kubernetes In-tree plugin code to CSI plugin repositories.
Consumers
can make use of this repository can make use of functions like
`TranslateTo
CSI`
and
`TranslateTo
InTree`
functions to translate PV sources.
Consumers
of this repository can make use of functions like
`TranslateToCSI`
and
`TranslateToInTree`
functions to translate PV sources.
## Community, discussion, contribution, and support
...
...
staging/src/k8s.io/csi-translation-lib/plugins/aws_ebs.go
View file @
44419ce3
...
...
@@ -30,12 +30,19 @@ const (
AWSEBSInTreePluginName
=
"kubernetes.io/aws-ebs"
)
// AWSEBS handles translation of PV spec from In-tree EBS to CSI EBS and vice versa
type
AWSEBS
struct
{}
var
_
InTreePlugin
=
&
awsElasticBlockStoreCSITranslator
{}
// awsElasticBlockStoreTranslator handles translation of PV spec from In-tree EBS to CSI EBS and vice versa
type
awsElasticBlockStoreCSITranslator
struct
{}
// NewAWSElasticBlockStoreCSITranslator returns a new instance of awsElasticBlockStoreTranslator
func
NewAWSElasticBlockStoreCSITranslator
()
InTreePlugin
{
return
&
awsElasticBlockStoreCSITranslator
{}
}
// TranslateInTreePVToCSI takes a PV with AWSElasticBlockStore set from in-tree
// and converts the AWSElasticBlockStore source to a CSIPersistentVolumeSource
func
(
t
*
AWSEBS
)
TranslateInTreePVToCSI
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
func
(
t
*
awsElasticBlockStoreCSITranslator
)
TranslateInTreePVToCSI
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
if
pv
==
nil
||
pv
.
Spec
.
AWSElasticBlockStore
==
nil
{
return
nil
,
fmt
.
Errorf
(
"pv is nil or AWS EBS not defined on pv"
)
}
...
...
@@ -59,7 +66,7 @@ func (t *AWSEBS) TranslateInTreePVToCSI(pv *v1.PersistentVolume) (*v1.Persistent
// TranslateCSIPVToInTree takes a PV with CSIPersistentVolumeSource set and
// translates the EBS CSI source to a AWSElasticBlockStore source.
func
(
t
*
AWSEBS
)
TranslateCSIPVToInTree
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
func
(
t
*
awsElasticBlockStoreCSITranslator
)
TranslateCSIPVToInTree
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
if
pv
==
nil
||
pv
.
Spec
.
CSI
==
nil
{
return
nil
,
fmt
.
Errorf
(
"pv is nil or CSI source not defined on pv"
)
}
...
...
@@ -88,11 +95,11 @@ func (t *AWSEBS) TranslateCSIPVToInTree(pv *v1.PersistentVolume) (*v1.Persistent
// CanSupport tests whether the plugin supports a given volume
// specification from the API. The spec pointer should be considered
// const.
func
(
t
*
AWSEBS
)
CanSupport
(
pv
*
v1
.
PersistentVolume
)
bool
{
func
(
t
*
awsElasticBlockStoreCSITranslator
)
CanSupport
(
pv
*
v1
.
PersistentVolume
)
bool
{
return
pv
!=
nil
&&
pv
.
Spec
.
AWSElasticBlockStore
!=
nil
}
// GetInTreePluginName returns the name of the intree plugin driver
func
(
t
*
AWSEBS
)
GetInTreePluginName
()
string
{
func
(
t
*
awsElasticBlockStoreCSITranslator
)
GetInTreePluginName
()
string
{
return
AWSEBSInTreePluginName
}
staging/src/k8s.io/csi-translation-lib/plugins/gce_pd.go
View file @
44419ce3
...
...
@@ -47,12 +47,20 @@ const (
UnspecifiedValue
=
"UNSPECIFIED"
)
// GCEPD handles translation of PV spec from In-tree GCE PD to CSI GCE PD and vice versa
type
GCEPD
struct
{}
var
_
InTreePlugin
=
&
gcePersistentDiskCSITranslator
{}
// gcePersistentDiskCSITranslator handles translation of PV spec from In-tree
// GCE PD to CSI GCE PD and vice versa
type
gcePersistentDiskCSITranslator
struct
{}
// NewGCEPersistentDiskCSITranslator returns a new instance of gcePersistentDiskTranslator
func
NewGCEPersistentDiskCSITranslator
()
InTreePlugin
{
return
&
gcePersistentDiskCSITranslator
{}
}
// TranslateInTreePVToCSI takes a PV with GCEPersistentDisk set from in-tree
// and converts the GCEPersistentDisk source to a CSIPersistentVolumeSource
func
(
g
*
GCEPD
)
TranslateInTreePVToCSI
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
func
(
g
*
gcePersistentDiskCSITranslator
)
TranslateInTreePVToCSI
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
var
volID
string
if
pv
==
nil
||
pv
.
Spec
.
GCEPersistentDisk
==
nil
{
...
...
@@ -95,7 +103,7 @@ func (g *GCEPD) TranslateInTreePVToCSI(pv *v1.PersistentVolume) (*v1.PersistentV
// TranslateCSIPVToInTree takes a PV with CSIPersistentVolumeSource set and
// translates the GCE PD CSI source to a GCEPersistentDisk source.
func
(
g
*
GCEPD
)
TranslateCSIPVToInTree
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
func
(
g
*
gcePersistentDiskCSITranslator
)
TranslateCSIPVToInTree
(
pv
*
v1
.
PersistentVolume
)
(
*
v1
.
PersistentVolume
,
error
)
{
if
pv
==
nil
||
pv
.
Spec
.
CSI
==
nil
{
return
nil
,
fmt
.
Errorf
(
"pv is nil or CSI source not defined on pv"
)
}
...
...
@@ -130,12 +138,12 @@ func (g *GCEPD) TranslateCSIPVToInTree(pv *v1.PersistentVolume) (*v1.PersistentV
// CanSupport tests whether the plugin supports a given volume
// specification from the API. The spec pointer should be considered
// const.
func
(
g
*
GCEPD
)
CanSupport
(
pv
*
v1
.
PersistentVolume
)
bool
{
func
(
g
*
gcePersistentDiskCSITranslator
)
CanSupport
(
pv
*
v1
.
PersistentVolume
)
bool
{
return
pv
!=
nil
&&
pv
.
Spec
.
GCEPersistentDisk
!=
nil
}
// GetInTreePluginName returns the name of the intree plugin driver
func
(
g
*
GCEPD
)
GetInTreePluginName
()
string
{
func
(
g
*
gcePersistentDiskCSITranslator
)
GetInTreePluginName
()
string
{
return
GCEPDInTreePluginName
}
...
...
staging/src/k8s.io/csi-translation-lib/translate.go
View file @
44419ce3
...
...
@@ -25,8 +25,8 @@ import (
var
(
inTreePlugins
=
map
[
string
]
plugins
.
InTreePlugin
{
plugins
.
GCEPDDriverName
:
&
plugins
.
GCEPD
{}
,
plugins
.
AWSEBSDriverName
:
&
plugins
.
AWSEBS
{}
,
plugins
.
GCEPDDriverName
:
plugins
.
NewGCEPersistentDiskCSITranslator
()
,
plugins
.
AWSEBSDriverName
:
plugins
.
NewAWSElasticBlockStoreCSITranslator
()
,
plugins
.
CinderDriverName
:
plugins
.
NewOpenStackCinderCSITranslator
(),
}
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment