Skip to content

Commit

Permalink
Rename some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Nov 12, 2024
1 parent 3cc95e3 commit cb88944
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
11 changes: 6 additions & 5 deletions cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ var logsCmd = &cobra.Command{
}
logOptions := container.LogConfiguration.Options
awslogsGroup := logOptions["awslogs-group"]
describedLogGroups, err := cwlogsClient.DescribeLogGroups(context.TODO(), &cloudwatchlogs.DescribeLogGroupsInput{
describeLogGroups, err := cwlogsClient.DescribeLogGroups(context.TODO(), &cloudwatchlogs.DescribeLogGroupsInput{
LogGroupNamePrefix: &awslogsGroup,
})
if err != nil {
log.Fatal(err)
}

// TODO: get log_group ARN from SDK
startLiveTail, _ := cwlogsClient.StartLiveTail(context.TODO(), &cloudwatchlogs.StartLiveTailInput{
LogGroupIdentifiers: []string{*describedLogGroups.LogGroups[0].LogGroupArn},
startLiveTail, err := cwlogsClient.StartLiveTail(context.TODO(), &cloudwatchlogs.StartLiveTailInput{
LogGroupIdentifiers: []string{*describeLogGroups.LogGroups[0].LogGroupArn},
LogStreamNamePrefixes: []string{logOptions["awslogs-stream-prefix"]},
})
if err != nil {
log.Fatal(err)
}
stream := startLiveTail.GetStream()
var wg sync.WaitGroup
wg.Add(1)
Expand Down
20 changes: 10 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ func Execute() {

func describeCluster(ctx context.Context, client *ecs.Client, clusterId string) (*types.Cluster, error) {
if clusterId == "" {
listedClusters, err := client.ListClusters(ctx, &ecs.ListClustersInput{})
listClusters, err := client.ListClusters(ctx, &ecs.ListClustersInput{})
if err != nil {
return nil, err
}
clusterArn, err := pterm.DefaultInteractiveSelect.WithOptions(listedClusters.ClusterArns).Show("Cluster")
clusterArn, err := pterm.DefaultInteractiveSelect.WithOptions(listClusters.ClusterArns).Show("Cluster")
if err != nil {
return nil, err
}
clusterId = clusterArn
}
describedClusters, err := client.DescribeClusters(ctx, &ecs.DescribeClustersInput{
describeClusters, err := client.DescribeClusters(ctx, &ecs.DescribeClustersInput{
Clusters: []string{clusterId},
})
if err != nil {
return nil, err
}
if len(describedClusters.Clusters) == 1 {
return &describedClusters.Clusters[0], nil
if len(describeClusters.Clusters) == 1 {
return &describeClusters.Clusters[0], nil
}
return nil, fmt.Errorf("no cluster '%v' found", clusterId)
}
Expand All @@ -63,15 +63,15 @@ func describeTask(ctx context.Context, client *ecs.Client, clusterId string, tas
}
taskId = taskArn
}
describedTasks, err := client.DescribeTasks(ctx, &ecs.DescribeTasksInput{
describeTasks, err := client.DescribeTasks(ctx, &ecs.DescribeTasksInput{
Cluster: &clusterId,
Tasks: []string{taskId},
})
if err != nil {
return nil, err
}
if len(describedTasks.Tasks) == 1 {
return &describedTasks.Tasks[0], nil
if len(describeTasks.Tasks) == 1 {
return &describeTasks.Tasks[0], nil
}
return nil, fmt.Errorf("no task '%v' found", taskId)
}
Expand All @@ -97,13 +97,13 @@ func describeContainer(containers []types.Container, containerId string) (*types
}

func describeContainerDefinition(ctx context.Context, client *ecs.Client, taskDefinitionArn string, containerId string) (*types.ContainerDefinition, error) {
describedTaskDefinition, err := client.DescribeTaskDefinition(ctx, &ecs.DescribeTaskDefinitionInput{
describeTaskDefinition, err := client.DescribeTaskDefinition(ctx, &ecs.DescribeTaskDefinitionInput{
TaskDefinition: &taskDefinitionArn,
})
if err != nil {
return nil, err
}
containerDefinitions := describedTaskDefinition.TaskDefinition.ContainerDefinitions
containerDefinitions := describeTaskDefinition.TaskDefinition.ContainerDefinitions
if containerId == "" {
var containerNames []string
for _, containerDefinition := range containerDefinitions {
Expand Down

0 comments on commit cb88944

Please sign in to comment.