Skip to content

Commit 22147b1

Browse files
Kirdocktomazpu
authored andcommitted
feat(classic): support aws credential services endpoint
1 parent 65e0dc4 commit 22147b1

File tree

4 files changed

+89
-9
lines changed

4 files changed

+89
-9
lines changed

pkg/api/endpoints.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
ApplicationMobile = "application-mobile"
4747
AppDetectionRule = "app-detection-rule"
4848
AwsCredentials = "aws-credentials"
49+
AwsCredentialsServices = "aws-credentials-services"
4950
KubernetesCredentials = "kubernetes-credentials" // #nosec G101
5051
AzureCredentials = "azure-credentials" // #nosec G101
5152
RequestAttributes = "request-attributes"
@@ -109,6 +110,12 @@ func NewAPIs() APIs {
109110
PropertyNameOfGetAllResponse: "dashboards",
110111
NonUniqueName: true,
111112
}
113+
var awsCredentialsAPI = API{
114+
ID: AwsCredentials,
115+
URLPath: "/api/config/v1/aws/credentials",
116+
PropertyNameOfGetAllResponse: StandardApiPropertyNameOfGetAllResponse,
117+
SkipDownload: true,
118+
}
112119

113120
// ApplicationWeb has KeyUserActionsWeb as a child API and so is defined here explicitly
114121
var applicationWebAPI = API{
@@ -241,11 +248,20 @@ func NewAPIs() APIs {
241248
PropertyNameOfGetAllResponse: StandardApiPropertyNameOfGetAllResponse,
242249
DeprecatedBy: "builtin:rum.web.app-detection",
243250
},
251+
awsCredentialsAPI,
244252
{
245-
ID: AwsCredentials,
246-
URLPath: "/api/config/v1/aws/credentials",
247-
PropertyNameOfGetAllResponse: StandardApiPropertyNameOfGetAllResponse,
248-
SkipDownload: true,
253+
ID: AwsCredentialsServices,
254+
URLPath: "/api/config/v1/aws/credentials/{SCOPE}/services",
255+
Parent: &awsCredentialsAPI,
256+
SingleConfiguration: true,
257+
NonDeletable: true,
258+
// References can't be resolved because we don't download the credentials.
259+
// Therefore, we are also ignoring this config
260+
SkipDownload: true,
261+
// Deploy doesn't accept metadata
262+
TweakResponseFunc: func(m map[string]any) {
263+
delete(m, "metadata")
264+
},
249265
},
250266
// Early adopter API !
251267
{

pkg/delete/delete.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ func Configs(ctx context.Context, clients client.ClientSet, entriesToDelete Dele
5050

5151
remainingEntriesToDelete, errCount := deleteAutomationConfigs(ctx, deleters, entriesToDelete)
5252

53-
// Dashboard share settings cannot be deleted
54-
if _, ok := remainingEntriesToDelete[api.DashboardShareSettings]; ok {
55-
log.WarnContext(ctx, "Classic config of type %s cannot be deleted. Note, that they can be removed by deleting the associated dashboard.", api.DashboardShareSettings)
56-
delete(remainingEntriesToDelete, api.DashboardShareSettings)
57-
}
53+
removeNonDeletableClassicAPIs(ctx, remainingEntriesToDelete)
5854

5955
// Delete rest of config types
6056
for t, entries := range remainingEntriesToDelete {
@@ -70,6 +66,21 @@ func Configs(ctx context.Context, clients client.ClientSet, entriesToDelete Dele
7066
return nil
7167
}
7268

69+
func removeNonDeletableClassicAPIs(ctx context.Context, remainingEntriesToDelete DeleteEntries) {
70+
for _, classicApi := range api.NewAPIs() {
71+
if !classicApi.NonDeletable {
72+
continue
73+
}
74+
75+
if classicApi.Parent == nil {
76+
log.WarnContext(ctx, "Classic config of type %s cannot be deleted.", classicApi.ID)
77+
} else {
78+
log.WarnContext(ctx, "Classic config of type %s cannot be deleted. Note, that they can be removed by deleting the associated '%s' type.", classicApi.ID, classicApi.Parent.ID)
79+
}
80+
delete(remainingEntriesToDelete, classicApi.ID)
81+
}
82+
}
83+
7384
func deleteAutomationConfigs(ctx context.Context, deleters Deleters, allEntries DeleteEntries) (DeleteEntries, int) {
7485
remainingDeleteEntries := maps.Clone(allEntries)
7586
errCount := 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
configs:
2+
- id: aws-credentials-services
3+
config:
4+
name: AWS credentials service config
5+
template: settings.json
6+
type:
7+
api:
8+
name: aws-credentials-services #monaco-test:no-replace
9+
scope:
10+
configId: credentials
11+
configType: aws-credentials
12+
property: id
13+
type: reference
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"services": [
3+
{
4+
"name": "lambda_builtin",
5+
"monitoredMetrics": null
6+
},
7+
{
8+
"name": "ebs_builtin",
9+
"monitoredMetrics": null
10+
},
11+
{
12+
"name": "ELB_builtin",
13+
"monitoredMetrics": null
14+
},
15+
{
16+
"name": "loadbalancer_builtin",
17+
"monitoredMetrics": null
18+
},
19+
{
20+
"name": "s3_builtin",
21+
"monitoredMetrics": null
22+
},
23+
{
24+
"name": "dynamodb_builtin",
25+
"monitoredMetrics": null
26+
},
27+
{
28+
"name": "ec2_builtin",
29+
"monitoredMetrics": null
30+
},
31+
{
32+
"name": "asg_builtin",
33+
"monitoredMetrics": null
34+
},
35+
{
36+
"name": "rds_builtin",
37+
"monitoredMetrics": null
38+
}
39+
]
40+
}

0 commit comments

Comments
 (0)