Skip to content

Commit bd71bde

Browse files
yogesh-chauhanHarness
authored andcommitted
chore: [ML-1335]: code format existing files (#161)
* chore: [ML-1335]: code format existing files
1 parent f1713e2 commit bd71bde

36 files changed

+681
-680
lines changed

client/ar/ar_gen.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/ccmcommitments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (r *CloudCostManagementService) GetCommitmentMasterAccounts(ctx context.Con
162162

163163
listMasterAccountsResponse := new(dto.CCMCommitmentBaseResponse)
164164

165-
err := r.Client.Post(ctx, path, params, nil, map[string]string{},listMasterAccountsResponse)
165+
err := r.Client.Post(ctx, path, params, nil, map[string]string{}, listMasterAccountsResponse)
166166
if err != nil {
167167
return nil, fmt.Errorf("failed to get cloud cost managment master accounts with path %s: %w", path, err)
168168
}

client/ccmcommons/ccmconstants.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,27 @@ var OutputKeyValueFields = []map[string]string{
9292

9393
var OutputKeyFields = []map[string]string{
9494
{
95-
"fieldId": "labels.key",
96-
"fieldName": "",
97-
"identifier": "LABEL",
95+
"fieldId": "labels.key",
96+
"fieldName": "",
97+
"identifier": "LABEL",
9898
},
9999
{
100-
"fieldId": "labels.key2",
101-
"fieldName": "",
102-
"identifier": "LABEL_V2",
100+
"fieldId": "labels.key2",
101+
"fieldName": "",
102+
"identifier": "LABEL_V2",
103103
},
104104
}
105105

106-
var DefaultGroupBy = []map[string]any{
107-
{
108-
"entityGroupBy": map[string]any{
109-
"fieldId": "product",
110-
"fieldName": "Product",
111-
"identifier": "COMMON",
112-
"identifierName": "Common",
113-
},
106+
var DefaultGroupBy = []map[string]any{
107+
{
108+
"entityGroupBy": map[string]any{
109+
"fieldId": "product",
110+
"fieldName": "Product",
111+
"identifier": "COMMON",
112+
"identifierName": "Common",
114113
},
115-
}
114+
},
115+
}
116116

117117
var ConditionFieldDescriptions = []map[string]string{
118118
{
@@ -195,10 +195,10 @@ var ConditionKeyValueFieldDescriptions = []map[string]string{
195195
},
196196
{
197197
"fieldId": "label_v2",
198-
"description": labelV2Description,
198+
"description": labelV2Description,
199199
},
200200
{
201201
"fieldId": "business_mapping",
202-
"description": costCategoryDescription,
202+
"description": costCategoryDescription,
203203
},
204204
}

client/ccmcommons/ccmfilterhelper.go

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package ccmcommons
22

33
import (
4-
"time"
5-
"strings"
64
"encoding/json"
5+
"fmt"
76
"log/slog"
7+
"strings"
8+
"time"
9+
810
"github.com/harness/harness-mcp/client/dto"
9-
"fmt"
1011
)
1112

12-
func BuildFilters(viewId string ,timeFilters string, idFilters dto.CCMGraphQLFilters, keyValueFilters dto.CCMGraphQLKeyValueFilters) ([]map[string]any) {
13+
func BuildFilters(viewId string, timeFilters string, idFilters dto.CCMGraphQLFilters, keyValueFilters dto.CCMGraphQLKeyValueFilters) []map[string]any {
1314
filters := []map[string]any{}
14-
viewFilter := BuildViewFilter(viewId)
15+
viewFilter := BuildViewFilter(viewId)
1516
filters = append(filters, viewFilter...)
1617
filters = append(filters, BuildTimeFilters(timeFilters)...)
1718
filters = append(filters, BuildFieldFilters(idFilters, OutputFields)...)
@@ -24,39 +25,39 @@ func BuildViewFilter(viewId string) []map[string]any {
2425
return []map[string]any{
2526
{
2627
"viewMetadataFilter": map[string]any{
27-
"viewId": viewId,
28+
"viewId": viewId,
2829
"isPreview": false,
2930
},
3031
},
3132
}
3233
}
3334

34-
func BuildFilterValues(options *dto.CCMPerspectiveFilterValuesOptions) []map[string]any {
35+
func BuildFilterValues(options *dto.CCMPerspectiveFilterValuesOptions) []map[string]any {
3536
filters := []map[string]any{}
36-
viewFilter := BuildViewFilter(options.ViewId)
37+
viewFilter := BuildViewFilter(options.ViewId)
3738
filters = append(filters, viewFilter...)
3839
filters = append(filters, BuildTimeFilters(options.TimeFilter)...)
3940

40-
if options.ValueType == dto.ValueTypeCostCategory ||
41-
options.ValueType == dto.ValueTypeLabel ||
41+
if options.ValueType == dto.ValueTypeCostCategory ||
42+
options.ValueType == dto.ValueTypeLabel ||
4243
options.ValueType == dto.ValueTypeLabelV2 {
4344

4445
filter, err := BuildKeyValueFieldFilter(options.ValueType, options.ValueSubType, BuildOutputFieldsMap())
4546
if err == nil {
4647
filters = append(filters, filter...)
4748
}
48-
} else if options.ValueType == dto.ValueTypeLabelKey ||
49+
} else if options.ValueType == dto.ValueTypeLabelKey ||
4950
options.ValueType == dto.ValueTypeLabelV2Key {
5051
filter, err := BuildKeyFieldFilter(options.ValueType, BuildOutputFieldsMap())
5152
if err == nil {
5253
filters = append(filters, filter...)
5354
}
54-
55+
5556
} else {
5657
filter := BuildFieldFilters(buildFilterForValue(options.ValueType), OutputFields)
5758
filters = append(filters, filter...)
5859
}
59-
return filters
60+
return filters
6061
}
6162

6263
func buildFilterForValue(valueType string) dto.CCMGraphQLFilters {
@@ -66,13 +67,13 @@ func buildFilterForValue(valueType string) dto.CCMGraphQLFilters {
6667
func buildFilterForKeyValue(valueType string, valueSubtype string) dto.CCMGraphQLKeyValueFilters {
6768

6869
filterType := "labels.value"
69-
if strings.EqualFold(valueType, dto.ValueTypeCostCategory) {
70+
if strings.EqualFold(valueType, dto.ValueTypeCostCategory) {
7071
filterType = "business_mapping"
7172
}
7273

7374
return map[string]map[string]any{
7475
filterType: {
75-
"filterL1": valueSubtype,
76+
"filterL1": valueSubtype,
7677
"filterL2": filterType,
7778
},
7879
}
@@ -104,32 +105,32 @@ func BuildTimeFilters(timeFilter string) []map[string]any {
104105
},
105106
},
106107
}
107-
}
108+
}
108109

109-
func BuildAggregateFunction() ([]map[string]any) {
110+
func BuildAggregateFunction() []map[string]any {
110111

111112
return []map[string]any{
112113
{
113114
"operationType": "SUM",
114-
"columnName": "cost",
115+
"columnName": "cost",
115116
},
116117
}
117-
}
118+
}
118119

119-
func BuildPreferences() (map[string]any) {
120+
func BuildPreferences() map[string]any {
120121
return map[string]any{
121-
"includeOthers": false,
122+
"includeOthers": false,
122123
"includeUnallocatedCost": false,
123124
"awsPreferences": map[string]any{
124125
"includeDiscounts": false,
125-
"includeCredits": false,
126-
"includeRefunds": false,
127-
"includeTaxes": false,
128-
"awsCost": "UNBLENDED",
126+
"includeCredits": false,
127+
"includeRefunds": false,
128+
"includeTaxes": false,
129+
"awsCost": "UNBLENDED",
129130
},
130-
"gcpPreferences": nil,
131+
"gcpPreferences": nil,
131132
"azureViewPreferences": nil,
132-
"showAnomalies": false,
133+
"showAnomalies": false,
133134
}
134135
}
135136

@@ -186,11 +187,11 @@ func BuildFieldFiltersWithOperator(input map[string][]string, output []map[strin
186187
"idFilter": map[string]any{
187188
"values": values,
188189
"operator": operator,
189-
"field": out,
190+
"field": out,
190191
},
191192
}
192193

193-
result = append(result, idFilterMap)
194+
result = append(result, idFilterMap)
194195
}
195196
}
196197
}
@@ -209,15 +210,15 @@ func BuildKeyValueFieldFiltersWithOperator(input dto.CCMGraphQLKeyValueFilters,
209210
if strings.EqualFold(fName, out["identifier"]) {
210211
fieldName, ok := values["filterL1"].(string)
211212
if ok {
212-
out["fieldName"] = fieldName
213+
out["fieldName"] = fieldName
213214
var idFilterMap = map[string]any{
214215
"idFilter": map[string]any{
215216
"values": values["filterL2"],
216217
"operator": operator,
217-
"field": out,
218+
"field": out,
218219
},
219220
}
220-
result = append(result, idFilterMap)
221+
result = append(result, idFilterMap)
221222
}
222223
}
223224
}
@@ -231,7 +232,7 @@ func BuildKeyFieldFilter(input string, output map[string]map[string]any) ([]map[
231232

232233
func BuildKeyFieldFilterWithOperator(fieldKey string, output map[string]map[string]any, operator string) ([]map[string]any, error) {
233234
result := make([]map[string]any, 0)
234-
235+
235236
fieldOut, ok := output[fieldKey]
236237
if !ok {
237238
return nil, fmt.Errorf("Field key not found when building filter %s", fieldKey)
@@ -243,9 +244,9 @@ func BuildKeyFieldFilterWithOperator(fieldKey string, output map[string]map[stri
243244
}
244245
var idFilterMap = map[string]any{
245246
"idFilter": map[string]any{
246-
"values": []string{""},
247+
"values": []string{""},
247248
"operator": operator,
248-
"field": out,
249+
"field": out,
249250
},
250251
}
251252
result = append(result, idFilterMap)
@@ -258,7 +259,7 @@ func BuildKeyValueFieldFilter(fieldKey string, fieldSubKey string, output map[st
258259

259260
func BuildKeyValueFieldFilterWithOperator(fieldKey string, fieldSubKey string, output map[string]map[string]any, operator string) ([]map[string]any, error) {
260261
result := make([]map[string]any, 0)
261-
262+
262263
fieldOut, ok := output[fieldKey]
263264

264265
if !ok {
@@ -273,9 +274,9 @@ func BuildKeyValueFieldFilterWithOperator(fieldKey string, fieldSubKey string, o
273274
out["fieldName"] = fieldSubKey
274275
var idFilterMap = map[string]any{
275276
"idFilter": map[string]any{
276-
"values": []string{""},
277+
"values": []string{""},
277278
"operator": operator,
278-
"field": out,
279+
"field": out,
279280
},
280281
}
281282
result = append(result, idFilterMap)
@@ -286,8 +287,8 @@ func BuildGroupBy(input map[string]any, outputFields []map[string]string, output
286287
// Get the value when grouping by field only.
287288
field, ok1 := input["field"].(string)
288289
if ok1 == false {
289-
return DefaultGroupBy
290-
}
290+
return DefaultGroupBy
291+
}
291292

292293
for _, out := range outputFields {
293294
if strings.EqualFold(field, out["fieldId"]) {
@@ -302,7 +303,7 @@ func BuildGroupBy(input map[string]any, outputFields []map[string]string, output
302303
// Get the value when grouping by key,value.
303304
value, ok2 := input["value"].(string)
304305
if ok2 == false {
305-
return DefaultGroupBy
306+
return DefaultGroupBy
306307
}
307308
for _, out := range outputKeyValueFields {
308309
if strings.EqualFold(field, out["identifier"]) {
@@ -314,7 +315,7 @@ func BuildGroupBy(input map[string]any, outputFields []map[string]string, output
314315
}
315316
}
316317
}
317-
return DefaultGroupBy
318+
return DefaultGroupBy
318319
}
319320

320321
func DebugPayload(operation string, payload map[string]any) {
@@ -324,7 +325,7 @@ func DebugPayload(operation string, payload map[string]any) {
324325
slog.Debug("-----------", "----------", "--------------")
325326
}
326327

327-
func MapToJSONString(m map[string]any) (string) {
328+
func MapToJSONString(m map[string]any) string {
328329
b, err := json.MarshalIndent(m, "", " ")
329330
if err != nil {
330331
return ""

client/connectors.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ func (c *ConnectorService) ListConnectors(ctx context.Context, scope dto.Scope,
107107
ConnectorNames: connectorNames,
108108
ConnectorIdentifiers: connectorIdentifiers,
109109
Description: description,
110-
Types: types,
111-
Categories: categories,
112-
ConnectivityStatuses: connectivityStatuses,
110+
Types: types,
111+
Categories: categories,
112+
ConnectivityStatuses: connectivityStatuses,
113113
InheritingCredentialsFromDelegate: inheritingCredentialsFromDelegate,
114-
ConnectorConnectivityModes: connectorConnectivityModes,
115-
Tags: tags,
116-
FilterType: "Connector", // Fixed value
114+
ConnectorConnectivityModes: connectorConnectivityModes,
115+
Tags: tags,
116+
FilterType: "Connector", // Fixed value
117117
}
118118

119119
// Define a struct to match the actual API response structure
120120
type listConnectorsResponse struct {
121-
Status string `json:"status"`
122-
Data pkgDTO.ConnectorListData `json:"data"`
123-
MetaData interface{} `json:"metaData"`
124-
CorrelationID string `json:"correlationId"`
121+
Status string `json:"status"`
122+
Data pkgDTO.ConnectorListData `json:"data"`
123+
MetaData interface{} `json:"metaData"`
124+
CorrelationID string `json:"correlationId"`
125125
}
126126

127127
var response listConnectorsResponse

0 commit comments

Comments
 (0)