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
2fd82f60
Commit
2fd82f60
authored
Mar 24, 2015
by
markturansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move escape function to util and clarify name
parent
a4c02d8e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
23 deletions
+50
-23
volumes.go
pkg/kubelet/volumes.go
+2
-1
escape.go
pkg/util/escape.go
+36
-0
empty_dir.go
pkg/volume/empty_dir/empty_dir.go
+1
-1
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+2
-1
git_repo.go
pkg/volume/git_repo/git_repo.go
+3
-2
nfs.go
pkg/volume/nfs/nfs.go
+2
-1
plugins.go
pkg/volume/plugins.go
+0
-15
secret.go
pkg/volume/secret/secret.go
+2
-1
testing.go
pkg/volume/testing.go
+2
-1
No files found.
pkg/kubelet/volumes.go
View file @
2fd82f60
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/davecgh/go-spew/spew"
"github.com/davecgh/go-spew/spew"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -174,7 +175,7 @@ func (kl *Kubelet) getPodVolumesFromDisk() map[string]volume.Cleaner {
...
@@ -174,7 +175,7 @@ func (kl *Kubelet) getPodVolumesFromDisk() map[string]volume.Cleaner {
}
}
func
(
kl
*
Kubelet
)
newVolumeCleanerFromPlugins
(
kind
string
,
name
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
func
(
kl
*
Kubelet
)
newVolumeCleanerFromPlugins
(
kind
string
,
name
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
plugName
:=
volume
.
UnescapePluginName
(
kind
)
plugName
:=
util
.
UnescapeQualifiedNameForDisk
(
kind
)
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginByName
(
plugName
)
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginByName
(
plugName
)
if
err
!=
nil
{
if
err
!=
nil
{
// TODO: Maybe we should launch a cleanup of this dir?
// TODO: Maybe we should launch a cleanup of this dir?
...
...
pkg/util/escape.go
0 → 100644
View file @
2fd82f60
/*
Copyright 2014 Google Inc. All rights reserved.
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
util
import
(
"strings"
)
// EscapeQualifiedNameForDisk converts a plugin name, which might contain a / into a
// string that is safe to use on-disk. This assumes that the input has already
// been validates as a qualified name. we use "~" rather than ":" here in case
// we ever use a filesystem that doesn't allow ":".
func
EscapeQualifiedNameForDisk
(
in
string
)
string
{
return
strings
.
Replace
(
in
,
"/"
,
"~"
,
-
1
)
}
// UnescapeQualifiedNameForDisk converts an escaped plugin name (as per EscapeQualifiedNameForDisk)
// back to its normal form. This assumes that the input has already been
// validates as a qualified name.
func
UnescapeQualifiedNameForDisk
(
in
string
)
string
{
return
strings
.
Replace
(
in
,
"~"
,
"/"
,
-
1
)
}
pkg/volume/empty_dir/empty_dir.go
View file @
2fd82f60
...
@@ -203,7 +203,7 @@ func (ed *emptyDir) GetPath() string {
...
@@ -203,7 +203,7 @@ func (ed *emptyDir) GetPath() string {
if
ed
.
legacyMode
{
if
ed
.
legacyMode
{
name
=
emptyDirPluginLegacyName
name
=
emptyDirPluginLegacyName
}
}
return
ed
.
plugin
.
host
.
GetPodVolumeDir
(
ed
.
podUID
,
volume
.
EscapePluginName
(
name
),
ed
.
volName
)
return
ed
.
plugin
.
host
.
GetPodVolumeDir
(
ed
.
podUID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
ed
.
volName
)
}
}
// TearDown simply discards everything in the directory.
// TearDown simply discards everything in the directory.
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
2fd82f60
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
...
@@ -242,7 +243,7 @@ func (pd *gcePersistentDisk) GetPath() string {
...
@@ -242,7 +243,7 @@ func (pd *gcePersistentDisk) GetPath() string {
if
pd
.
legacyMode
{
if
pd
.
legacyMode
{
name
=
gcePersistentDiskPluginLegacyName
name
=
gcePersistentDiskPluginLegacyName
}
}
return
pd
.
plugin
.
host
.
GetPodVolumeDir
(
pd
.
podUID
,
volume
.
EscapePluginName
(
name
),
pd
.
volName
)
return
pd
.
plugin
.
host
.
GetPodVolumeDir
(
pd
.
podUID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
pd
.
volName
)
}
}
// Unmounts the bind mount, and detaches the disk only if the PD
// Unmounts the bind mount, and detaches the disk only if the PD
...
...
pkg/volume/git_repo/git_repo.go
View file @
2fd82f60
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -169,7 +170,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
...
@@ -169,7 +170,7 @@ func (gr *gitRepo) SetUpAt(dir string) error {
}
}
func
(
gr
*
gitRepo
)
getMetaDir
()
string
{
func
(
gr
*
gitRepo
)
getMetaDir
()
string
{
return
path
.
Join
(
gr
.
plugin
.
host
.
GetPodPluginDir
(
gr
.
podRef
.
UID
,
volume
.
EscapePluginName
(
gitRepoPluginName
)),
gr
.
volName
)
return
path
.
Join
(
gr
.
plugin
.
host
.
GetPodPluginDir
(
gr
.
podRef
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
gitRepoPluginName
)),
gr
.
volName
)
}
}
func
(
gr
*
gitRepo
)
isReady
()
bool
{
func
(
gr
*
gitRepo
)
isReady
()
bool
{
...
@@ -212,7 +213,7 @@ func (gr *gitRepo) GetPath() string {
...
@@ -212,7 +213,7 @@ func (gr *gitRepo) GetPath() string {
if
gr
.
legacyMode
{
if
gr
.
legacyMode
{
name
=
gitRepoPluginLegacyName
name
=
gitRepoPluginLegacyName
}
}
return
gr
.
plugin
.
host
.
GetPodVolumeDir
(
gr
.
podRef
.
UID
,
volume
.
EscapePluginName
(
name
),
gr
.
volName
)
return
gr
.
plugin
.
host
.
GetPodVolumeDir
(
gr
.
podRef
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
gr
.
volName
)
}
}
// TearDown simply deletes everything in the directory.
// TearDown simply deletes everything in the directory.
...
...
pkg/volume/nfs/nfs.go
View file @
2fd82f60
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -146,7 +147,7 @@ func (nfsVolume *nfs) SetUpAt(dir string) error {
...
@@ -146,7 +147,7 @@ func (nfsVolume *nfs) SetUpAt(dir string) error {
func
(
nfsVolume
*
nfs
)
GetPath
()
string
{
func
(
nfsVolume
*
nfs
)
GetPath
()
string
{
name
:=
nfsPluginName
name
:=
nfsPluginName
return
nfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
nfsVolume
.
podRef
.
UID
,
volume
.
EscapePluginName
(
name
),
nfsVolume
.
volName
)
return
nfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
nfsVolume
.
podRef
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
nfsVolume
.
volName
)
}
}
func
(
nfsVolume
*
nfs
)
TearDown
()
error
{
func
(
nfsVolume
*
nfs
)
TearDown
()
error
{
...
...
pkg/volume/plugins.go
View file @
2fd82f60
...
@@ -173,18 +173,3 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
...
@@ -173,18 +173,3 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
}
}
return
pm
.
plugins
[
matches
[
0
]],
nil
return
pm
.
plugins
[
matches
[
0
]],
nil
}
}
// EscapePluginName converts a plugin name, which might contain a / into a
// string that is safe to use on-disk. This assumes that the input has already
// been validates as a qualified name. we use "~" rather than ":" here in case
// we ever use a filesystem that doesn't allow ":".
func
EscapePluginName
(
in
string
)
string
{
return
strings
.
Replace
(
in
,
"/"
,
"~"
,
-
1
)
}
// UnescapePluginName converts an escaped plugin name (as per EscapePluginName)
// back to its normal form. This assumes that the input has already been
// validates as a qualified name.
func
UnescapePluginName
(
in
string
)
string
{
return
strings
.
Replace
(
in
,
"~"
,
"/"
,
-
1
)
}
pkg/volume/secret/secret.go
View file @
2fd82f60
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -128,7 +129,7 @@ func (sv *secretVolume) SetUpAt(dir string) error {
...
@@ -128,7 +129,7 @@ func (sv *secretVolume) SetUpAt(dir string) error {
}
}
func
(
sv
*
secretVolume
)
GetPath
()
string
{
func
(
sv
*
secretVolume
)
GetPath
()
string
{
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
podRef
.
UID
,
volume
.
EscapePluginName
(
secretPluginName
),
sv
.
volName
)
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
podRef
.
UID
,
util
.
EscapeQualifiedNameForDisk
(
secretPluginName
),
sv
.
volName
)
}
}
func
(
sv
*
secretVolume
)
TearDown
()
error
{
func
(
sv
*
secretVolume
)
TearDown
()
error
{
...
...
pkg/volume/testing.go
View file @
2fd82f60
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
// fakeVolumeHost is useful for testing volume plugins.
// fakeVolumeHost is useful for testing volume plugins.
...
@@ -117,7 +118,7 @@ func (fv *FakeVolume) SetUpAt(dir string) error {
...
@@ -117,7 +118,7 @@ func (fv *FakeVolume) SetUpAt(dir string) error {
}
}
func
(
fv
*
FakeVolume
)
GetPath
()
string
{
func
(
fv
*
FakeVolume
)
GetPath
()
string
{
return
path
.
Join
(
fv
.
Plugin
.
Host
.
GetPodVolumeDir
(
fv
.
PodUID
,
EscapePluginName
(
fv
.
Plugin
.
PluginName
),
fv
.
VolName
))
return
path
.
Join
(
fv
.
Plugin
.
Host
.
GetPodVolumeDir
(
fv
.
PodUID
,
util
.
EscapeQualifiedNameForDisk
(
fv
.
Plugin
.
PluginName
),
fv
.
VolName
))
}
}
func
(
fv
*
FakeVolume
)
TearDown
()
error
{
func
(
fv
*
FakeVolume
)
TearDown
()
error
{
...
...
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