github.com/umeshredd/helm@v3.0.0-alpha.1+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  	"helm.sh/helm/pkg/helmpath"
    24  )
    25  
    26  // LocalInstaller installs plugins from the filesystem.
    27  type LocalInstaller struct {
    28  	base
    29  }
    30  
    31  // NewLocalInstaller creates a new LocalInstaller.
    32  func NewLocalInstaller(source string, home helmpath.Home) (*LocalInstaller, error) {
    33  	src, err := filepath.Abs(source)
    34  	if err != nil {
    35  		return nil, errors.Wrap(err, "unable to get absolute path to plugin")
    36  	}
    37  	i := &LocalInstaller{
    38  		base: newBase(src, home),
    39  	}
    40  	return i, nil
    41  }
    42  
    43  // Install creates a symlink to the plugin directory in $HELM_HOME.
    44  //
    45  // Implements Installer.
    46  func (i *LocalInstaller) Install() error {
    47  	if !isPlugin(i.Source) {
    48  		return ErrMissingMetadata
    49  	}
    50  	return i.link(i.Source)
    51  }
    52  
    53  // Update updates a local repository
    54  func (i *LocalInstaller) Update() error {
    55  	debug("local repository is auto-updated")
    56  	return nil
    57  }