tedsmitt / ecsgo

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.
Apache License 2.0
81 stars 13 forks source link

Error when Cluster has no services #14

Closed tedsmitt closed 2 years ago

tedsmitt commented 2 years ago

Inside of getService we return an error if the length of services is 0

    if len(list.ServiceArns) > 0 {
        var serviceNames []string
        for _, c := range list.ServiceArns {
            arnSplit := strings.Split(*c, "/")
            name := arnSplit[len(arnSplit)-1]
            serviceNames = append(serviceNames, name)
        }
        selection, err := selectService(serviceNames)
        if err != nil {
            e.err <- err
            return
        }
        if selection == backOpt {
            e.cmd <- "getCluster"
            return
        }
        e.service = selection
        e.cmd <- "getTask"
        return
    } else {
        e.err <- err
        return
    }

We should allow for scenarios where the cluster has no services, and has tasks run ad-hoc via external orchestrators (such as Jenkins) or scheduled tasks.