Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
f32dcf28
Commit
f32dcf28
authored
Jun 09, 2017
by
Miek Gieben
Committed by
GitHub
Jun 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove pkg/storage (#727)
It's not used, remove it.
parent
0d72efbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
102 deletions
+0
-102
middleware/pkg/storage/fs.go
middleware/pkg/storage/fs.go
+0
-60
middleware/pkg/storage/fs_test.go
middleware/pkg/storage/fs_test.go
+0
-42
No files found.
middleware/pkg/storage/fs.go
deleted
100644 → 0
View file @
0d72efbb
// Package storage abstracts away where middleware can store assests (zones, keys, etc).
package
storage
import
(
"net/http"
"os"
"path"
"path/filepath"
"runtime"
)
// dir wraps an http.Dir that restrict file access to a specific directory tree, see http.Dir's documentation
// for methods for accessing files.
type
dir
http
.
Dir
// CoreDir is the directory where middleware can store assets, like zone files after a zone transfer
// or public and private keys or anything else a middleware might need. The convention is to place
// assets in a subdirectory named after the zone prefixed with "D", to prevent the root zone become a hidden directory.
//
// Dexample.org/Kexample.org<something>.key
//
// Note that subzone(s) under example.org are places in the own directory under CoreDir:
//
// Dexample.org/...
// Db.example.org/...
//
// CoreDir will default to "$HOME/.coredns" on Unix, but it's location can be overridden with the COREDNSPATH
// environment variable.
var
CoreDir
=
dir
(
fsPath
())
func
(
d
dir
)
Zone
(
z
string
)
dir
{
if
z
!=
"."
&&
z
[
len
(
z
)
-
2
]
==
'.'
{
return
dir
(
path
.
Join
(
string
(
d
),
"D"
+
z
[
:
len
(
z
)
-
1
]))
}
return
dir
(
path
.
Join
(
string
(
d
),
"D"
+
z
))
}
// fsPath returns the path to the directory where the application may store data.
// If COREDNSPATH env variable. is set, that value is used. Otherwise, the path is
// the result of evaluating "$HOME/.coredns".
func
fsPath
()
string
{
if
corePath
:=
os
.
Getenv
(
"COREDNSPATH"
);
corePath
!=
""
{
return
corePath
}
return
filepath
.
Join
(
userHomeDir
(),
".coredns"
)
}
// userHomeDir returns the user's home directory according to environment variables.
//
// Credit: http://stackoverflow.com/a/7922977/1048862
func
userHomeDir
()
string
{
if
runtime
.
GOOS
==
"windows"
{
home
:=
os
.
Getenv
(
"HOMEDRIVE"
)
+
os
.
Getenv
(
"HOMEPATH"
)
if
home
==
""
{
home
=
os
.
Getenv
(
"USERPROFILE"
)
}
return
home
}
return
os
.
Getenv
(
"HOME"
)
}
middleware/pkg/storage/fs_test.go
deleted
100644 → 0
View file @
0d72efbb
package
storage
import
(
"os"
"path"
"strings"
"testing"
)
func
TestFsPath
(
t
*
testing
.
T
)
{
if
actual
:=
fsPath
();
!
strings
.
HasSuffix
(
actual
,
".coredns"
)
{
t
.
Errorf
(
"Expected path to be a .coredns folder, got: %v"
,
actual
)
}
os
.
Setenv
(
"COREDNSPATH"
,
"testpath"
)
defer
os
.
Setenv
(
"COREDNSPATH"
,
""
)
if
actual
,
expected
:=
fsPath
(),
"testpath"
;
actual
!=
expected
{
t
.
Errorf
(
"Expected path to be %v, got: %v"
,
expected
,
actual
)
}
}
func
TestZone
(
t
*
testing
.
T
)
{
for
_
,
ts
:=
range
[]
string
{
"example.org."
,
"example.org"
}
{
d
:=
CoreDir
.
Zone
(
ts
)
actual
:=
path
.
Base
(
string
(
d
))
expected
:=
"D"
+
ts
if
actual
!=
expected
{
t
.
Errorf
(
"Expected path to be %v, got %v"
,
actual
,
expected
)
}
}
}
func
TestZoneRoot
(
t
*
testing
.
T
)
{
for
_
,
ts
:=
range
[]
string
{
"."
}
{
d
:=
CoreDir
.
Zone
(
ts
)
actual
:=
path
.
Base
(
string
(
d
))
expected
:=
"D"
+
ts
if
actual
!=
expected
{
t
.
Errorf
(
"Expected path to be %v, got %v"
,
actual
,
expected
)
}
}
}
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