github.com/kolanos/fargate@v0.2.3/cmd/service_env_list.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  	ECS "github.com/jpignata/fargate/ecs"
     6  	"github.com/spf13/cobra"
     7  )
     8  
     9  type ServiceEnvListOperation struct {
    10  	ServiceName string
    11  }
    12  
    13  var serviceEnvListCmd = &cobra.Command{
    14  	Use:   "list <service-name>",
    15  	Short: "Show environment variables",
    16  	Run: func(cmd *cobra.Command, args []string) {
    17  		operation := &ServiceEnvListOperation{
    18  			ServiceName: args[0],
    19  		}
    20  
    21  		serviceEnvList(operation)
    22  	},
    23  }
    24  
    25  func init() {
    26  	serviceEnvCmd.AddCommand(serviceEnvListCmd)
    27  }
    28  
    29  func serviceEnvList(operation *ServiceEnvListOperation) {
    30  	ecs := ECS.New(sess, clusterName)
    31  	service := ecs.DescribeService(operation.ServiceName)
    32  	envVars := ecs.GetEnvVarsFromTaskDefinition(service.TaskDefinitionArn)
    33  
    34  	for _, envVar := range envVars {
    35  		fmt.Printf("%s=%s\n", envVar.Key, envVar.Value)
    36  	}
    37  }