Skip to content

Commit

Permalink
ext: ecsobserver Move ecsmock to internal
Browse files Browse the repository at this point in the history
It should get moved into internal/aws in the future. Keep it under
extension package for now
  • Loading branch information
pingleig committed May 7, 2021
1 parent 0e75288 commit 10a06a2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions extension/observer/ecsobserver/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import (
"go.uber.org/zap"
)

// ecsClient includes API required by TaskFetcher.
// ecsClient includes API required by taskFetcher.
type ecsClient interface {
ListTasksWithContext(ctx context.Context, input *ecs.ListTasksInput, opts ...request.Option) (*ecs.ListTasksOutput, error)
DescribeTasksWithContext(ctx context.Context, input *ecs.DescribeTasksInput, opts ...request.Option) (*ecs.DescribeTasksOutput, error)
}

type TaskFetcher struct {
type taskFetcher struct {
logger *zap.Logger
ecs ecsClient
cluster string
}

type TaskFetcherOptions struct {
type taskFetcherOptions struct {
Logger *zap.Logger
Cluster string
Region string
Expand All @@ -45,8 +45,8 @@ type TaskFetcherOptions struct {
ecsOverride ecsClient
}

func NewTaskFetcher(opts TaskFetcherOptions) (*TaskFetcher, error) {
fetcher := TaskFetcher{
func newTaskFetcher(opts taskFetcherOptions) (*taskFetcher, error) {
fetcher := taskFetcher{
logger: opts.Logger,
ecs: opts.ecsOverride,
cluster: opts.Cluster,
Expand All @@ -55,12 +55,12 @@ func NewTaskFetcher(opts TaskFetcherOptions) (*TaskFetcher, error) {
if fetcher.ecs != nil {
return &fetcher, nil
}
panic("actual aws init logic not implemented")
return nil, fmt.Errorf("actual aws init logic not implemented")
}

// GetAllTasks get arns of all running tasks and describe those tasks.
// There is no API to list task detail without arn so we need to call two APIs.
func (f *TaskFetcher) GetAllTasks(ctx context.Context) ([]*ecs.Task, error) {
func (f *taskFetcher) GetAllTasks(ctx context.Context) ([]*ecs.Task, error) {
svc := f.ecs
cluster := aws.String(f.cluster)
req := ecs.ListTasksInput{Cluster: cluster}
Expand Down
4 changes: 2 additions & 2 deletions extension/observer/ecsobserver/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver/ecsmock"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver/internal/ecsmock"
)

func TestFetcher_GetAllTasks(t *testing.T) {
c := ecsmock.NewCluster()
f, err := NewTaskFetcher(TaskFetcherOptions{
f, err := newTaskFetcher(taskFetcherOptions{
Logger: zap.NewExample(),
Cluster: "not used",
Region: "not used",
Expand Down
2 changes: 1 addition & 1 deletion extension/observer/ecsobserver/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// Task contains both raw task info and its definition.
// It is generated from TaskFetcher.
// It is generated from taskFetcher.
type Task struct {
Task *ecs.Task
Definition *ecs.TaskDefinition
Expand Down

0 comments on commit 10a06a2

Please sign in to comment.