mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
We tend to get scared off from routine dependency upgrades because it's hard to know where to start when we want to avoid upgrading too many things at once and thus making it hard for us to understand the impact. This tool makes a best effort to suggest an order of upgrades that lets us upgrade one thing at a time when possible, and if not possible then at least tries to minimize how many things get upgraded at once. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
41 lines
930 B
Go
41 lines
930 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/apparentlymart/go-versions/versions"
|
|
)
|
|
|
|
// ModulePath is a string containing a Go module path.
|
|
type ModulePath string
|
|
|
|
// Version is a convenience alias for [versions.Version]
|
|
type Version = versions.Version
|
|
|
|
type UpgradeCandidate struct {
|
|
Module ModulePath
|
|
CurrentVersion Version
|
|
LatestVersion Version
|
|
}
|
|
|
|
type PendingUpgrade struct {
|
|
Module ModulePath
|
|
CurrentVersion Version
|
|
LatestVersion Version
|
|
Prereqs map[ModulePath]Version
|
|
}
|
|
|
|
func parseVersion(raw string) (Version, error) {
|
|
if !strings.HasPrefix(raw, "v") {
|
|
return versions.Unspecified, fmt.Errorf("missing 'v' prefix")
|
|
}
|
|
raw = raw[1:] // the "versions" library doesn't actually want the prefix
|
|
return versions.ParseVersion(raw)
|
|
}
|