Skip to content

Commit

Permalink
update version checking for iba dashboard(s) data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Sep 25, 2024
1 parent c8b8fd5 commit 44b0830
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
20 changes: 6 additions & 14 deletions apstra/data_source_blueprint_iba_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ func (o *dataSourceBlueprintIbaDashboard) Schema(_ context.Context, _ datasource
}
}

func (o *dataSourceBlueprintIbaDashboard) ValidateConfig(ctx context.Context, req datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) {
// Retrieve values from config.
var config iba.Dashboard
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
}

// cannot proceed to config + api version validation if the provider has not been configured
func (o *dataSourceBlueprintIbaDashboard) ValidateConfig(_ context.Context, _ datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) {
// cannot proceed to api version validation if the provider has not been configured
if o.client == nil {
return
}
Expand All @@ -62,7 +55,6 @@ func (o *dataSourceBlueprintIbaDashboard) ValidateConfig(ctx context.Context, re
"Incompatible API version",
"This data source is compatible only with Apstra "+compatibility.BpIbaDashboardOk.String(),
)
return
}
}

Expand Down Expand Up @@ -127,11 +119,11 @@ func (o *dataSourceBlueprintIbaDashboard) Read(ctx context.Context, req datasour
resp.Diagnostics.Append(resp.State.Set(ctx, &config)...)
}

func (o *dataSourceBlueprintIbaDashboard) setBpClientFunc(f func(context.Context, string) (*apstra.TwoStageL3ClosClient, error)) {
o.getBpClientFunc = f
}

// setClient is used for API version compatibility check only
func (o *dataSourceBlueprintIbaDashboard) setClient(client *apstra.Client) {
o.client = client
}

func (o *dataSourceBlueprintIbaDashboard) setBpClientFunc(f func(context.Context, string) (*apstra.TwoStageL3ClosClient, error)) {
o.getBpClientFunc = f
}
13 changes: 1 addition & 12 deletions apstra/data_source_blueprint_iba_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@ func (o *dataSourceBlueprintIbaDashboards) Schema(_ context.Context, _ datasourc
}
}

func (o *dataSourceBlueprintIbaDashboards) ValidateConfig(ctx context.Context, req datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) {
var config struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Ids types.Set `tfsdk:"ids"`
}

// Retrieve values from config.
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
}

func (o *dataSourceBlueprintIbaDashboards) ValidateConfig(_ context.Context, _ datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) {
// cannot proceed to config + api version validation if the provider has not been configured
if o.client == nil {
return
Expand Down

0 comments on commit 44b0830

Please sign in to comment.