Skip to content

Commit

Permalink
Remove unnecessary Consul attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev committed Jan 23, 2024
1 parent ec32409 commit 68d5af3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,9 @@ type Config struct {
// DefaultArguments holds default settings for Config.
var DefaultArguments = Config{
ResourceAttributes: ResourceAttributesConfig{
AzureResourcegroupName: rac.ResourceAttributeConfig{Enabled: true},
AzureVMName: rac.ResourceAttributeConfig{Enabled: true},
AzureVMScalesetName: rac.ResourceAttributeConfig{Enabled: true},
AzureVMSize: rac.ResourceAttributeConfig{Enabled: true},
CloudAccountID: rac.ResourceAttributeConfig{Enabled: true},
CloudPlatform: rac.ResourceAttributeConfig{Enabled: true},
CloudProvider: rac.ResourceAttributeConfig{Enabled: true},
CloudRegion: rac.ResourceAttributeConfig{Enabled: true},
HostID: rac.ResourceAttributeConfig{Enabled: true},
HostName: rac.ResourceAttributeConfig{Enabled: true},
CloudRegion: rac.ResourceAttributeConfig{Enabled: true},
HostID: rac.ResourceAttributeConfig{Enabled: true},
HostName: rac.ResourceAttributeConfig{Enabled: true},
},
}

Expand Down Expand Up @@ -87,29 +80,15 @@ func (args Config) Convert() map[string]interface{} {

// ResourceAttributesConfig provides config for consul resource attributes.
type ResourceAttributesConfig struct {
AzureResourcegroupName rac.ResourceAttributeConfig `river:"azure.resourcegroup.name,block,optional"`
AzureVMName rac.ResourceAttributeConfig `river:"azure.vm.name,block,optional"`
AzureVMScalesetName rac.ResourceAttributeConfig `river:"azure.vm.scaleset.name,block,optional"`
AzureVMSize rac.ResourceAttributeConfig `river:"azure.vm.size,block,optional"`
CloudAccountID rac.ResourceAttributeConfig `river:"cloud.account.id,block,optional"`
CloudPlatform rac.ResourceAttributeConfig `river:"cloud.platform,block,optional"`
CloudProvider rac.ResourceAttributeConfig `river:"cloud.provider,block,optional"`
CloudRegion rac.ResourceAttributeConfig `river:"cloud.region,block,optional"`
HostID rac.ResourceAttributeConfig `river:"host.id,block,optional"`
HostName rac.ResourceAttributeConfig `river:"host.name,block,optional"`
CloudRegion rac.ResourceAttributeConfig `river:"cloud.region,block,optional"`
HostID rac.ResourceAttributeConfig `river:"host.id,block,optional"`
HostName rac.ResourceAttributeConfig `river:"host.name,block,optional"`
}

func (r *ResourceAttributesConfig) Convert() map[string]interface{} {
return map[string]interface{}{
"azure.resourcegroup.name": r.AzureResourcegroupName.Convert(),
"azure.vm.name": r.AzureVMName.Convert(),
"azure.vm.scaleset.name": r.AzureVMScalesetName.Convert(),
"azure.vm.size": r.AzureVMSize.Convert(),
"cloud.account.id": r.CloudAccountID.Convert(),
"cloud.platform": r.CloudPlatform.Convert(),
"cloud.provider": r.CloudProvider.Convert(),
"cloud.region": r.CloudRegion.Convert(),
"host.id": r.HostID.Convert(),
"host.name": r.HostName.Convert(),
"cloud.region": r.CloudRegion.Convert(),
"host.id": r.HostID.Convert(),
"host.name": r.HostName.Convert(),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1050,12 +1050,8 @@ func TestArguments_UnmarshalRiver(t *testing.T) {
namespace = "test_namespace"
meta = ["test"]
resource_attributes {
azure.resourcegroup.name { enabled = true }
azure.vm.name { enabled = true }
azure.vm.scaleset.name { enabled = true }
azure.vm.size { enabled = true }
cloud.account.id { enabled = false }
cloud.platform { enabled = false }
cloud.region { enabled = false }
host.id { enabled = false }
}
}
output {}
Expand All @@ -1071,32 +1067,11 @@ func TestArguments_UnmarshalRiver(t *testing.T) {
"namespace": "test_namespace",
"meta": map[string]string{"test": ""},
"resource_attributes": map[string]interface{}{
"azure.resourcegroup.name": map[string]interface{}{
"enabled": true,
},
"azure.vm.name": map[string]interface{}{
"enabled": true,
},
"azure.vm.scaleset.name": map[string]interface{}{
"enabled": true,
},
"azure.vm.size": map[string]interface{}{
"enabled": true,
},
"cloud.account.id": map[string]interface{}{
"enabled": false,
},
"cloud.platform": map[string]interface{}{
"enabled": false,
},
"cloud.provider": map[string]interface{}{
"enabled": true,
},
"cloud.region": map[string]interface{}{
"enabled": true,
"enabled": false,
},
"host.id": map[string]interface{}{
"enabled": true,
"enabled": false,
},
"host.name": map[string]interface{}{
"enabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,8 @@ Block | Description

The `resource_attributes` block supports the following blocks:

<!-- TODO: Why are all these azure resource attributes here? -->
Block | Description | Required
--------------------------------------- | --------------------------------------------------------------------------------------------------- | --------
[azure.resourcegroup.name][res-attr-cfg] | Toggles the `azure.resourcegroup.name` resource attribute. <br> Sets `enabled` to `true` by default. | no
[azure.vm.name][res-attr-cfg] | Toggles the `azure.vm.name` resource attribute. <br> Sets `enabled` to `true` by default. | no
[azure.vm.scaleset.name][res-attr-cfg] | Toggles the `azure.vm.scaleset.name` resource attribute. <br> Sets `enabled` to `true` by default. | no
[azure.vm.size][res-attr-cfg] | Toggles the `azure.vm.size` resource attribute. <br> Sets `enabled` to `true` by default. | no
[cloud.account.id][res-attr-cfg] | Toggles the `cloud.account.id` resource attribute. <br> Sets `enabled` to `true` by default. | no
[cloud.platform][res-attr-cfg] | Toggles the `cloud.platform` resource attribute. <br> Sets `enabled` to `true` by default. | no
[cloud.provider][res-attr-cfg] | Toggles the `cloud.provider` resource attribute. <br> Sets `enabled` to `true` by default. | no
[cloud.region][res-attr-cfg] | Toggles the `cloud.region` resource attribute. <br> Sets `enabled` to `true` by default. | no
[host.id][res-attr-cfg] | Toggles the `host.id` resource attribute. <br> Sets `enabled` to `true` by default. | no
[host.name][res-attr-cfg] | Toggles the `host.name` resource attribute. <br> Sets `enabled` to `true` by default. | no
Expand Down

0 comments on commit 68d5af3

Please sign in to comment.