Skip to content

Commit 6575758

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-29
2 parents b232c81 + 58b0c09 commit 6575758

File tree

29 files changed

+118
-501
lines changed

29 files changed

+118
-501
lines changed

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ linters-settings:
3232
- reflectvaluecompare
3333
- sortslice
3434
- unusedwrite
35+
unused:
36+
field-writes-are-uses: false
37+
exported-fields-are-used: false
38+
# parameters-are-used: false
39+
local-variables-are-used: false
3540

3641
issues:
3742
# Print all issues reported by all linters.

cmd/buildtools/k0s.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,27 @@ var k0sImageComponents = map[string]addonComponent{
2424
getWolfiPackageName: func(opts addonComponentOptions) string {
2525
return "calico-node"
2626
},
27+
getWolfiPackageVersion: func(opts addonComponentOptions) string {
28+
return getCalicoVersion(opts)
29+
},
2730
},
2831
"quay.io/k0sproject/calico-cni": {
2932
name: "calico-cni",
3033
getWolfiPackageName: func(opts addonComponentOptions) string {
3134
return "calico-cni"
3235
},
36+
getWolfiPackageVersion: func(opts addonComponentOptions) string {
37+
return getCalicoVersion(opts)
38+
},
3339
},
3440
"quay.io/k0sproject/calico-kube-controllers": {
3541
name: "calico-kube-controllers",
3642
getWolfiPackageName: func(opts addonComponentOptions) string {
3743
return "calico-kube-controllers"
3844
},
45+
getWolfiPackageVersion: func(opts addonComponentOptions) string {
46+
return getCalicoVersion(opts)
47+
},
3948
},
4049
"registry.k8s.io/metrics-server/metrics-server": {
4150
name: "metrics-server",
@@ -108,3 +117,11 @@ func getK0sVersion() (*semver.Version, error) {
108117
}
109118
return semver.MustParse(v), nil
110119
}
120+
121+
func getCalicoVersion(opts addonComponentOptions) string {
122+
// k0s < 1.32 is not compatible with calico 3.29+
123+
if opts.k0sVersion.LessThan(semver.MustParse("1.32")) {
124+
return "3.28"
125+
}
126+
return latestPatchVersion(opts.upstreamVersion)
127+
}

cmd/buildtools/utils.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ func FamiliarImageName(imageName string) string {
172172
return reference.FamiliarName(ref)
173173
}
174174

175-
func GetLatestGitHubRelease(ctx context.Context, owner, repo string) (string, error) {
176-
client := github.NewClient(nil)
177-
release, _, err := client.Repositories.GetLatestRelease(ctx, owner, repo)
178-
if err != nil {
179-
return "", err
180-
}
181-
return release.GetName(), nil
182-
}
183-
184175
func latestPatchConstraint(s *semver.Version) string {
185176
return fmt.Sprintf(">=%d.%d,<%d.%d", s.Major(), s.Minor(), s.Major(), s.Minor()+1)
186177
}

cmd/installer/cli/install.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"time"
1414

1515
"github.com/gosimple/slug"
16-
k0sconfig "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1716
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
1817
"github.com/replicatedhq/embedded-cluster/cmd/installer/goods"
1918
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
@@ -69,9 +68,7 @@ type InstallCmdFlags struct {
6968
ignoreHostPreflights bool
7069
configValues string
7170

72-
networkInterface string
73-
isAutoSelectedNetworkInterface bool
74-
autoSelectNetworkInterfaceErr error
71+
networkInterface string
7572

7673
license *kotsv1beta1.License
7774
proxy *ecv1beta1.ProxySpec
@@ -194,10 +191,7 @@ func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags) error {
194191
// if a network interface flag was not provided, attempt to discover it
195192
if flags.networkInterface == "" {
196193
autoInterface, err := determineBestNetworkInterface()
197-
if err != nil {
198-
flags.autoSelectNetworkInterfaceErr = err
199-
} else {
200-
flags.isAutoSelectedNetworkInterface = true
194+
if err == nil {
201195
flags.networkInterface = autoInterface
202196
}
203197
}
@@ -216,15 +210,22 @@ func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags) error {
216210
flags.license = l
217211
}
218212

213+
if flags.configValues != "" {
214+
err := configutils.ValidateKotsConfigValues(flags.configValues)
215+
if err != nil {
216+
return fmt.Errorf("config values file is not valid: %w", err)
217+
}
218+
}
219+
220+
flags.isAirgap = flags.airgapBundle != ""
221+
219222
runtimeconfig.ApplyFlags(cmd.Flags())
220223
os.Setenv("TMPDIR", runtimeconfig.EmbeddedClusterTmpSubDir())
221224

222225
if err := runtimeconfig.WriteToDisk(); err != nil {
223226
return fmt.Errorf("unable to write runtime config to disk: %w", err)
224227
}
225228

226-
flags.isAirgap = flags.airgapBundle != ""
227-
228229
return nil
229230
}
230231

