Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: VEC-185 allow index definitions in yaml as input and output #8

Merged
merged 11 commits into from
Aug 6, 2024

Conversation

jdogmcsteezy
Copy link

The following 3 cmds will now work:

  1. asvec index list --yaml > indexDef.yaml
  2. cat indexDef.yaml | asvec index create
  3. asvec index create --file indexDef.yaml

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 81.46341% with 38 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@ff48bea). Learn more about missing BASE report.

Files Patch % Lines
cmd/indexCreate.go 85.14% 19 Missing and 7 partials ⚠️
cmd/indexList.go 60.00% 9 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main       #8   +/-   ##
=======================================
  Coverage        ?   79.55%           
=======================================
  Files           ?       34           
  Lines           ?     1996           
  Branches        ?        0           
=======================================
  Hits            ?     1588           
  Misses          ?      344           
  Partials        ?       64           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dwelch-spike dwelch-spike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a single nit

Comment on lines 142 to 171
if err != io.EOF {
logger.Error("failed to unmarshal index definitions", slog.Any("error", err))
return err
}

logger.Debug("read index definitions from stdin", slog.Any("data", data))

// Unmarshal YAML data
intermediate := map[string]interface{}{}
err = yaml.Unmarshal([]byte(data), &intermediate)
if err != nil {
logger.Error("failed to unmarshal index definitions", slog.Any("error", err))
return err
}

jsonBytes, err := json.Marshal(intermediate)
if err != nil {
logger.Error("failed to marshal index definitions", slog.Any("error", err))
return err
}

logger.Debug("marshalled index definitions", slog.Any("data", string(jsonBytes)))

stdinIndexDefinitions = &protos.IndexDefinitionList{}

err = protojson.Unmarshal(jsonBytes, stdinIndexDefinitions)
if err != nil {
logger.Error("failed to unmarshal index definitions", slog.Any("error", err))
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think these log lines should include what kind of marshaling/unmarshaling that failed so it's easier to tell which step failed from the logs.

@jdogmcsteezy jdogmcsteezy merged commit 8f1b95d into main Aug 6, 2024
5 checks passed
@jdogmcsteezy jdogmcsteezy deleted the VEC-185-yaml branch August 6, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants