2017-04-06 14:28:09 -04:00
|
|
|
/*
|
2018-08-24 15:03:55 -04:00
|
|
|
Copyright The Helm Authors.
|
2017-04-06 14:28:09 -04:00
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-16 17:42:00 -04:00
|
|
|
package installer // import "helm.sh/helm/v4/internal/plugin/installer"
|
2017-04-06 14:28:09 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
|
2024-12-26 16:33:51 -05:00
|
|
|
"helm.sh/helm/v4/pkg/cli"
|
2017-04-06 14:28:09 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type base struct {
|
|
|
|
|
// Source is the reference to a plugin
|
|
|
|
|
Source string
|
2021-08-06 21:38:17 -04:00
|
|
|
// PluginsDirectory is the directory where plugins are installed
|
|
|
|
|
PluginsDirectory string
|
2017-04-06 14:28:09 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-14 03:11:21 -05:00
|
|
|
func newBase(source string) base {
|
2021-08-06 21:38:17 -04:00
|
|
|
settings := cli.New()
|
|
|
|
|
return base{
|
|
|
|
|
Source: source,
|
|
|
|
|
PluginsDirectory: settings.PluginsDirectory,
|
|
|
|
|
}
|
2017-04-06 14:28:09 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-22 18:33:01 -04:00
|
|
|
// Path is where the plugin will be installed.
|
2017-04-06 14:28:09 -04:00
|
|
|
func (b *base) Path() string {
|
|
|
|
|
if b.Source == "" {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2021-08-06 21:38:17 -04:00
|
|
|
return filepath.Join(b.PluginsDirectory, filepath.Base(b.Source))
|
2017-04-06 14:28:09 -04:00
|
|
|
}
|