Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Jan 20, 2025
1 parent 7271dc3 commit 2ac35b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions api/types/usertasks/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,37 +399,37 @@ func validateDiscoverRDSTaskType(ut *usertasksv1.UserTask) error {
if ut.GetSpec().Integration == "" {
return trace.BadParameter("integration is required")
}
if ut.GetSpec().DiscoverRds == nil {
if ut.GetSpec().GetDiscoverRds() == nil {
return trace.BadParameter("%s requires the discover_rds field", TaskTypeDiscoverRDS)
}
if ut.GetSpec().DiscoverRds.AccountId == "" {
if ut.GetSpec().GetDiscoverRds().AccountId == "" {
return trace.BadParameter("%s requires the discover_rds.account_id field", TaskTypeDiscoverRDS)
}
if ut.GetSpec().DiscoverRds.Region == "" {
if ut.GetSpec().GetDiscoverRds().Region == "" {
return trace.BadParameter("%s requires the discover_rds.region field", TaskTypeDiscoverRDS)
}

expectedTaskName := TaskNameForDiscoverRDS(TaskNameForDiscoverRDSParts{
Integration: ut.Spec.Integration,
IssueType: ut.Spec.IssueType,
AccountID: ut.Spec.DiscoverRds.AccountId,
Region: ut.Spec.DiscoverRds.Region,
Integration: ut.GetSpec().Integration,
IssueType: ut.GetSpec().IssueType,
AccountID: ut.GetSpec().GetDiscoverRds().AccountId,
Region: ut.GetSpec().GetDiscoverRds().Region,
})
if ut.Metadata.GetName() != expectedTaskName {
if ut.GetMetadata().GetName() != expectedTaskName {
return trace.BadParameter("task name is pre-defined for discover-rds types, expected %s, got %s",
expectedTaskName,
ut.Metadata.GetName(),
)
}

if !slices.Contains(DiscoverRDSIssueTypes, ut.GetSpec().IssueType) {
if !slices.Contains(DiscoverRDSIssueTypes, ut.GetSpec().GetIssueType()) {
return trace.BadParameter("invalid issue type state, allowed values: %v", DiscoverRDSIssueTypes)
}

if len(ut.Spec.DiscoverRds.Databases) == 0 {
if len(ut.GetSpec().GetDiscoverRds().GetDatabases()) == 0 {
return trace.BadParameter("at least one database is required")
}
for databaseIdentifier, databaseIssue := range ut.Spec.DiscoverRds.Databases {
for databaseIdentifier, databaseIssue := range ut.GetSpec().GetDiscoverRds().GetDatabases() {
if databaseIdentifier == "" {
return trace.BadParameter("database identifier in discover_rds.databases map is required")
}
Expand Down
12 changes: 6 additions & 6 deletions lib/usertasks/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ func withRDSDatabaseIssueURL(metadata *usertasksv1.UserTask, database *usertasks
databaseBaseURL := url.URL{
Scheme: "https",
Host: "console.aws.amazon.com",
Path: path.Join("rds", "home"),
Path: "/rds/home",
Fragment: fragment,
RawQuery: url.Values{
"region": []string{metadata.Spec.DiscoverRds.GetRegion()},
"region": []string{metadata.GetSpec().GetDiscoverRds().GetRegion()},
}.Encode(),
}
ret.ResourceURL = databaseBaseURL.String()

switch metadata.Spec.IssueType {
switch metadata.GetSpec().GetIssueType() {
case usertasksapi.AutoDiscoverRDSIssueIAMAuthenticationDisabled:
databaseBaseURL.Fragment = databaseBaseURL.Fragment + ";tab=configuration"
databaseBaseURL.Fragment += ";tab=configuration"
ret.ConfigurationURL = databaseBaseURL.String()
}

Expand All @@ -229,15 +229,15 @@ func withRDSDatabaseIssueURL(metadata *usertasksv1.UserTask, database *usertasks
// - ResourceURL: a link to open the database in Amazon Web Console.
// - ConfigurationURL: a link to open the database in Amazon Web Console in the configuration tab.
func RDSDatabasesWithURLs(ut *usertasksv1.UserTask) *UserTaskDiscoverRDSWithURLs {
databases := ut.Spec.GetDiscoverRds().GetDatabases()
databases := ut.GetSpec().GetDiscoverRds().GetDatabases()
databasesWithURLs := make(map[string]*DiscoverRDSDatabaseWithURLs, len(databases))

for databaseID, database := range databases {
databasesWithURLs[databaseID] = withRDSDatabaseIssueURL(ut, database)
}

return &UserTaskDiscoverRDSWithURLs{
DiscoverRDS: ut.Spec.GetDiscoverRds(),
DiscoverRDS: ut.GetSpec().GetDiscoverRds(),
Databases: databasesWithURLs,
}
}

0 comments on commit 2ac35b1

Please sign in to comment.