Skip to content

Commit

Permalink
Merge pull request scottdware#47 from f5devcentral/devbranch-ravinder01
Browse files Browse the repository at this point in the history
adding teem module change
  • Loading branch information
RavinderReddyF5 authored Jul 1, 2020
2 parents 0c10c88 + 9cd6293 commit 9e910a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ matrix:
- go: tip
allow_failures:
- go: tip

env:
- TEEM_API_ENVIRONMENT=staging
8 changes: 4 additions & 4 deletions f5teem/f5teem.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
)

func AnonymousClient(assetInfo AssetInfo, apiKey string) *TeemObject {
teemServer := getEndpointInfo()
if apiKey == "" {
envTeem, teemServer := getEndpointInfo()
if envTeem != "staging" {
apiKey = teemServer.(map[string]string)["api_key"]
}
serviceHost := teemServer.(map[string]string)["endpoint"]
Expand All @@ -46,12 +46,12 @@ func AnonymousClient(assetInfo AssetInfo, apiKey string) *TeemObject {
return &teemClient
}

func getEndpointInfo() interface{} {
func getEndpointInfo() (string, interface{}) {
environment := envVar["published"].([]string)[0]
if len(os.Getenv(envVar["env_var"].(string))) > 0 {
environment = os.Getenv(envVar["env_var"].(string))
}
return endPoints["anonymous"].(map[string]interface{})[environment]
return environment, endPoints["anonymous"].(map[string]interface{})[environment]
}

func genUUID() string {
Expand Down
9 changes: 7 additions & 2 deletions f5teem/f5teem_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package f5teem

import (
"os"
"testing"
)

Expand All @@ -10,7 +11,8 @@ func TestTeemTelemetryRequest(t *testing.T) {
"1.2.0",
"",
}
teemDevice := AnonymousClient(assetInfo, "")
apiKey := os.Getenv("TEEM_API_KEY")
teemDevice := AnonymousClient(assetInfo, apiKey)
d := map[string]interface{}{
"Device": 1,
"Tenant": 1,
Expand All @@ -24,7 +26,10 @@ func TestTeemTelemetryRequest(t *testing.T) {
"platformVersion": "15.1.0.5",
}
err := teemDevice.Report(d, "Terraform BIGIP-ravinder-latest", "1")
if err != nil {
if apiKey == "" && err == nil {
t.Errorf("Error:%v", err)
}
if apiKey != "" && err != nil {
t.Errorf("Error:%v", err)
}
}
Expand Down

0 comments on commit 9e910a5

Please sign in to comment.