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
4 changes: 2 additions & 2 deletions cmd/elastic-cloud/delete-stale.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"time"

"github.com/dpc-sdp/bay-cli/internal/helpers"
elasticsearch "github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/go-elasticsearch/v8/esapi"
elasticsearch "github.com/elastic/go-elasticsearch/v9"
"github.com/elastic/go-elasticsearch/v9/esapi"
"github.com/manifoldco/promptui"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
Expand Down
43 changes: 24 additions & 19 deletions cmd/elastic-cloud/unassigned-shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/json"
"fmt"

elasticsearch "github.com/elastic/go-elasticsearch/v8"
"github.com/elastic/go-elasticsearch/v8/esapi"
elasticsearch "github.com/elastic/go-elasticsearch/v9"
"github.com/elastic/go-elasticsearch/v9/esapi"
errors "github.com/pkg/errors"
"github.com/urfave/cli/v2"
)
Expand All @@ -27,26 +27,31 @@ func ListUnassignedShards(c *cli.Context) error {
return err
}
shards, err := esapi.CatShardsRequest{Format: "json", FilterPath: []string{"index", "shard", "state"}}.Do(context.Background(), client)

shardsList := Shards{}
unassignedShards := Shards{}

if err := json.NewDecoder(shards.Body).Decode(&shardsList); err != nil {
return errors.Wrap(err, "Error parsing the response body")
} else {
for _, s := range shardsList {
if s.State == "UNASSIGNED" {
unassignedShards = append(unassignedShards, s)
if err != nil {
return err
}
if shards != nil {
shardsList := Shards{}
unassignedShards := Shards{}

if err := json.NewDecoder(shards.Body).Decode(&shardsList); err != nil {
return errors.Wrap(err, "Error parsing the response body")
} else {
for _, s := range shardsList {
if s.State == "UNASSIGNED" {
unassignedShards = append(unassignedShards, s)
}
}
}

if err != nil {
return err
}
if err != nil {
return err
}

json, _ := json.Marshal(unassignedShards)
fmt.Printf("%s", json)
json, _ := json.Marshal(unassignedShards)
fmt.Printf("%s", json)

return nil
return nil
}
}
return errors.New("no unassigned shards found")
}
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/alexeyco/simpletable v1.0.0
github.com/aws/aws-sdk-go-v2/config v1.29.17
github.com/aws/aws-sdk-go-v2/service/kms v1.41.1
github.com/elastic/go-elasticsearch/v8 v8.18.1
github.com/elastic/go-elasticsearch/v9 v9.0.0
github.com/go-git/go-git/v5 v5.16.2
github.com/manifoldco/promptui v0.9.0
Expand All @@ -17,7 +16,6 @@ require (
github.com/uselagoon/machinery v0.0.34
golang.org/x/crypto v0.39.0
gopkg.in/yaml.v3 v3.0.1
sigs.k8s.io/controller-runtime v0.21.0
)

require (
Expand Down Expand Up @@ -54,6 +52,7 @@ require (
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/machinebox/graphql v0.2.2 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/onsi/gomega v1.36.1 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -64,11 +63,9 @@ require (
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/sdk v1.33.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/tools v0.26.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
Loading