Skip to content

Commit

Permalink
feat(apigateway): report docker-compose-baremetal running environment (
Browse files Browse the repository at this point in the history
  • Loading branch information
zexi authored Jul 22, 2024
1 parent 23a63a3 commit be0ebd0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/apigateway/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ type sReport struct {
}

const (
RUNNING_ENV_KUBERNETES = "kubernetes"
RUNNING_ENV_DOCKER_COMPOSE = "docker-compose"
RUNNING_ENV_UNKNOWN = "unknown"
RUNNING_ENV_KUBERNETES = "kubernetes"
RUNNING_ENV_DOCKER_COMPOSE = "docker-compose"
RUNNING_ENV_DOCKER_COMPOSE_BAREMETAL = "docker-compose-baremetal"
RUNNING_ENV_UNKNOWN = "unknown"
)

func isInsideDockerCompose() bool {
Expand Down Expand Up @@ -123,6 +124,19 @@ func getRunningEnv() string {
}

if isInsideDockerCompose() {
// list agent to check whether we're running baremetal agent
s := auth.GetAdminSession(context.Background(), options.Options.Region)
ret, err := compute.Baremetalagents.List(s, nil)
if err != nil {
log.Warningf("list agents error: %s", err)
return RUNNING_ENV_DOCKER_COMPOSE
}
for _, agent := range ret.Data {
aType, _ := agent.GetString("agent_type")
if aType == "baremetal" {
return RUNNING_ENV_DOCKER_COMPOSE_BAREMETAL
}
}
return RUNNING_ENV_DOCKER_COMPOSE
}
return RUNNING_ENV_UNKNOWN
Expand Down

0 comments on commit be0ebd0

Please sign in to comment.