diff --git a/states/etcd/download/distribution.go b/states/etcd/download/distribution.go index bbd9da0..bea7b49 100644 --- a/states/etcd/download/distribution.go +++ b/states/etcd/download/distribution.go @@ -29,6 +29,20 @@ func PullGlobalDistributionDetails(cli clientv3.KV, basePath string) *cobra.Comm return err } + fileName, err := cmd.Flags().GetString("file") + if err != nil { + return err + } + f, err := os.Create(fileName) + if err != nil { + return err + } + + defer f.Close() + + w := csv.NewWriter(f) + defer w.Flush() + for _, session := range sessions { opts := []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), @@ -77,19 +91,6 @@ func PullGlobalDistributionDetails(cli clientv3.KV, basePath string) *cobra.Comm return err } - fileName, err := cmd.Flags().GetString("file") - if err != nil { - return err - } - f, err := os.Create(fileName) - if err != nil { - return err - } - - defer f.Close() - w := csv.NewWriter(f) - defer w.Flush() - for _, segment := range segments { // serverID,collectionID,partitionID,segmentID,channelName,rowNum,state content := make([]string, 0)