mirror of https://github.com/helm/helm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.1 KiB
83 lines
2.1 KiB
8 years ago
|
/*
|
||
6 years ago
|
Copyright The Helm Authors.
|
||
8 years ago
|
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 helmpath
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
8 years ago
|
"os"
|
||
8 years ago
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
// Home describes the location of a CLI configuration.
|
||
|
//
|
||
|
// This helper builds paths relative to a Helm Home directory.
|
||
|
type Home string
|
||
|
|
||
|
// String returns Home as a string.
|
||
|
//
|
||
|
// Implements fmt.Stringer.
|
||
|
func (h Home) String() string {
|
||
8 years ago
|
return os.ExpandEnv(string(h))
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
// Path returns Home with elements appended.
|
||
|
func (h Home) Path(elem ...string) string {
|
||
8 years ago
|
p := []string{h.String()}
|
||
8 years ago
|
p = append(p, elem...)
|
||
|
return filepath.Join(p...)
|
||
|
}
|
||
|
|
||
6 years ago
|
// Registry returns the path to the local registry cache.
|
||
|
func (h Home) Registry() string {
|
||
|
return h.Path("registry")
|
||
|
}
|
||
|
|
||
8 years ago
|
// Repository returns the path to the local repository.
|
||
|
func (h Home) Repository() string {
|
||
8 years ago
|
return h.Path("repository")
|
||
8 years ago
|
}
|
||
|
|
||
|
// RepositoryFile returns the path to the repositories.yaml file.
|
||
|
func (h Home) RepositoryFile() string {
|
||
8 years ago
|
return h.Path("repository", "repositories.yaml")
|
||
8 years ago
|
}
|
||
|
|
||
|
// Cache returns the path to the local cache.
|
||
|
func (h Home) Cache() string {
|
||
8 years ago
|
return h.Path("repository", "cache")
|
||
8 years ago
|
}
|
||
|
|
||
|
// CacheIndex returns the path to an index for the given named repository.
|
||
|
func (h Home) CacheIndex(name string) string {
|
||
8 years ago
|
target := fmt.Sprintf("%s-index.yaml", name)
|
||
|
return h.Path("repository", "cache", target)
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
// Starters returns the path to the Helm starter packs.
|
||
|
func (h Home) Starters() string {
|
||
8 years ago
|
return h.Path("starters")
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
// Plugins returns the path to the plugins directory.
|
||
|
func (h Home) Plugins() string {
|
||
8 years ago
|
return h.Path("plugins")
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
// Archive returns the path to download chart archives.
|
||
8 years ago
|
func (h Home) Archive() string {
|
||
|
return h.Path("cache", "archive")
|
||
|
}
|