Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
module github.com/longhorn/cli

go 1.26.0
go 1.27.0

require (
github.com/dustin/go-humanize v1.1.0
github.com/longhorn/go-common-libs v0.0.0-20260909075701-1a37e0e5083e
github.com/longhorn/longhorn-engine v1.13.0-rc2
github.com/longhorn/longhorn-manager v1.12.1
github.com/longhorn/sparse-tools v0.0.0-20260423074222-280e61de741a
github.com/longhorn/sparse-tools v0.0.0-20261022004111-a7caacc40965
github.com/otiai10/copy v1.14.1
github.com/pkg/errors v0.9.1
github.com/rancher/go-fibmap v0.0.0-20160418233256-5fc9f8c1ed47
github.com/sirupsen/logrus v1.10.2
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.12.1
go.yaml.in/yaml/v3 v3.0.5
golang.org/x/sys v0.50.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.37.1
k8s.io/apimachinery v0.37.1
k8s.io/cli-runtime v0.37.1
k8s.io/client-go v0.37.1
k8s.io/kubectl v0.37.1
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3
sigs.k8s.io/kustomize/kyaml v0.21.2
k8s.io/api v0.37.2
k8s.io/apimachinery v0.37.2
k8s.io/cli-runtime v0.37.2
k8s.io/client-go v0.37.2
k8s.io/kubectl v0.37.2
k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab
)

require (
Expand Down Expand Up @@ -111,7 +111,6 @@ require (
github.com/xlab/treeprint v1.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/crypto v0.59.0 // indirect
golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a // indirect
golang.org/x/net v0.62.0 // indirect
Expand All @@ -127,14 +126,15 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
howett.net/plist v1.0.1 // indirect
k8s.io/component-base v0.37.1 // indirect
k8s.io/component-helpers v0.37.1 // indirect
k8s.io/component-base v0.37.2 // indirect
k8s.io/component-helpers v0.37.2 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad // indirect
k8s.io/mount-utils v0.36.4 // indirect
k8s.io/streaming v0.37.1 // indirect
k8s.io/streaming v0.37.2 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/kustomize/api v0.21.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.21.1 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.4.2 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
Expand All @@ -143,6 +143,6 @@ require (
replace (
// align to longhorn-manager's beszel version
github.com/henrygd/beszel => github.com/longhorn/beszel v0.16.2-0.20260114090315-332709c32c7d
k8s.io/cloud-provider => k8s.io/cloud-provider v0.37.1
k8s.io/kubelet => k8s.io/kubelet v0.37.1
k8s.io/cloud-provider => k8s.io/cloud-provider v0.37.2
k8s.io/kubelet => k8s.io/kubelet v0.37.2
)
44 changes: 22 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ github.com/longhorn/longhorn-engine v1.13.0-rc2 h1:dPxUKXEAYy2mkQ7C8H3PfwzKO9/O2
github.com/longhorn/longhorn-engine v1.13.0-rc2/go.mod h1:4qUkcCdWfnaKD25+EL0YrW3AjOMn0/9BnRmPCu6oS/s=
github.com/longhorn/longhorn-manager v1.12.1 h1:ncrTZUxXCpXvzWOhPbzdFCRk2Lp6pZfP3UMbyCY+z2E=
github.com/longhorn/longhorn-manager v1.12.1/go.mod h1:msD+SdP1rvEqhPEFbuxAXw8HBePREwVKkMoF7kUhoJk=
github.com/longhorn/sparse-tools v0.0.0-20260423074222-280e61de741a h1:xb71oeVPI7XZymAAG8ts5deC8s40dnX5IgxTYAB/qnk=
github.com/longhorn/sparse-tools v0.0.0-20260423074222-280e61de741a/go.mod h1:d8l9nyC8No3PIfYHwZunnBj88y5M4sDM+h6uZyTtaNk=
github.com/longhorn/sparse-tools v0.0.0-20261022004111-a7caacc40965 h1:082mjqY6STBnO4SEN7DBG+NubfUeyMlgwEQhOxC6T1o=
github.com/longhorn/sparse-tools v0.0.0-20261022004111-a7caacc40965/go.mod h1:d8l9nyC8No3PIfYHwZunnBj88y5M4sDM+h6uZyTtaNk=
github.com/longhorn/types v0.0.0-20260810232958-141f76734364 h1:OwnsjatjbLF+D4MtlQjfc7G6MK5uIiY8ac7/ePypRsA=
github.com/longhorn/types v0.0.0-20260810232958-141f76734364/go.mod h1:fmaMw+kNcCfoil6w9VNlEmXzBWIpZpofb2FvmxQFA8A=
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k=
Expand Down Expand Up @@ -336,36 +336,36 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM=
howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
k8s.io/api v0.37.1 h1:l6N77U7tjwB5L056bgrBTJIEdevac/naBZ3iSvDNfpM=
k8s.io/api v0.37.1/go.mod h1:zSlbB1YpJ1YQlFVQy20UYll81UJSJJUMLhkhvg6Z78M=
k8s.io/apimachinery v0.37.1 h1:hGCYyvKHCwtwMitj2vU4vYx0Z16N9GyZk9BBnz0wDAE=
k8s.io/apimachinery v0.37.1/go.mod h1:jF84AyUi/IRIXRot5f+lm6MpxoWI+F1XgjaMmwCdTFw=
k8s.io/cli-runtime v0.37.1 h1:3mir5bM4XjMJHW3SMRk++3Ylf4YQne0XFFsW+IGT85U=
k8s.io/cli-runtime v0.37.1/go.mod h1:g3VQOm71f//aNbp79g0az9jBRTrvPjAHz7WxVysbZ4M=
k8s.io/client-go v0.37.1 h1:QTv/5ha4jAHtW9qxxVBkQVFBRDb4jHfFopQqqMdc+wM=
k8s.io/client-go v0.37.1/go.mod h1:dnAPtTnCNY38Ho04D2KdY1F4IKausa9UbqaAZKl60SY=
k8s.io/component-base v0.37.1 h1:93DMmlENnK7gNLkL4pMqLO5M/HVf3p3sM4q/GasLveY=
k8s.io/component-base v0.37.1/go.mod h1:bBrdziT4dreQG5lzTaPVxBwsZe1oxphG+ZVdD56dQWQ=
k8s.io/component-helpers v0.37.1 h1:V6ueiH2SBqpZil1X9+uMK8GAwsGYPVfoRN9eA5vY2G8=
k8s.io/component-helpers v0.37.1/go.mod h1:Ib5+txJA7lG9/xCdRrPshX8GnRRTXPElxtxo+bFQ0Y8=
k8s.io/api v0.37.2 h1:PnxqnUFy93jr2GcpWDkKOm8wfy25kT9wa572MuQS8oc=
k8s.io/api v0.37.2/go.mod h1:+NVRLft99kx+Jg9v34GmHw867Dapim89TSyCsn2hK+M=
k8s.io/apimachinery v0.37.2 h1:G4t9RGoPDbQML38hz/kQQiltttgd3egg2ODCR8aIc2o=
k8s.io/apimachinery v0.37.2/go.mod h1:qaAvSNvgU2x07wRM95MSHSJTPQ/ob/LeNAGbeDgqQJg=
k8s.io/cli-runtime v0.37.2 h1:EpE50B2FmXz8SxkYqoS2q0piDk1qe7g9dGZGIW+apws=
k8s.io/cli-runtime v0.37.2/go.mod h1:0IDMrrzVnj1cqBlCll8oGSOb2js6mSy0ALtbh0MsYyc=
k8s.io/client-go v0.37.2 h1:sgFtyRZukGkOrsu+QgS7LYnbFFJ5ut3MchdBNduD//E=
k8s.io/client-go v0.37.2/go.mod h1:bo3LFC8YbCtKFPX21Yj8puMsoJLAv/+SvuOODma0s54=
k8s.io/component-base v0.37.2 h1:Ia9IKTg1yWrUntJU5lVetapkC9pXlLg9L6P3R1IkbcY=
k8s.io/component-base v0.37.2/go.mod h1:qq+ueHZyLfzRJzxyDoyxHWNhF1JPv4zm3hcaddXWDvY=
k8s.io/component-helpers v0.37.2 h1:TQBsmHFs8gpfiyPFvyMaxqTgojtcXR2mVj+knnycln0=
k8s.io/component-helpers v0.37.2/go.mod h1:HZMT6lvkix4wkgYYXZJ/45BbYM1TZoOlANisHn7FoVY=
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0=
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad h1:oXImqH8mQNk7PmvzKhmN3ddJoY6OnyM225MXwGHPm0A=
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad/go.mod h1:0/mqHCVhlumdJ3BhCfnjSZQE037nAhNodh1/hK0T8/I=
k8s.io/kubectl v0.37.1 h1:n1VCIntOJiX943uByXCThSZQmE+4v9jGS8S9u94/aHU=
k8s.io/kubectl v0.37.1/go.mod h1:66cc4Bz8PxBTxlrHzBuzXEzGIytAnNasKQPeEcpuaV8=
k8s.io/kubectl v0.37.2 h1:AGGIhrGSsXtrL6BZWf7Hp2K9yB+2qdx7wovsOP1MiCg=
k8s.io/kubectl v0.37.2/go.mod h1:0nyX9up426PgGMcGkWjF1DeipLkd41eKZHoLDgop20k=
k8s.io/mount-utils v0.36.4 h1:dmCrrFDdcj56q1GuHJw228Ri62iBzMvt8PbPFHS91pA=
k8s.io/mount-utils v0.36.4/go.mod h1:f4k8GAu4zHwLuBqdyAHTNG2I7rAey5B+Zr3UI7HoNfE=
k8s.io/streaming v0.37.1 h1:TpzVfQeFuVndn2g9mFqxy1UcUYPwDzqjUmwR/IzJCWc=
k8s.io/streaming v0.37.1/go.mod h1:APlJR26ZWRcVy5bIEj0QRrKUXROtBHPcxl2NT7EAzPU=
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3 h1:jVkFFVfXdXP74B/zbO3hM3hpSFD0xvhQ5U686DPurkE=
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3/go.mod h1:M2s5JB1lIYP3jzZdorPLHXIPJzt9vv2muW5a6L9DtNM=
k8s.io/streaming v0.37.2 h1:xmzp9nbqIbjvsRcqrBYa+K5XPQ6Jy/Dm3zZ8mN916AI=
k8s.io/streaming v0.37.2/go.mod h1:APlJR26ZWRcVy5bIEj0QRrKUXROtBHPcxl2NT7EAzPU=
k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab h1:pjQrNLaF//ytZtWwCAHtW+pqwSKjtWDqzA8+TCX37RI=
k8s.io/utils v0.0.0-20261023123148-ca04ba58ecab/go.mod h1:DdQ0BJxlQtuMlKDqdg7X5IMMQCXIk2b3d1/4M9OhUYo=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/kustomize/api v0.21.1 h1:lzqbzvz2CSvsjIUZUBNFKtIMsEw7hVLJp0JeSIVmuJs=
sigs.k8s.io/kustomize/api v0.21.1/go.mod h1:f3wkKByTrgpgltLgySCntrYoq5d3q7aaxveSagwTlwI=
sigs.k8s.io/kustomize/kyaml v0.21.2 h1:1javwStFk7cgOeLU7yJtPmXcgMEhQgC2X0WjFT6U0p0=
sigs.k8s.io/kustomize/kyaml v0.21.2/go.mod h1:zX3qwtuouXd2K1fMiCV0VSFReX06a+CY1rhyf5Dy7hQ=
sigs.k8s.io/kustomize/kyaml v0.21.1 h1:IVlbmhC076nf6foyL6Taw4BkrLuEsXUXNpsE+ScX7fI=
sigs.k8s.io/kustomize/kyaml v0.21.1/go.mod h1:hmxADesM3yUN2vbA5z1/YTBnzLJ1dajdqpQonwBL1FQ=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v6 v6.4.2 h1:qdOxHwrl2Kaag1aQEarlYcOA9vSyGCp3CIki3aW8c4Q=
Expand Down
5 changes: 2 additions & 3 deletions pkg/remote/diagnose/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (

"github.com/pkg/errors"

"sigs.k8s.io/kustomize/kyaml/yaml"

"github.com/longhorn/cli/pkg/types"
"github.com/longhorn/cli/pkg/utils"
)

const (
Expand Down Expand Up @@ -80,7 +79,7 @@ func (results Results) Failed() []string {
func (results Results) Marshal(format string) ([]byte, error) {
switch format {
case OutputFormatYAML:
return yaml.Marshal(results)
return utils.MarshalYAML(results)
case OutputFormatJSON:
output, err := json.MarshalIndent(results, "", " ")
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/remote/preflight/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/pkg/errors"

"k8s.io/utils/ptr"
"sigs.k8s.io/kustomize/kyaml/yaml"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -122,7 +121,7 @@ func (remote *Checker) Run() (string, error) {
return "", nil
}

yamlData, err := yaml.Marshal(nodeCollections)
yamlData, err := utils.MarshalYAML(nodeCollections)
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/remote/preflight/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/sirupsen/logrus"

"k8s.io/utils/ptr"
"sigs.k8s.io/kustomize/kyaml/yaml"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -214,7 +213,7 @@ func (remote *Installer) InstallByPackageManager() (string, error) {
return "", nil
}

yamlData, err := yaml.Marshal(nodeCollections)
yamlData, err := utils.MarshalYAML(nodeCollections)
if err != nil {
return "", err
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/utils/common.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
package utils

import (
"bytes"
"path"
"strings"

"go.yaml.in/yaml/v3"
)

// MarshalYAML encodes v as YAML using 2-space indentation and compact sequence indentation.
func MarshalYAML(v any) ([]byte, error) {
var buf bytes.Buffer
enc := yaml.NewEncoder(&buf)
enc.SetIndent(2)
enc.CompactSeqIndent()
if err := enc.Encode(v); err != nil {
return nil, err
}
if err := enc.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}

// BuildImageName returns an image name with the given global registry prepended.
// If no global registry is provided, the original image string is returned unchanged.
func BuildImageName(image, globalRegistry string) string {
Expand Down
17 changes: 16 additions & 1 deletion pkg/utils/common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package utils

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestBuildImageName(t *testing.T) {
for testName, testCase := range map[string]struct {
Expand All @@ -18,3 +23,13 @@ func TestBuildImageName(t *testing.T) {
})
}
}

func TestMarshalYAML(t *testing.T) {
type sample struct {
Name string `yaml:"name"`
Items []string `yaml:"items"`
}
out, err := MarshalYAML([]sample{{Name: "first", Items: []string{"a", "b"}}})
require.NoError(t, err)
assert.Equal(t, "- name: first\n items:\n - a\n - b\n", string(out))
}
44 changes: 38 additions & 6 deletions vendor/github.com/longhorn/sparse-tools/sparse/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading