Skip to content

Commit ca046c0

Browse files
authored
chore: update golang constructs via go fix (#541)
Co-authored-by: Christian Lechner <22294087+lechnerc77@users.noreply.github.com>
1 parent 32cfd16 commit ca046c0

File tree

59 files changed

+209
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+209
-208
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ MAIN_PACKAGE=main.go
2020
build:
2121
go build -v ./...
2222

23+
fix:
24+
go fix -v ./...
25+
2326
install: build
2427
go build -o $(BINARY_PATH) $(MAIN_PACKAGE)
2528

@@ -37,4 +40,4 @@ docs:
3740
spellchecker:
3841
#prerequisite: Install pyspelling and aspell
3942
pyspelling -c .spellcheck.yml
40-
.PHONY: build install lint fmt test docs
43+
.PHONY: build fix install lint fmt test docs

cmd/cmdMarkdownHelper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func genMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string)
179179

180180
if len(cmd.Example) > 0 {
181181
buf.WriteString("### Examples\n\n```bash\n")
182-
lines := strings.Split(cmd.Example, "\n")
183-
for _, line := range lines {
182+
lines := strings.SplitSeq(cmd.Example, "\n")
183+
for line := range lines {
184184
buf.WriteString(formatCommandLine(line) + "\n")
185185
}
186186
buf.WriteString("```\n\n")

internal/btpcli/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func nthElementOrDefault[T any](slice []T, n int, defaultValue T) T {
2020
return slice[n]
2121
}
2222

23-
func doExecute[T interface{}](cliClient *v2Client, ctx context.Context, req *CommandRequest, options ...CommandOptions) (T, CommandResponse, error) {
23+
func doExecute[T any](cliClient *v2Client, ctx context.Context, req *CommandRequest, options ...CommandOptions) (T, CommandResponse, error) {
2424
var obj T
2525

2626
res, err := cliClient.Execute(ctx, req, options...)

internal/btpcli/types/cis/globalaccount_response_object.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type GlobalAccountResponseObject struct {
3838
// The current state of the global account. * <b>STARTED:</b> CRUD operation on an entity has started. * <b>CREATING:</b> Creating entity operation is in progress. * <b>UPDATING:</b> Updating entity operation is in progress. * <b>MOVING:</b> Moving entity operation is in progress. * <b>PROCESSING:</b> A series of operations related to the entity is in progress. * <b>DELETING:</b> Deleting entity operation is in progress. * <b>OK:</b> The CRUD operation or series of operations completed successfully. * <b>PENDING REVIEW:</b> The processing operation has been stopped for reviewing and can be restarted by the operator. * <b>CANCELLED:</b> The operation or processing was canceled by the operator. * <b>CREATION_FAILED:</b> The creation operation failed, and the entity was not created or was created but cannot be used. * <b>UPDATE_FAILED:</b> The update operation failed, and the entity was not updated. * <b>PROCESSING_FAILED:</b> The processing operations failed. * <b>DELETION_FAILED:</b> The delete operation failed, and the entity was not deleted. * <b>MOVE_FAILED:</b> Entity could not be moved to a different location. * <b>MIGRATING:</b> Migrating entity from NEO to CF.
3939
EntityState string `json:"entityState,omitempty"`
4040
// The planned date that the global account expires. This is the same date as the Contract End Date, unless a manual adjustment has been made to the actual expiration date of the global account. Typically, this property is automatically populated only when a formal termination order is received from the CRM system. From a customer perspective, this date marks the start of the grace period, which is typically 30 days before the actual deletion of the account.
41-
ExpiryDate Time `json:"expiryDate,omitempty"`
41+
ExpiryDate Time `json:"expiryDate"`
4242
// The geographic locations from where the global account can be accessed. * <b>STANDARD:</b> The global account can be accessed from any geographic location. * <b>EU_ACCESS:</b> The global account can be accessed only within locations in the EU.
4343
GeoAccess string `json:"geoAccess"`
4444
// The GUID of the directory's global account entity.
@@ -50,15 +50,15 @@ type GlobalAccountResponseObject struct {
5050
// The type of license for the global account. The license type affects the scope of functions of the account. * <b>DEVELOPER:</b> For internal developer global accounts on Staging or Canary landscapes. * <b>CUSTOMER:</b> For customer global accounts. * <b>PARTNER:</b> For partner global accounts. * <b>INTERNAL_DEV:</b> For internal global accounts on the Dev landscape. * <b>INTERNAL_PROD:</b> For internal global accounts on the Live landscape. * <b>TRIAL:</b> For customer trial accounts.
5151
LicenseType string `json:"licenseType"`
5252
// The date the global account was last modified. Dates and times are in UTC format.
53-
ModifiedDate Time `json:"modifiedDate,omitempty"`
53+
ModifiedDate Time `json:"modifiedDate"`
5454
// The origin of the account. * <b>ORDER:</b> Created by the Order Processing API or Submit Order wizard. * <b>OPERATOR:</b> Created by the Global Account wizard. * <b>REGION_SETUP:</b> Created automatically as part of the region setup.
5555
Origin string `json:"origin,omitempty"`
5656
// The GUID of the global account's parent entity. Typically this is the global account.
5757
ParentGUID string `json:"parentGUID"`
5858
// The Type of the global account's parent entity.
5959
ParentType string `json:"parentType"`
6060
// The date that an expired contract was renewed. Dates and times are in UTC format.
61-
RenewalDate Time `json:"renewalDate,omitempty"`
61+
RenewalDate Time `json:"renewalDate"`
6262
// For internal accounts, the service for which the global account was created.
6363
ServiceId string `json:"serviceId,omitempty"`
6464
// Information about the state.

internal/btpcli/types/saas_manager_service/model_entitled_applications_response_object.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type EntitledApplicationsResponseObject struct {
1616
// The unique registration name of the deployed multitenant application as defined by the app developer.
1717
AppName string `json:"appName,omitempty"`
1818
// The application coordinates provided in metadata for customer-facing UIs.
19-
ApplicationCoordinates *interface{} `json:"applicationCoordinates,omitempty"`
19+
ApplicationCoordinates *any `json:"applicationCoordinates,omitempty"`
2020
// The authentication provider of the multitenant application. * XSUAA is the SAP Authorization and Trust Management service that defines scopes and permissions for users as tenants at the global account level. * IAS is Identity Authentication Service that defines scopes and permissions for users in zones (common data isolation systems across systems, SaaS tenants, and services).
2121
AuthenticationProvider string `json:"authenticationProvider,omitempty"`
2222
// The state of the automation solution.
@@ -30,7 +30,7 @@ type EntitledApplicationsResponseObject struct {
3030
// The commercial name of the deployed multitenant application as defined by the app developer.
3131
CommercialAppName string `json:"commercialAppName,omitempty"`
3232
// The date the subscription was created. Dates and times are in UTC format.
33-
CreatedDate Time `json:"createdDate,omitempty"`
33+
CreatedDate Time `json:"createdDate"`
3434
// Whether the application was developed by a customer. If not, then the application is developed by the cloud operator, such as SAP.
3535
CustomerDeveloped bool `json:"customerDeveloped,omitempty"`
3636
// The description of the multitenant application for customer-facing UIs.
@@ -48,11 +48,11 @@ type EntitledApplicationsResponseObject struct {
4848
// User-defined labels that are assigned as key-value pairs in a JSON array to the multitenant application subscription. Example: { \"Cost Center\": [\"19700626\"], \"Department\": [\"Sales\"], \"Contacts\": [\"name1@example.com\",\"name2@example.com\"], \"EMEA\":[] }
4949
Labels map[string][]string `json:"labels,omitempty"`
5050
// JSON schema that describes the metadata that the consumer provide when subscribing to the application.
51-
Metadata map[string]interface{} `json:"metadata,omitempty"`
51+
Metadata map[string]any `json:"metadata,omitempty"`
5252
// The date the subscription was last modified. Dates and times are in UTC format.
53-
ModifiedDate Time `json:"modifiedDate,omitempty"`
53+
ModifiedDate Time `json:"modifiedDate"`
5454
// JSON schema that describes the parameters that the consumer must provide when subscribing to the application.
55-
ParamsSchema map[string]interface{} `json:"paramsSchema,omitempty"`
55+
ParamsSchema map[string]any `json:"paramsSchema,omitempty"`
5656
// The description of the plan for customer-facing UIs.
5757
PlanDescription string `json:"planDescription,omitempty"`
5858
// The plan name of the application to which the consumer has subscribed.

internal/btpcli/types/servicemanager/model_service_offering_response_object.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type ServiceOfferingResponseObject struct {
4141
// The catalog name of the service offering.
4242
CatalogName string `json:"catalog_name,omitempty"`
4343
// The time the service offering was created. <br> In ISO 8601 format:</br> YYYY-MM-DDThh:mm:ssTZD
44-
CreatedAt time.Time `json:"created_at,omitempty"`
44+
CreatedAt time.Time `json:"created_at"`
4545
// The last time the service offering was updated. <br/> In ISO 8601 format.
46-
UpdatedAt time.Time `json:"updated_at,omitempty"`
46+
UpdatedAt time.Time `json:"updated_at"`
4747
}

internal/btpcli/types/servicemanager/model_service_plan_response_object.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type ServicePlanResponseObject struct {
3333
// The ID of the service offering.
3434
ServiceOfferingId string `json:"service_offering_id,omitempty"`
3535
// The time the service plan was created.<br> In ISO 8601 format:</br> YYYY-MM-DDThh:mm:ssTZD
36-
CreatedAt time.Time `json:"created_at,omitempty"`
36+
CreatedAt time.Time `json:"created_at"`
3737
// The last time the service plan was updated.<br> In ISO 8601 format.
38-
UpdatedAt time.Time `json:"updated_at,omitempty"`
38+
UpdatedAt time.Time `json:"updated_at"`
3939
}

pkg/defaultfilter/defaultfilter.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ func FilterDefaultRoleCollectionsFromJsonData(subaccountId string, directoryID s
7373
}
7474

7575
// Filter out the default role collections from the data
76-
entities := data[dataSourceListKey].([]interface{})
76+
entities := data[dataSourceListKey].([]any)
7777

78-
entities = slices.DeleteFunc(entities, func(value interface{}) bool {
79-
entity := value.(map[string]interface{})
78+
entities = slices.DeleteFunc(entities, func(value any) bool {
79+
entity := value.(map[string]any)
8080
return IsRoleCollectionInDefaultList(fmt.Sprintf("%v", entity[resourceKey]), defaultRoleCollectionNames)
8181
})
8282

@@ -148,10 +148,10 @@ func FilterDefaultRolesFromJsonData(subaccountId string, directoryID string, dat
148148
}
149149

150150
// Filter out the default role collections from the data
151-
entities := data[dataSourceListKey].([]interface{})
151+
entities := data[dataSourceListKey].([]any)
152152

153-
entities = slices.DeleteFunc(entities, func(value interface{}) bool {
154-
entity := value.(map[string]interface{})
153+
entities = slices.DeleteFunc(entities, func(value any) bool {
154+
entity := value.(map[string]any)
155155
return IsRoleInDefaultList(fmt.Sprintf("%v", entity[resourceKey]), defaultRoles)
156156
})
157157

@@ -164,10 +164,10 @@ func FilterDefaultIdpJsonData(data map[string]any) map[string]any {
164164
const resourceKey = "origin"
165165

166166
// Filter out the default role collections from the data
167-
entities := data[dataSourceListKey].([]interface{})
167+
entities := data[dataSourceListKey].([]any)
168168

169-
entities = slices.DeleteFunc(entities, func(value interface{}) bool {
170-
entity := value.(map[string]interface{})
169+
entities = slices.DeleteFunc(entities, func(value any) bool {
170+
entity := value.(map[string]any)
171171
return fmt.Sprintf("%v", entity[resourceKey]) == "sap.default"
172172
})
173173

pkg/tfcleanup/resource_processor/btp_subaccount_entitlement_processor.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,26 @@ func addEntitlementVariables(variablesToCreate *generictools.VariableContent, en
152152
variableInfo := "Object of entitlements to be assigned to the subaccount."
153153
variableType := "map(list(string))"
154154

155-
defaultValue := "{\n"
155+
var defaultValue strings.Builder
156+
defaultValue.WriteString("{\n")
156157
for key, info := range entitlementAddress {
157158
serviceName := key.ServiceName
158159
planName := key.PlanName
159160
amount := info.Amount
160161

161162
if amount > 0 {
162163
stringForValue := serviceName + "=[\"" + planName + "=" + strconv.Itoa(amount) + "\"]\n"
163-
defaultValue += strings.ReplaceAll(stringForValue, " ", "")
164+
defaultValue.WriteString(strings.ReplaceAll(stringForValue, " ", ""))
164165
} else {
165-
defaultValue += "\"" + serviceName + "\" = [\"" + planName + "\"]\n"
166+
defaultValue.WriteString("\"" + serviceName + "\" = [\"" + planName + "\"]\n")
166167
}
167168
}
168-
defaultValue += "}"
169+
defaultValue.WriteString("}")
169170

170171
(*variablesToCreate)[variableName] = generictools.VariableInfo{
171172
Description: variableInfo,
172173
Type: variableType,
173-
DefaultValue: defaultValue,
174+
DefaultValue: defaultValue.String(),
174175
}
175176
}
176177

pkg/tfimportprovider/ITfimportprovider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package tfimportprovider
22

33
type ITfImportProvider interface {
44
GetResourceType() string
5-
GetImportBlock(data map[string]interface{}, levelId string, filterValues []string) (string, int, error)
5+
GetImportBlock(data map[string]any, levelId string, filterValues []string) (string, int, error)
66
}

0 commit comments

Comments
 (0)