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

Support for Dashboard Timeframe #21

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Conversation

shaswot77
Copy link
Contributor

Description

Added support for dashboard time frame

Checklist:

  • Added a label: bug-fix, feature, or enhancement
  • PR description written

@shaswot77 shaswot77 added the enhancement New feature or request label Dec 19, 2023
.vscode/settings.json Outdated Show resolved Hide resolved
@shaswot77 shaswot77 merged commit 80aa8f8 into main Dec 19, 2023
6 checks passed
@shaswot77 shaswot77 deleted the work/ss/dashboard-timeframe branch December 19, 2023 20:45
@@ -6,11 +6,12 @@ import (
"strings"
)

func (c *SquaredUpClient) CreateDashboard(displayName string, workspaceId string, dashboardContent string) (*Dashboard, error) {
func (c *SquaredUpClient) CreateDashboard(displayName string, workspaceId string, timeframe string, dashboardContent string) (*Dashboard, error) {

Choose a reason for hiding this comment

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

How does adding a required argument (timeframe) impact upgrades of Terraform provider versions? e.g. user upgrades to this version of provider and their Terraform deployment breaks as now they need to provide an extra string argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

timeframe is not a required argument. Its optional in internal/provider/resource_dashboard.go

@@ -86,6 +86,7 @@ type Dashboard struct {
Group string `json:"group,omitempty"`

Choose a reason for hiding this comment

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

We don't want to advertise Group (it was an old thing left over from Beacon days)

@@ -86,6 +86,7 @@ type Dashboard struct {
Group string `json:"group,omitempty"`
Name string `json:"name"`
SchemaVersion string `json:"schemaVersion"`

Choose a reason for hiding this comment

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

We don't want to advertise SchemaVersion (it's an internal thing used for dashboard migrations). Perhaps we need to strip SchemaVersion and Group from Dashobard reads (GETs) too.

@@ -36,6 +38,7 @@ type squaredupDashboard struct {
DashboardTemplate jsontypes.Normalized `tfsdk:"dashboard_template"`
TemplateBindings jsontypes.Normalized `tfsdk:"template_bindings"`
DashboardContent jsontypes.Normalized `tfsdk:"dashboard_content"`
Timeframe types.String `tfsdk:"timeframe"`
Group types.String `tfsdk:"group"`
Name types.String `tfsdk:"name"`
SchemaVersion types.String `tfsdk:"schema_version"`

Choose a reason for hiding this comment

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

Ditto previous comment on SchemaVersion and Group

@@ -269,6 +292,7 @@ func (r *DashboardResource) Update(ctx context.Context, req resource.UpdateReque
DashboardTemplate: plan.DashboardTemplate,
TemplateBindings: plan.TemplateBindings,
DashboardContent: jsontypes.NewNormalizedValue(updatedDashboard),
Timeframe: types.StringValue(dashboard.Timeframe),
Group: types.StringValue(dashboard.Group),
Name: types.StringValue(dashboard.Name),
SchemaVersion: types.StringValue(dashboard.SchemaVersion),

Choose a reason for hiding this comment

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

Ditto previous comments on SchemaVersion and Group (both fields are referened in a few other places in this repo I haven't commented on too as not changed in this PR)

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 will do a cleanup of these based on our new API documentation. I have raised a JIRA for this

Choose a reason for hiding this comment

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

I will do a cleanup of these based on our new API documentation. I have raised a JIRA for this

Thanks @shaswot77

"timeframe": schema.StringAttribute{
Description: "The timeframe of the dashboard. It should be one of the following: last1hour, last12hours, last24hours, last7days, last30days, thisMonth, thisQuarter, thisYear, lastMonth, lastQuarter, lastYear",
Optional: true,
Computed: true,
Copy link

@wigsaparelli wigsaparelli Dec 20, 2023

Choose a reason for hiding this comment

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

Why is timeframe marked as Computed (in fact lots of attribs are - obviously doesn't mean what I think it does)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its to handle null value as its marked as optional.

Choose a reason for hiding this comment

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

Its to handle null value as its marked as optional.

Ah, ta, so what value will it compute when null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just an empty string "". Because terraform store states based on response it expect some value than null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants