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(usage-view): download usage data in csv format #214

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

mwasilew2
Copy link
Contributor

related to: https://app.clickup.com/t/8693k73r6

Adds support for downloading usage view data in csv format.

@Clickup-user
Copy link

@mwasilew2 mwasilew2 force-pushed the CU-8693k73r6-usage-view-csv-download branch from ea9b1af to a4b3ac0 Compare January 24, 2024 16:09
Signed-off-by: Michal Wasilewski <michal@mwasilewski.net>
@mwasilew2 mwasilew2 force-pushed the CU-8693k73r6-usage-view-csv-download branch from 1da3dc6 to 24c879b Compare January 24, 2024 16:30
@mwasilew2 mwasilew2 marked this pull request as ready for review January 24, 2024 16:33
internal/cmd/profile/usage_view_csv_command.go Outdated Show resolved Hide resolved

// save response to a file
var filePath string
if !ctx.IsSet(flagUsageViewCSVFile.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is not set, we could just print to stdout. My reasoning is one could just call it like spacectl profile usage-view-csv > myfile.csv, it would also be possible to do additional modifications on the fly if this was possible.

One thing that makes this not great is that we also print things like log.Println("Querying Spacelift for usage data...")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess a global logging flag would be helpful here. Since we don't have that, what we can do is write csv file to stdout and print messages to stderr. Although that would be inconsistent with how it's done in other parts of the project. Let me know what you think.

Copy link
Contributor

@tomasmik tomasmik Jan 25, 2024

Choose a reason for hiding this comment

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

I guess a global logging flag would be helpful here.

I guess, we should maybe create an issue for this.

Let me know what you think.

I had the idea myself, but didnt suggest it because it is inconsistent. Honestly I have no strong feeling for this. You can merge the code as is. Don't want to block you.

internal/cmd/profile/usage_view_csv_command.go Outdated Show resolved Hide resolved
internal/cmd/profile/usage_view_csv_command.go Outdated Show resolved Hide resolved
Signed-off-by: Michal Wasilewski <michal@mwasilewski.net>
@mwasilew2 mwasilew2 merged commit 0bb042f into main Jan 25, 2024
9 checks passed
@mwasilew2 mwasilew2 deleted the CU-8693k73r6-usage-view-csv-download branch January 25, 2024 13:27
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