Skip to content

Commit

Permalink
Rename describe functions to select
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Nov 24, 2024
1 parent 43fcb35 commit 523c395
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ var execCmd = &cobra.Command{
}

func runExec(ctx context.Context, client *ecs.Client, region string, clusterId string, serviceId string, taskId string, containerId string, command string, interactive bool) error {
cluster, err := describeCluster(ctx, client, clusterId)
cluster, err := selectCluster(ctx, client, clusterId)
if err != nil {
return err
}
service, err := describeService(ctx, client, *cluster.ClusterArn, serviceId)
service, err := selectService(ctx, client, *cluster.ClusterArn, serviceId)
if err != nil {
return err
}
task, err := describeTask(ctx, client, *cluster.ClusterArn, *service.ServiceName, taskId)
task, err := selectTask(ctx, client, *cluster.ClusterArn, *service.ServiceName, taskId)
if err != nil {
return err
}
container, err := describeContainer(task.Containers, containerId)
container, err := selectContainer(task.Containers, containerId)
if err != nil {
return err
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func runExec(ctx context.Context, client *ecs.Client, region string, clusterId s
return smp.Run()
}

func describeContainer(containers []types.Container, containerId string) (*types.Container, error) {
func selectContainer(containers []types.Container, containerId string) (*types.Container, error) {
if containerId == "" {
var containerNames []string
for _, container := range containers {
Expand Down
8 changes: 4 additions & 4 deletions cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ var logsCmd = &cobra.Command{
}

func runLogs(ctx context.Context, ecsClient *ecs.Client, cwlogsClient *cloudwatchlogs.Client, clusterId string, serviceId string, taskId string, containerId string) error {
cluster, err := describeCluster(ctx, ecsClient, clusterId)
cluster, err := selectCluster(ctx, ecsClient, clusterId)
if err != nil {
return err
}
service, err := describeService(ctx, ecsClient, *cluster.ClusterArn, serviceId)
service, err := selectService(ctx, ecsClient, *cluster.ClusterArn, serviceId)
if err != nil {
return err
}
container, err := describeContainerDefinition(context.TODO(), ecsClient, *service.TaskDefinition, containerId)
container, err := selectContainerDefinition(context.TODO(), ecsClient, *service.TaskDefinition, containerId)
if err != nil {
return err
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func runLogs(ctx context.Context, ecsClient *ecs.Client, cwlogsClient *cloudwatc
return nil
}

func describeContainerDefinition(ctx context.Context, client *ecs.Client, taskDefinitionArn string, containerId string) (*ecsTypes.ContainerDefinition, error) {
func selectContainerDefinition(ctx context.Context, client *ecs.Client, taskDefinitionArn string, containerId string) (*ecsTypes.ContainerDefinition, error) {
describeTaskDefinition, err := client.DescribeTaskDefinition(ctx, &ecs.DescribeTaskDefinitionInput{
TaskDefinition: &taskDefinitionArn,
})
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Execute() {
}
}

func describeCluster(ctx context.Context, client *ecs.Client, clusterId string) (*types.Cluster, error) {
func selectCluster(ctx context.Context, client *ecs.Client, clusterId string) (*types.Cluster, error) {
if clusterId == "" {
listClusters, err := client.ListClusters(ctx, &ecs.ListClustersInput{})
if err != nil {
Expand All @@ -56,7 +56,7 @@ func describeCluster(ctx context.Context, client *ecs.Client, clusterId string)
return nil, fmt.Errorf("no cluster '%v' found", clusterId)
}

func describeService(ctx context.Context, client *ecs.Client, clusterId string, serviceId string) (*types.Service, error) {
func selectService(ctx context.Context, client *ecs.Client, clusterId string, serviceId string) (*types.Service, error) {
if serviceId == "" {
listServices, err := client.ListServices(ctx, &ecs.ListServicesInput{
Cluster: &clusterId,
Expand All @@ -83,7 +83,7 @@ func describeService(ctx context.Context, client *ecs.Client, clusterId string,
return nil, fmt.Errorf("no service '%v' found", serviceId)
}

func describeTask(ctx context.Context, client *ecs.Client, clusterId string, serviceId string, taskId string) (*types.Task, error) {
func selectTask(ctx context.Context, client *ecs.Client, clusterId string, serviceId string, taskId string) (*types.Task, error) {
if taskId == "" {
listTasks, err := client.ListTasks(ctx, &ecs.ListTasksInput{
Cluster: &clusterId,
Expand Down

0 comments on commit 523c395

Please sign in to comment.