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

cmd: add alpha view-cluster-manifest command #2408

Merged
merged 7 commits into from
Jul 11, 2023

Conversation

gsora
Copy link
Collaborator

@gsora gsora commented Jul 6, 2023

Moved some manifest load/store functions to manifest_tools.go and generalized them, so we can reuse code across multiple commands.

Closes #2381

category: feature
ticket: #2381

Moved some manifest load/store functions to `manifest_tools.go` and generalized them, so we can reuse code across multiple commands.
@gsora gsora self-assigned this Jul 6, 2023
@codecov
Copy link

codecov bot commented Jul 6, 2023

Codecov Report

Patch coverage: 53.03% and project coverage change: +0.10 🎉

Comparison is base (ffe4966) 53.67% compared to head (e4a0d49) 53.77%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2408      +/-   ##
==========================================
+ Coverage   53.67%   53.77%   +0.10%     
==========================================
  Files         196      198       +2     
  Lines       26326    26418      +92     
==========================================
+ Hits        14130    14207      +77     
- Misses      10441    10450       +9     
- Partials     1755     1761       +6     
Impacted Files Coverage Δ
cmd/cmd.go 80.16% <0.00%> (-0.67%) ⬇️
cmd/manifest_tools.go 39.28% <39.28%> (ø)
cmd/addvalidators.go 53.02% <46.66%> (+0.57%) ⬆️
cmd/view_cluster_manifest.go 59.09% <59.09%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

cmd/view_cluster_manifest.go Outdated Show resolved Hide resolved
cmd/view_cluster_manifest.go Outdated Show resolved Hide resolved
@gsora gsora requested a review from corverroos July 6, 2023 15:34
cmd/view_cluster_manifest.go Show resolved Hide resolved
Comment on lines 129 to 135
// if we're able to unmarshal in a map do it, otherwise hex encode and return
brJSON := make(map[string]any)
if err := json.Unmarshal(bytes, &brJSON); err != nil {
return "0x" + hex.EncodeToString(bytes)
}

return brJSON
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can replace with: return fmt.Sprint("%#x", bytes)

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, maybe this supports marshalling nested json fields

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if bytes contains valid json we return it unmarshaled in a map, otherwise its hex encoded representation - this code is here to give users plaintext validator registrations instead of a escaped string containing raw JSON

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i did replace hex.EncodeToString with the sprintf suggestion though

cmd/addvalidators.go Outdated Show resolved Hide resolved
@@ -46,6 +46,7 @@ func New() *cobra.Command {
newCombineCmd(newCombineFunc),
newAlphaCmd(
newAddValidatorsCmd(runAddValidatorsSolo),
newViewClusterManifestCmd(runViewClusterManifest),
Copy link
Contributor

@xenowits xenowits Jul 10, 2023

Choose a reason for hiding this comment

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

nit: fix indent if broken

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wdym?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nvm, when viewing the PR, i couldn't see a tab space

cmd/manifest_tools.go Outdated Show resolved Hide resolved
return viewClusterManifest(manifestFilePath, out)
}

func viewClusterManifest(manifestFilePath string, out io.Writer) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add godoc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed that function and replaced it with a plain runViewClusterManifest - I don't think this function needs godoc (isn't exported, meaning of the function is clear enough).

@gsora gsora added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jul 11, 2023
@obol-bulldozer obol-bulldozer bot merged commit 4e903ca into main Jul 11, 2023
12 checks passed
@obol-bulldozer obol-bulldozer bot deleted the gsora/view_cluster_manifest branch July 11, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add command to view cluster manifests
3 participants