Skip to content

Commit 987a70a

Browse files
committed
fix(dvb): resolve CI lint errors
- Fix rangeValCopy lint errors in delete.go by using index-based iteration instead of value copy (avoids copying 192 bytes per iteration) - Fix gofmt formatting in apply.go and main.go - Alias sigs.k8s.io/yaml import to k8syaml to avoid package name collision with gopkg.in/yaml.v3 used in diff.go
1 parent 11f2095 commit 987a70a

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

cmd/dvb/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func applyDevnet(cmd *cobra.Command, devnet *config.YAMLDevnet) (*v1.ApplyDevnet
128128
// yamlToProtoSpec converts YAML spec to proto DevnetSpec
129129
func yamlToProtoSpec(yamlSpec *config.YAMLDevnetSpec) *v1.DevnetSpec {
130130
spec := &v1.DevnetSpec{
131-
Plugin: yamlSpec.Network, // YAML uses "network", proto uses "plugin"
131+
Plugin: yamlSpec.Network, // YAML uses "network", proto uses "plugin"
132132
NetworkType: yamlSpec.NetworkType,
133133
Validators: int32(yamlSpec.Validators),
134134
FullNodes: int32(yamlSpec.FullNodes),

cmd/dvb/delete.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func runDeleteFromFile(cmd *cobra.Command, filePath string, force, dryRun bool)
8686
// Preview mode
8787
if dryRun {
8888
fmt.Printf("Would delete %d devnet(s):\n", len(devnets))
89-
for _, d := range devnets {
90-
fmt.Printf(" - devnet/%s\n", d.Metadata.Name)
89+
for i := range devnets {
90+
fmt.Printf(" - devnet/%s\n", devnets[i].Metadata.Name)
9191
}
9292
fmt.Println("\nRun without --dry-run to delete.")
9393
return nil
@@ -96,8 +96,8 @@ func runDeleteFromFile(cmd *cobra.Command, filePath string, force, dryRun bool)
9696
// Confirm if not forced
9797
if !force {
9898
fmt.Printf("This will delete %d devnet(s):\n", len(devnets))
99-
for _, d := range devnets {
100-
fmt.Printf(" - devnet/%s\n", d.Metadata.Name)
99+
for i := range devnets {
100+
fmt.Printf(" - devnet/%s\n", devnets[i].Metadata.Name)
101101
}
102102
fmt.Print("\nAre you sure? [y/N] ")
103103
var response string
@@ -114,8 +114,8 @@ func runDeleteFromFile(cmd *cobra.Command, filePath string, force, dryRun bool)
114114

115115
// Delete each devnet
116116
var hasErrors bool
117-
for _, d := range devnets {
118-
name := d.Metadata.Name
117+
for i := range devnets {
118+
name := devnets[i].Metadata.Name
119119
err := daemonClient.DeleteDevnet(cmd.Context(), name)
120120
if err != nil {
121121
color.Red("devnet/%s deletion failed: %v", name, err)

cmd/dvb/get.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
v1 "github.com/altuslabsxyz/devnet-builder/api/proto/gen/v1"
1111
"github.com/fatih/color"
1212
"github.com/spf13/cobra"
13-
"sigs.k8s.io/yaml"
13+
k8syaml "sigs.k8s.io/yaml"
1414
)
1515

1616
func newGetCmd() *cobra.Command {
@@ -114,7 +114,7 @@ func listDevnets(cmd *cobra.Command, output, labelSel string) error {
114114
if i > 0 {
115115
fmt.Println("---")
116116
}
117-
out, err := yaml.Marshal(protoDevnetToYAML(d))
117+
out, err := k8syaml.Marshal(protoDevnetToYAML(d))
118118
if err != nil {
119119
return fmt.Errorf("failed to marshal yaml: %w", err)
120120
}
@@ -172,7 +172,7 @@ func getDevnet(cmd *cobra.Command, name, output string, showNodes bool) error {
172172
// Handle yaml/json output
173173
switch output {
174174
case "yaml":
175-
out, err := yaml.Marshal(protoDevnetToYAML(devnet))
175+
out, err := k8syaml.Marshal(protoDevnetToYAML(devnet))
176176
if err != nil {
177177
return fmt.Errorf("failed to marshal yaml: %w", err)
178178
}
@@ -322,7 +322,7 @@ func protoDevnetToYAML(d *v1.Devnet) *YAMLDevnetOutput {
322322
Annotations: d.Metadata.Annotations,
323323
},
324324
Spec: YAMLDevnetSpecOutput{
325-
Network: d.Spec.Plugin, // proto uses Plugin, YAML uses network
325+
Network: d.Spec.Plugin, // proto uses Plugin, YAML uses network
326326
NetworkType: d.Spec.NetworkType,
327327
NetworkVersion: d.Spec.SdkVersion, // proto uses SdkVersion, YAML uses networkVersion
328328
Validators: d.Spec.Validators,

cmd/dvb/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func main() {
6363
newGetCmd(),
6464
newDeleteCmd(),
6565
newDiffCmd(),
66-
newDeployCmd(), // deprecated
66+
newDeployCmd(), // deprecated
6767
newListCmd(),
6868
newStatusCmd(),
6969
newStartCmd(),

0 commit comments

Comments
 (0)