Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
52513443
Commit
52513443
authored
Apr 27, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm): add structure.go to hold paths
parent
7fde0643
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
40 deletions
+58
-40
home.go
cmd/helm/home.go
+0
-6
init.go
cmd/helm/init.go
+19
-27
init_test.go
cmd/helm/init_test.go
+5
-4
package.go
cmd/helm/package.go
+1
-1
search.go
cmd/helm/search.go
+1
-1
serve.go
cmd/helm/serve.go
+1
-1
structure.go
cmd/helm/structure.go
+31
-0
No files found.
cmd/helm/home.go
View file @
52513443
package
main
import
(
"os"
"github.com/spf13/cobra"
)
...
...
@@ -25,7 +23,3 @@ func init() {
func
home
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmd
.
Printf
(
homePath
()
+
"
\n
"
)
}
func
homePath
()
string
{
return
os
.
ExpandEnv
(
helmHome
)
}
cmd/helm/init.go
View file @
52513443
...
...
@@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/deis/tiller/pkg/client"
"github.com/deis/tiller/pkg/kubectl"
...
...
@@ -17,13 +16,10 @@ This command installs Tiller (the helm server side component) onto your
Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.helm/)
`
var
repositoriesFilePath
string
var
cachePath
string
var
localRepoPath
string
var
localCacheFilePath
string
var
tillerImg
string
var
defaultRepo
=
map
[
string
]
string
{
"default-name"
:
"default-url"
}
var
(
tillerImg
string
defaultRepo
=
map
[
string
]
string
{
"default-name"
:
"default-url"
}
)
func
init
()
{
initCmd
.
Flags
()
.
StringVarP
(
&
tillerImg
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
...
...
@@ -43,7 +39,7 @@ func runInit(cmd *cobra.Command, args []string) error {
return
errors
.
New
(
"This command does not accept arguments.
\n
"
)
}
if
err
:=
ensureHome
(
homePath
()
);
err
!=
nil
{
if
err
:=
ensureHome
();
err
!=
nil
{
return
err
}
...
...
@@ -81,14 +77,8 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner {
// ensureHome checks to see if $HELM_HOME exists
//
// If $HELM_HOME does not exist, this function will create it.
func
ensureHome
(
home
string
)
error
{
repositoriesFilePath
=
filepath
.
Join
(
home
,
"repositories.yaml"
)
cachePath
=
filepath
.
Join
(
home
,
"cache"
)
localRepoPath
=
filepath
.
Join
(
home
,
"local"
)
localCacheFilePath
=
filepath
.
Join
(
home
,
"cache.yaml"
)
fmt
.
Println
(
"home path: "
+
home
)
configDirectories
:=
[]
string
{
home
,
cachePath
,
localRepoPath
}
func
ensureHome
()
error
{
configDirectories
:=
[]
string
{
homePath
(),
cacheDirectory
(),
localRepoDirectory
()}
for
_
,
p
:=
range
configDirectories
{
if
fi
,
err
:=
os
.
Stat
(
p
);
err
!=
nil
{
...
...
@@ -101,28 +91,30 @@ func ensureHome(home string) error {
}
}
if
fi
,
err
:=
os
.
Stat
(
repositoriesFilePath
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
repositoriesFilePath
)
if
err
:=
ioutil
.
WriteFile
(
repositoriesFilePath
,
[]
byte
(
"local: localhost:8879/charts
\n
"
),
0644
);
err
!=
nil
{
repoFile
:=
repositoriesFile
()
if
fi
,
err
:=
os
.
Stat
(
repoFile
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
repoFile
)
if
err
:=
ioutil
.
WriteFile
(
repoFile
,
[]
byte
(
"local: localhost:8879/charts
\n
"
),
0644
);
err
!=
nil
{
return
err
}
}
else
if
fi
.
IsDir
()
{
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
repo
sitoriesFilePath
)
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
repo
File
)
}
if
fi
,
err
:=
os
.
Stat
(
localCacheFilePath
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
localCacheFilePath
)
_
,
err
:=
os
.
Create
(
localCacheFilePath
)
localRepoCacheFile
:=
localRepoDirectory
(
localRepoCacheFilePath
)
if
fi
,
err
:=
os
.
Stat
(
localRepoCacheFile
);
err
!=
nil
{
fmt
.
Printf
(
"Creating %s
\n
"
,
localRepoCacheFile
)
_
,
err
:=
os
.
Create
(
localRepoCacheFile
)
if
err
!=
nil
{
return
err
}
//TODO: take this out and replace with helm update functionality
os
.
Symlink
(
local
CacheFilePath
,
filepath
.
Join
(
cachePath
,
"local-cache.yaml"
))
os
.
Symlink
(
local
RepoCacheFile
,
cacheDirectory
(
"local-cache.yaml"
))
}
else
if
fi
.
IsDir
()
{
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
local
CacheFilePath
)
return
fmt
.
Errorf
(
"%s must be a file, not a directory"
,
local
RepoCacheFile
)
}
fmt
.
Printf
(
"$HELM_HOME has
also
been configured at %s.
\n
"
,
helmHome
)
fmt
.
Printf
(
"$HELM_HOME has been configured at %s.
\n
"
,
helmHome
)
return
nil
}
cmd/helm/init_test.go
View file @
52513443
...
...
@@ -8,11 +8,12 @@ import (
func
TestEnsureHome
(
t
*
testing
.
T
)
{
home
:=
createTmpHome
()
if
err
:=
ensureHome
(
home
);
err
!=
nil
{
helmHome
=
home
if
err
:=
ensureHome
();
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
expectedDirs
:=
[]
string
{
home
,
cachePath
,
localRepoPath
}
expectedDirs
:=
[]
string
{
home
Path
(),
cacheDirectory
(),
localRepoDirectory
()
}
for
_
,
dir
:=
range
expectedDirs
{
if
fi
,
err
:=
os
.
Stat
(
dir
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
...
...
@@ -21,13 +22,13 @@ func TestEnsureHome(t *testing.T) {
}
}
if
fi
,
err
:=
os
.
Stat
(
repositoriesFile
Path
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
repositoriesFile
()
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
else
if
fi
.
IsDir
()
{
t
.
Errorf
(
"%s should not be a directory"
,
fi
)
}
if
fi
,
err
:=
os
.
Stat
(
local
CacheFilePath
);
err
!=
nil
{
if
fi
,
err
:=
os
.
Stat
(
local
RepoDirectory
(
localRepoCacheFilePath
)
);
err
!=
nil
{
t
.
Errorf
(
"%s"
,
err
)
}
else
if
fi
.
IsDir
()
{
t
.
Errorf
(
"%s should not be a directory"
,
fi
)
...
...
cmd/helm/package.go
View file @
52513443
...
...
@@ -56,7 +56,7 @@ func runPackage(cmd *cobra.Command, args []string) error {
// Save to $HELM_HOME/local directory.
if
save
{
if
err
:=
repo
.
AddChartToLocalRepo
(
ch
,
localRepo
Path
);
err
!=
nil
{
if
err
:=
repo
.
AddChartToLocalRepo
(
ch
,
localRepo
Directory
()
);
err
!=
nil
{
return
err
}
}
...
...
cmd/helm/search.go
View file @
52513443
...
...
@@ -40,7 +40,7 @@ func search(cmd *cobra.Command, args []string) error {
func
searchCacheForPattern
(
name
string
)
([]
string
,
error
)
{
fileList
:=
[]
string
{}
filepath
.
Walk
(
cache
Path
,
func
(
path
string
,
f
os
.
FileInfo
,
err
error
)
error
{
filepath
.
Walk
(
cache
Directory
()
,
func
(
path
string
,
f
os
.
FileInfo
,
err
error
)
error
{
if
!
f
.
IsDir
()
{
fileList
=
append
(
fileList
,
path
)
}
...
...
cmd/helm/serve.go
View file @
52513443
...
...
@@ -22,5 +22,5 @@ var serveCmd = &cobra.Command{
}
func
serve
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
repo
.
StartLocalRepo
(
localRepo
Path
)
repo
.
StartLocalRepo
(
localRepo
Directory
()
)
}
cmd/helm/structure.go
0 → 100644
View file @
52513443
package
main
import
(
"os"
"path/filepath"
)
const
(
repositoriesFilePath
string
=
"repositories.yaml"
cachePath
string
=
"cache"
localRepoPath
string
=
"local"
localRepoCacheFilePath
string
=
"cache.yaml"
)
func
homePath
()
string
{
return
os
.
ExpandEnv
(
helmHome
)
}
func
cacheDirectory
(
paths
...
string
)
string
{
fragments
:=
append
([]
string
{
homePath
(),
cachePath
},
paths
...
)
return
filepath
.
Join
(
fragments
...
)
}
func
localRepoDirectory
(
paths
...
string
)
string
{
fragments
:=
append
([]
string
{
homePath
(),
localRepoPath
},
paths
...
)
return
filepath
.
Join
(
fragments
...
)
}
func
repositoriesFile
()
string
{
return
filepath
.
Join
(
homePath
(),
repositoriesFilePath
)
}
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