package clusterversion
import "github.com/oslokommune/okctl/pkg/upgrade/clusterversion"
Package clusterversion manages the cluster version
Index ¶
- type Versioner
- func New(out io.Writer, clusterID api.ID, upgradeState client.UpgradeState) Versioner
- func (v Versioner) GetClusterVersion() (string, error)
- func (v Versioner) SaveClusterVersion(version string) error
- func (v Versioner) SaveClusterVersionFromOriginalClusterVersionIfNotExists() error
- func (v Versioner) SaveClusterVersionIfNotExists(version string) error
- func (v Versioner) ValidateBinaryEqualsClusterVersion(binaryVersionString string) error
- func (v Versioner) ValidateBinaryVersionNotLessThanClusterVersion(binaryVersionString string) error
Types ¶
type Versioner ¶
type Versioner struct {
// contains filtered or unexported fields
}
Versioner knows how to enforce correct version of the okctl binary versus the cluster version. The intention is that we want to enforce that no users of a cluster are trying to run 'upgrade' or 'apply cluster' with an outdated version of the okctl binary, that is, a version that is older than the cluster version. The cluster version should be set to the current version whenever we run 'upgrade' or 'apply cluster'.
func New ¶
New returns a new Versioner
func (Versioner) GetClusterVersion ¶
GetClusterVersion returns the current cluster version
func (Versioner) SaveClusterVersion ¶
SaveClusterVersion saves the provided version
func (Versioner) SaveClusterVersionFromOriginalClusterVersionIfNotExists ¶
SaveClusterVersionFromOriginalClusterVersionIfNotExists gets the cluster's original version, and saves it as the current cluster version. (tag UPGR01)
When we're sure all users have set cluster version in state, the caller of this function can replace the call with a call to SaveClusterVersionIfNotExists(version.GetVersionInfo().Version).
Ideally, we would like to store just version.GetVersionInfo().Version, if it hasn't been stored before. Because what we want to achieve is to store current version of okctl into the current version of the cluster when a new cluster is made.
However, we're in a transition phase, where users' clusters don't have stored cluster version yet. If we simply store version.GetVersionInfo().Version, say 0.0.60, and the original cluster value is 0.0.50, this means the upgrade logic believes the cluster version is 0.0.60, when in fact it is 0.0.50. The upgrade logic will therefore not run upgrades for 0.0.50 to 0.0.60, when in fact they should be run.
The solution is to store the original cluster version instead. The upgrade logic will bump the cluster version to the current version when run.
To check if users has run this code, just check all users' cluster's state, and see if upgrade/ClusterVersion has been set or not. If it's set, it means this code has been run.
func (Versioner) SaveClusterVersionIfNotExists ¶
SaveClusterVersionIfNotExists saves the current cluster version
func (Versioner) ValidateBinaryEqualsClusterVersion ¶
ValidateBinaryEqualsClusterVersion returns an error if binary version is not equal to cluster version
func (Versioner) ValidateBinaryVersionNotLessThanClusterVersion ¶
ValidateBinaryVersionNotLessThanClusterVersion returns an error if binary version is less than cluster version.
Source Files ¶
- Version
- v0.0.106 (latest)
- Published
- Oct 21, 2022
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 18 hours ago –
Tools for package owners.