github.com/x-helm/helm@v3.0.0-beta.3+incompatible/pkg/plugin/installer/local_installer.go (about) 1 /* 2 Copyright The Helm Authors. 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 installer // import "helm.sh/helm/pkg/plugin/installer" 17 18 import ( 19 "path/filepath" 20 21 "github.com/pkg/errors" 22 ) 23 24 // LocalInstaller installs plugins from the filesystem. 25 type LocalInstaller struct { 26 base 27 } 28 29 // NewLocalInstaller creates a new LocalInstaller. 30 func NewLocalInstaller(source string) (*LocalInstaller, error) { 31 src, err := filepath.Abs(source) 32 if err != nil { 33 return nil, errors.Wrap(err, "unable to get absolute path to plugin") 34 } 35 i := &LocalInstaller{ 36 base: newBase(src), 37 } 38 return i, nil 39 } 40 41 // Install creates a symlink to the plugin directory. 42 // 43 // Implements Installer. 44 func (i *LocalInstaller) Install() error { 45 if !isPlugin(i.Source) { 46 return ErrMissingMetadata 47 } 48 return i.link(i.Source) 49 } 50 51 // Update updates a local repository 52 func (i *LocalInstaller) Update() error { 53 debug("local repository is auto-updated") 54 return nil 55 }