github.com/felipejfc/helm@v2.1.2+incompatible/cmd/helm/helmpath/helmhome.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package helmpath 17 18 import ( 19 "fmt" 20 "path/filepath" 21 ) 22 23 // Home describes the location of a CLI configuration. 24 // 25 // This helper builds paths relative to a Helm Home directory. 26 type Home string 27 28 // String returns Home as a string. 29 // 30 // Implements fmt.Stringer. 31 func (h Home) String() string { 32 return string(h) 33 } 34 35 // Repository returns the path to the local repository. 36 func (h Home) Repository() string { 37 return filepath.Join(string(h), "repository") 38 } 39 40 // RepositoryFile returns the path to the repositories.yaml file. 41 func (h Home) RepositoryFile() string { 42 return filepath.Join(string(h), "repository/repositories.yaml") 43 } 44 45 // Cache returns the path to the local cache. 46 func (h Home) Cache() string { 47 return filepath.Join(string(h), "repository/cache") 48 } 49 50 // CacheIndex returns the path to an index for the given named repository. 51 func (h Home) CacheIndex(name string) string { 52 target := fmt.Sprintf("repository/cache/%s-index.yaml", name) 53 return filepath.Join(string(h), target) 54 } 55 56 // Starters returns the path to the Helm starter packs. 57 func (h Home) Starters() string { 58 return filepath.Join(string(h), "starters") 59 } 60 61 // LocalRepository returns the location to the local repo. 62 // 63 // The local repo is the one used by 'helm serve' 64 // 65 // If additional path elements are passed, they are appended to the returned path. 66 func (h Home) LocalRepository(paths ...string) string { 67 frag := append([]string{string(h), "repository/local"}, paths...) 68 return filepath.Join(frag...) 69 } 70 71 // Plugins returns the path to the plugins directory. 72 func (h Home) Plugins() string { 73 return filepath.Join(string(h), "plugins") 74 }