|
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
|
|
|
|
package installer // import "helm.sh/helm/v4/pkg/plugin/installer"
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"log/slog"
|
|
|
|
|
"os"
|
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
|
@ -88,13 +89,13 @@ func (i *VCSInstaller) Install() error {
|
|
|
|
|
return ErrMissingMetadata
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debug("copying %s to %s", i.Repo.LocalPath(), i.Path())
|
|
|
|
|
slog.Debug("copying files", "source", i.Repo.LocalPath(), "destination", i.Path())
|
|
|
|
|
return fs.CopyDir(i.Repo.LocalPath(), i.Path())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update updates a remote repository
|
|
|
|
|
func (i *VCSInstaller) Update() error {
|
|
|
|
|
debug("updating %s", i.Repo.Remote())
|
|
|
|
|
slog.Debug("updating", "source", i.Repo.Remote())
|
|
|
|
|
if i.Repo.IsDirty() {
|
|
|
|
|
return errors.New("plugin repo was modified")
|
|
|
|
|
}
|
|
|
|
@ -128,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
debug("found refs: %s", refs)
|
|
|
|
|
slog.Debug("found refs", "refs", refs)
|
|
|
|
|
|
|
|
|
|
// Convert and filter the list to semver.Version instances
|
|
|
|
|
semvers := getSemVers(refs)
|
|
|
|
@ -139,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
|
|
|
|
|
if constraint.Check(v) {
|
|
|
|
|
// If the constraint passes get the original reference
|
|
|
|
|
ver := v.Original()
|
|
|
|
|
debug("setting to %s", ver)
|
|
|
|
|
slog.Debug("setting to version", "version", ver)
|
|
|
|
|
return ver, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -149,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
|
|
|
|
|
|
|
|
|
|
// setVersion attempts to checkout the version
|
|
|
|
|
func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error {
|
|
|
|
|
debug("setting version to %q", i.Version)
|
|
|
|
|
slog.Debug("setting version", "version", i.Version)
|
|
|
|
|
return repo.UpdateVersion(ref)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// sync will clone or update a remote repo.
|
|
|
|
|
func (i *VCSInstaller) sync(repo vcs.Repo) error {
|
|
|
|
|
if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) {
|
|
|
|
|
debug("cloning %s to %s", repo.Remote(), repo.LocalPath())
|
|
|
|
|
slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath())
|
|
|
|
|
return repo.Get()
|
|
|
|
|
}
|
|
|
|
|
debug("updating %s", repo.Remote())
|
|
|
|
|
slog.Debug("updating", "source", repo.Remote(), "destination", repo.LocalPath())
|
|
|
|
|
return repo.Update()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|