Skip to content

Commit

Permalink
removed unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
daidokoro committed Jul 11, 2023
1 parent fe916d3 commit 25733ea
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions otel-agent/ecs-ec2/ecsattributesprocessor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,40 +176,3 @@ func getEndpoints(ctx context.Context) (map[string][]string, error) {

return m, nil
}

func getEndpointsByID(containerID string) (map[string][]string, error) {
// Initialize Docker client
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return nil, fmt.Errorf("failed to create docker client: %s", err)
}

c, err := cli.ContainerInspect(context.Background(), containerID)
if err != nil {
return nil, fmt.Errorf("failed to inspect docker container %s: %s", containerID, err)
}

var endpoints []string

for _, env := range c.Config.Env {

// use regex to match ECS_CONTAINER_METADATA_URI_V4 and ECS_CONTAINER_METADATA_URI
for _, n := range []string{ecsContainerMetadataURIv4, ecsContainerMetadataURI} {
reg := regexp.MustCompile(fmt.Sprintf(`^%s=(.*$)`, n))
if !reg.MatchString(env) {
continue
}

matches := reg.FindStringSubmatch(env)
if len(matches) < 2 {
continue
}

endpoints = append(endpoints, matches[1])
}
}

m := make(map[string][]string)
m[containerID] = endpoints
return m, nil
}

0 comments on commit 25733ea

Please sign in to comment.