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

Redact empty status properties #3180

Merged
merged 3 commits into from
Aug 6, 2023

Conversation

theunrepentantgeek
Copy link
Member

@theunrepentantgeek theunrepentantgeek commented Aug 4, 2023

What this PR does / why we need it:

When importing an Azure resource, we have been getting an empty status section in the output, which isn't necessary.

  ...
  powerState:
    code: Running
  type: Microsoft.ContainerService/managedClusters/agentPools
  vmSize: Standard_D8ds_v5
status: {}
---
Import Azure Resources  [==============================] 100 %

This PR redacts that wart to make things cleaner:

  powerState:
    code: Running
  type: Microsoft.ContainerService/managedClusters/agentPools
  vmSize: Standard_D8ds_v5

---
Import Azure Resources  [==============================] 100 %

Special notes for your reviewer:

Also fixes a minor bug where the output was being sent to the wrong stream, giving weird results on screen.

How does this PR make you feel:
gif

@codecov-commenter
Copy link

Codecov Report

Merging #3180 (69520dc) into main (11f4803) will decrease coverage by 0.01%.
Report is 3 commits behind head on main.
The diff coverage is 85.55%.

@@            Coverage Diff             @@
##             main    #3180      +/-   ##
==========================================
- Coverage   54.38%   54.37%   -0.01%     
==========================================
  Files        1419     1419              
  Lines      604182   604177       -5     
==========================================
- Hits       328557   328522      -35     
- Misses     221948   221969      +21     
- Partials    53677    53686       +9     
Files Changed Coverage Δ
...i/cdn/v1api20210601/profiles_endpoint_types_gen.go 45.51% <ø> (ø)
.../cdn/v1beta20210601/profiles_endpoint_types_gen.go 51.88% <ø> (-0.07%) ⬇️
...beta20210601storage/profiles_endpoint_types_gen.go 62.33% <ø> (ø)
...api20201201/virtual_machine_scale_set_types_gen.go 54.72% <ø> (ø)
...compute/v1api20201201/virtual_machine_types_gen.go 51.96% <ø> (ø)
...1201storage/virtual_machine_scale_set_types_gen.go 68.82% <ø> (-0.23%) ⬇️
.../v1api20201201storage/virtual_machine_types_gen.go 65.11% <ø> (-0.29%) ⬇️
v2/api/compute/v1api20210701/image_types_gen.go 54.51% <ø> (-1.13%) ⬇️
...pi/compute/v1api20210701storage/image_types_gen.go 61.03% <ø> (ø)
v2/api/compute/v1api20220301/image_types_gen.go 49.46% <ø> (ø)
... and 155 more

... and 20 files with indirect coverage changes

@@ -138,3 +141,10 @@ func (*ResourceImportResult) writeTo(resources []genruntime.MetaObject, destinat

return nil
}

// redact removes any empty `status { }` blocks from the yaml
func redact(data []byte) []byte {
Copy link
Member

Choose a reason for hiding this comment

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

minor: redactStatus? Since it doesn't generally redact "other stuff"?

@theunrepentantgeek theunrepentantgeek enabled auto-merge (squash) August 6, 2023 20:55
@theunrepentantgeek theunrepentantgeek merged commit b4e626b into main Aug 6, 2023
@theunrepentantgeek theunrepentantgeek deleted the improve/asoctl-resource-output branch August 6, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants