Skip to content

Commit 1f7092d

Browse files
feat: publish alternative k0s url in release metadata (#205)
if we are using an alternative k0s binary for a release we need to expose this as part of the release metadata. without this we can't make upgrades use the right binary. the idea here is: if for a given release we need to replace the k0s binary we will create a branch for it and make sure that the makefile points to the right location on the branch. we can then create a tag on such branch and get a release that points to a different location. for instace: let's suppose we want to override the k0s binary for the next release, we could add a value for K0S_BINARY_SOURCE_OVERRIDE in the makefile, push and tag. this is not optimal as we need to remember to remove the value from K0S_BINARY_SOURCE_OVERRIDE for subsequent releases hence the idea of making this in a tag.
1 parent 5d3d3fd commit 1f7092d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ K0S_BINARY_SOURCE_OVERRIDE =
1919
TROUBLESHOOT_VERSION = v0.78.1
2020
LD_FLAGS = -X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sVersion=$(K0S_VERSION) \
2121
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.Version=$(VERSION) \
22+
-X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sBinaryURL=$(K0S_BINARY_SOURCE_OVERRIDE) \
2223
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartURL=$(ADMIN_CONSOLE_CHART_URL) \
2324
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartName=$(ADMIN_CONSOLE_CHART_NAME) \
2425
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.Version=$(ADMIN_CONSOLE_CHART_VERSION) \

cmd/embedded-cluster/version.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ var versionCommand = &cli.Command{
4141
// ReleaseMetadata holds the metadata about a specific release, including addons and
4242
// their versions.
4343
type ReleaseMetadata struct {
44-
Versions map[string]string
45-
K0sSHA string
44+
Versions map[string]string
45+
K0sSHA string
46+
K0sBinaryURL string
4647
}
4748

4849
var metadataCommand = &cli.Command{
@@ -61,7 +62,11 @@ var metadataCommand = &cli.Command{
6162
if err != nil {
6263
return fmt.Errorf("unable to get k0s binary sha256: %w", err)
6364
}
64-
meta := ReleaseMetadata{Versions: versions, K0sSHA: sha}
65+
meta := ReleaseMetadata{
66+
Versions: versions,
67+
K0sSHA: sha,
68+
K0sBinaryURL: defaults.K0sBinaryURL,
69+
}
6570
data, err := json.MarshalIndent(meta, "", "\t")
6671
if err != nil {
6772
return fmt.Errorf("unable to marshal versions: %w", err)

pkg/defaults/defaults.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ var (
1111
K0sVersion = "0.0.0"
1212
// provider holds a global reference to the default provider.
1313
provider *Provider
14+
// K0sBinaryURL holds an alternative URL from where to download the k0s
15+
// binary that has been embedded in this version of the binary. If this
16+
// is empty then it means we have shipped the official k0s binary. This
17+
// is set at compile time via ldflags.
18+
K0sBinaryURL = ""
1419
)
1520

1621
// def returns a global reference to the default provider. creates one if not

0 commit comments

Comments
 (0)