@@ -570,7 +571,7 @@ func materializeFiles(airgapBundle string) error {
570571
}
571572

572573
if airgapBundle != "" {
573-
mat.Infof("Materializing airgap installation files")
574+
mat.Infof("Materializing air gap installation files")
574575

575576
// read file from path
576577
rawfile, err := os.Open(airgapBundle)
@@ -1114,7 +1115,7 @@ func gatherVersionMetadata(withChannelRelease bool) (*types.ReleaseMetadata, err
11141115
}
11151116

11161117
additionalCharts := []ecv1beta1.Chart{}
1117-
additionalRepos := []k0sconfig.Repository{}
1118+
additionalRepos := []k0sv1beta1.Repository{}
11181119
if withChannelRelease {
11191120
additionalCharts = config.AdditionalCharts()
11201121
additionalRepos = config.AdditionalRepositories()

cmd/installer/cli/restore.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"github.com/sirupsen/logrus"
4040
"github.com/spf13/cobra"
4141
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
42-
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
4342
corev1 "k8s.io/api/core/v1"
4443
k8serrors "k8s.io/apimachinery/pkg/api/errors"
4544
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -1138,7 +1137,7 @@ func waitForVeleroRestoreCompleted(ctx context.Context, restoreName string) (*ve
11381137
}
11391138

11401139
for {
1141-
restore := velerov1api.Restore{}
1140+
restore := velerov1.Restore{}
11421141
err = kcli.Get(ctx, types.NamespacedName{Name: restoreName, Namespace: runtimeconfig.VeleroNamespace}, &restore)
11431142
if err != nil {
11441143
return nil, fmt.Errorf("unable to get restore: %w", err)
@@ -1412,7 +1411,7 @@ func restoreAppFromBackup(ctx context.Context, backup *velerov1.Backup, restore
14121411
restoreName := fmt.Sprintf("%s.restore", backup.Name)
14131412

14141413
// check if a restore object already exists
1415-
rest := velerov1api.Restore{}
1414+
rest := velerov1.Restore{}
14161415
err = kcli.Get(ctx, types.NamespacedName{Name: restoreName, Namespace: runtimeconfig.VeleroNamespace}, &rest)
14171416
if err != nil && !k8serrors.IsNotFound(err) {
14181417
return fmt.Errorf("unable to get restore: %w", err)
@@ -1454,7 +1453,7 @@ func restoreFromBackup(ctx context.Context, backup *velerov1.Backup, drComponent
14541453
restoreName := fmt.Sprintf("%s.%s", backup.Name, string(drComponent))
14551454

14561455
// check if a restore object already exists
1457-
rest := velerov1api.Restore{}
1456+
rest := velerov1.Restore{}
14581457
err = kcli.Get(ctx, types.NamespacedName{Name: restoreName, Namespace: runtimeconfig.VeleroNamespace}, &rest)
14591458
if err != nil && !k8serrors.IsNotFound(err) {
14601459
return fmt.Errorf("unable to get restore: %w", err)

cmd/installer/cli/restore_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli
33
import (
44
"context"
55
"embed"
6-
_ "embed"
76
"io"
87
"io/fs"
98
"testing"

deploy/images/seaweedfs/apko.tmpl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ contents:
99
- wolfi-base
1010
- seaweedfs~${PACKAGE_VERSION}
1111
- fuse3 # for weed mount
12+
- wget # for seaweedfs-bucket-hook
1213

1314
accounts:
1415
groups:

e2e/kots-release-upgrade/cluster-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ spec:
7979
values: |
8080
image:
8181
repository: proxy.replicated.com/anonymous/bloomberg/goldpinger
82-
- chartname: oci://registry-1.docker.io/bitnamicharts/memcached
82+
- chartname: oci://proxy.replicated.com/anonymous/bitnamicharts/memcached
8383
name: memcached
8484
namespace: memcached
8585
values: |

hack/test-installation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
image:
4242
repository: proxy.replicated.com/anonymous/bloomberg/goldpinger
4343
version: 6.1.2
44-
- chartname: oci://registry-1.docker.io/bitnamicharts/memcached
44+
- chartname: oci://proxy.replicated.com/anonymous/bitnamicharts/memcached
4545
name: memcached
4646
namespace: memcached
4747
order: 4

kinds/apis/v1beta1/config_types.go

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ package v1beta1
1818

1919
import (
2020
"encoding/json"
21-
"fmt"
2221
"time"
2322

24-
jsonpatch "github.com/evanphx/json-patch"
2523
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
2624
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27-
k8syaml "sigs.k8s.io/yaml"
2825
)
2926

3027
// UnsupportedOverrides holds the config overrides used to configure
@@ -148,32 +145,6 @@ type Extensions struct {
148145
Helm *Helm `json:"helm,omitempty"`
149146
}
150147

151-
func ConvertTo(e Helm, t *k0sv1beta1.HelmExtensions) (*k0sv1beta1.HelmExtensions, error) {
152-
j, err := json.Marshal(e)
153-
if err != nil {
154-
return t, fmt.Errorf("unable to convert extensions: %w", err)
155-
}
156-
157-
if err = json.Unmarshal(j, t); err != nil {
158-
return t, fmt.Errorf("unable to unmarshal to new type: %w", err)
159-
}
160-
161-
return t, nil
162-
}
163-
164-
func ConvertFrom(e k0sv1beta1.HelmExtensions, t *Helm) (*Helm, error) {
165-
j, err := json.Marshal(e)
166-
if err != nil {
167-
return t, fmt.Errorf("unable to convert extensions: %w", err)
168-
}
169-
170-
if err = json.Unmarshal(j, t); err != nil {
171-
return t, fmt.Errorf("unable to unmarshal to new type: %w", err)
172-
}
173-
174-
return t, nil
175-
}
176-
177148
// ConfigSpec defines the desired state of Config
178149
type ConfigSpec struct {
179150
Version string `json:"version,omitempty"`
@@ -201,35 +172,6 @@ func (c ConfigSpec) OverrideForBuiltIn(bi string) string {
201172
return ""
202173
}
203174

204-
// ApplyEndUserAddOnOverrides applies the end-user provided addon config on top
205-
// of the provided addon configuration (cfg).
206-
func (c *ConfigSpec) ApplyEndUserAddOnOverrides(name, cfg string) (string, error) {
207-
patch := c.OverrideForBuiltIn(name)
208-
if len(cfg) == 0 || len(patch) == 0 {
209-
if len(cfg) == 0 {
210-
return patch, nil
211-
}
212-
return cfg, nil
213-
}
214-
originalJSON, err := k8syaml.YAMLToJSON([]byte(cfg))
215-
if err != nil {
216-
return "", fmt.Errorf("unable to convert source yaml to json: %w", err)
217-
}
218-
patchJSON, err := k8syaml.YAMLToJSON([]byte(patch))
219-
if err != nil {
220-
return "", fmt.Errorf("unable to convert patch yaml to json: %w", err)
221-
}
222-
result, err := jsonpatch.MergePatch(originalJSON, patchJSON)
223-
if err != nil {
224-
return "", fmt.Errorf("unable to patch configuration: %w", err)
225-
}
226-
resultYAML, err := k8syaml.JSONToYAML(result)
227-
if err != nil {
228-
return "", fmt.Errorf("unable to convert result json to yaml: %w", err)
229-
}
230-
return string(resultYAML), nil
231-
}
232-
233175
// ConfigStatus defines the observed state of Config
234176
type ConfigStatus struct {
235177
}

0 commit comments

Comments
 (0)