feat: Add bucket schema management commands (#52)
* feat: update generated client to include schema-management APIs * feat: implement interfaces to decode flags and CSV * feat: implement decoders for different measurement schema column formats * feat: extend bucket CLI commands to support schema type property * feat: add CLI commands to manage measurement schema * test: add unit tests for bucket schema create, update and list commands
This commit is contained in:
28
internal/cmd/bucket_schema/nsjson.go
Normal file
28
internal/cmd/bucket_schema/nsjson.go
Normal file
@ -0,0 +1,28 @@
|
||||
package bucket_schema
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/internal/api"
|
||||
)
|
||||
|
||||
func decodeNDJson(r io.Reader) ([]api.MeasurementSchemaColumn, error) {
|
||||
scan := bufio.NewScanner(r)
|
||||
var rows []api.MeasurementSchemaColumn
|
||||
n := 1
|
||||
for scan.Scan() {
|
||||
if line := bytes.TrimSpace(scan.Bytes()); len(line) > 0 {
|
||||
var row api.MeasurementSchemaColumn
|
||||
if err := json.Unmarshal(line, &row); err != nil {
|
||||
return nil, fmt.Errorf("error decoding JSON at line %d: %w", n, err)
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
n++
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
Reference in New Issue
Block a user