signalfx / signalfx-go

Go client library and instrumentation bindings for SignalFx
https://www.signalfx.com
Apache License 2.0
14 stars 51 forks source link

fix robomaker and medialive namespaces #133

Closed xp-1000 closed 3 years ago

xp-1000 commented 3 years ago

related to https://github.com/splunk-terraform/terraform-provider-signalfx/pull/314 and https://github.com/signalfx/signalfx-go/pull/132 and support ticket 00019838

@dloucasfx @jrcamp @asuresh4 @keitwb

I found the https://app.eu0.signalfx.com/v2/aws/supportedNamespacesAndRegions (undocumented I think). while it requires a token it seems not possible to build the model fully dynamically.

Nevertheless, the manual update of aws and azure services is painful and always done after a customer feedback which is not really a proactive approach.

To clean manually this time I run the following script:

#!/bin/bash

if ! [ -v SFX_TOKEN ]; then
    echo "You must set environment variable \"SFX_TOKEN\""
    exit 1
fi

ERR=0
MODEL_FILE="integration/model_aws_service.go"
API_URL="https://app.${SFX_REALM:-us0}.signalfx.com/v2/aws/supportedNamespacesAndRegions"

resp=$(curl --fail-with-body -s "${API_URL}" -H "X-SF-TOKEN: ${SFX_TOKEN}")
if [ $? -ne 0 ]; then
    echo "Error during api call to ${API_URL}:"
    echo "$resp"
    exit -1
fi
supported_services=$(echo "$resp" | jq -rc '.namespaces | keys | .[]')

for namespace in $(echo "$supported_services"); do
    if ! grep -q "AwsService = \"$namespace\"" ${MODEL_FILE}; then
        echo "Missing namespace $namespace from $MODEL_FILE"
        ((ERR++))
    fi
done

echo "$supported_services" > /tmp/aws_services.txt
for namespace in $(grep AwsService.*= $MODEL_FILE | sed 's/^.*AwsService[[:space:]]=[[:space:]]"\(.*\)"/\1/g'); do
    if ! grep -q "^${namespace}$" <<<$supported_services; then
        echo "Undesired namespace $namespace should not be in $MODEL_FILE"
    fi
done

exit $ERR

the output before this change:

Missing namespace AWS/Robomaker from integration/model_aws_service.go
Missing namespace MediaLive from integration/model_aws_service.go
Undesired namespace AWS/RoboMaker should not be in integration/model_aws_service.go
Undesired namespace AWS/MediaLive should not be in integration/model_aws_service.go
xp-1000 commented 3 years ago

Also may be can you add a list a default reviewers for this repo or I am afraid contributions could be missed

keitwb commented 3 years ago

Also may be can you add a list a default reviewers for this repo or I am afraid contributions could be missed

I get notifications for everything on the repo regardless but yes the codeowners feature on github is helpful so I added it for future PRs.

xp-1000 commented 3 years ago

thanks as usual @keitwb !

If you have some time please give a look at https://github.com/splunk-terraform/terraform-provider-signalfx/pull/313 I am not really proud to be the one who inserted an useless sleep in your provider ..

xp-1000 commented 3 years ago

thanks @keitwb should I create a PR on https://github.com/splunk-terraform/terraform-provider-signalfx to upgrade the go lib version ?

keitwb commented 3 years ago

thanks @keitwb should I create a PR on https://github.com/splunk-terraform/terraform-provider-signalfx to upgrade the go lib version ?

Yes please.