Skip to content

Commit

Permalink
more review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kamieth committed Feb 14, 2024
1 parent 92c8178 commit 184002a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions builder/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ type Dashboard struct {
}

type DashboardBuilder struct {
resourceNames ResourceNames
resourceNames *ResourceNames
panelFactories []PanelFactory
orchestrator string
}

func NewDashboardBuilder(resourceNames ResourceNames, orchestrator string) *DashboardBuilder {
func NewDashboardBuilder(resourceNames *ResourceNames, orchestrator string) *DashboardBuilder {
return &DashboardBuilder{
resourceNames: resourceNames,
panelFactories: make([]PanelFactory, 0),
Expand Down Expand Up @@ -175,7 +175,7 @@ func (d *DashboardBuilder) Build() Dashboard {

func (d *DashboardBuilder) buildPanel(factory PanelFactory, x int, y int) Panel {
panelGridPos := NewPanelGridPos(PanelHeight, PanelWidth, x, y)
settings := newPaneSettings(d.resourceNames, panelGridPos, d.orchestrator)
settings := newPanelSettings(d.resourceNames, panelGridPos, d.orchestrator)
panel := factory(settings)

if panel.FieldConfig.Defaults.Custom.AxisPlacement == "" {
Expand Down
4 changes: 2 additions & 2 deletions builder/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestEcsDashboardWithError(t *testing.T) {
},
}

resourceNames := builder.ResourceNames{
resourceNames := &builder.ResourceNames{
CloudwatchNamespace: cloudwatchNamespace,
EcsCluster: ecsClusterName,
EcsService: ecsServiceName,
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestKubernetesDashboardWithError(t *testing.T) {
kubernetesPod := "pod"
var targetGroups []builder.ElbTargetGroup

resourceNames := builder.ResourceNames{
resourceNames := &builder.ResourceNames{
CloudwatchNamespace: cloudwatchNamespace,
EcsCluster: ecsClusterName,
EcsService: ecsServiceName,
Expand Down
4 changes: 2 additions & 2 deletions builder/panel.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package builder

func newPaneSettings(resourceNames ResourceNames, gridPos PanelGridPos, orchestrator string) PanelSettings {
func newPanelSettings(resourceNames *ResourceNames, gridPos PanelGridPos, orchestrator string) PanelSettings {
return PanelSettings{
resourceNames: resourceNames,
gridPos: gridPos,
Expand All @@ -9,7 +9,7 @@ func newPaneSettings(resourceNames ResourceNames, gridPos PanelGridPos, orchestr
}

type PanelSettings struct {
resourceNames ResourceNames
resourceNames *ResourceNames
gridPos PanelGridPos
orchestrator string
}
Expand Down
10 changes: 5 additions & 5 deletions provider/datasource_application_dashboard_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (a *ApplicationDashboardDefinitionDataSource) Read(ctx context.Context, req

var err error
var metadata *builder.MetadataApplication
var resourceNames builder.ResourceNames
var resourceNames *builder.ResourceNames

if metadata, err = a.metadataReader.ReadMetadata(state.AppId()); err != nil {
response.Diagnostics.AddError("can not get metadata", err.Error())
Expand Down Expand Up @@ -160,7 +160,7 @@ func (a *ApplicationDashboardDefinitionDataSource) Read(ctx context.Context, req
response.Diagnostics.Append(diags...)
}

func (a *ApplicationDashboardDefinitionDataSource) getResourceNames(ctx context.Context, state *ApplicationDashboardDefinitionData, response *tfsdk.ReadDataSourceResponse) (builder.ResourceNames, error) {
func (a *ApplicationDashboardDefinitionDataSource) getResourceNames(ctx context.Context, state *ApplicationDashboardDefinitionData, response *tfsdk.ReadDataSourceResponse) (*builder.ResourceNames, error) {
var err error

// Always available
Expand Down Expand Up @@ -190,15 +190,15 @@ func (a *ApplicationDashboardDefinitionDataSource) getResourceNames(ctx context.
targetGroups, ecsTaskDefinitionName, err = a.getEc2AndEcsData(ctx, response, ecsClusterName, ecsServiceName)

if err != nil {
return builder.ResourceNames{}, err
return nil, err
}
case orchestratorKubernetes:
kubernetesNamespace = builder.Augment(a.resourceNamePatterns.KubernetesNamespace, state.AppId())
kubernetesPod = builder.Augment(a.resourceNamePatterns.KubernetesPod, state.AppId())
traefikServiceName = builder.Augment(a.resourceNamePatterns.TraefikServiceName, state.AppId())
}

resourceNames := builder.ResourceNames{
resourceNames := &builder.ResourceNames{
CloudwatchNamespace: cloudwatchNamespace,
EcsCluster: ecsClusterName,
EcsService: ecsServiceName,
Expand Down Expand Up @@ -243,7 +243,7 @@ func (a *ApplicationDashboardDefinitionDataSource) getEc2AndEcsData(ctx context.
return targetGroups, *ecsTaskDefinitionName, err
}

func (a *ApplicationDashboardDefinitionDataSource) addHttpServers(metadata *builder.MetadataApplication, resourceNames builder.ResourceNames, db *builder.DashboardBuilder) {
func (a *ApplicationDashboardDefinitionDataSource) addHttpServers(metadata *builder.MetadataApplication, resourceNames *builder.ResourceNames, db *builder.DashboardBuilder) {
if len(metadata.HttpServers) == 0 {
return
}
Expand Down

0 comments on commit 184002a

Please sign in to comment.