From e9fd16b7a8b519380528e8ad6b4ddf93dd3d5d58 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Fri, 13 Oct 2023 10:26:19 +1100 Subject: [PATCH] refactor: make get deployment more useful by using build name --- cmd/get.go | 93 +++++++++++++------ docs/commands/lagoon.md | 2 +- docs/commands/lagoon_get.md | 2 +- docs/commands/lagoon_get_deployment.md | 10 +- docs/commands/lagoon_list.md | 4 +- docs/commands/lagoon_list_backups.md | 2 +- docs/commands/lagoon_list_deployments.md | 2 +- .../lagoon_list_deploytarget-configs.md | 2 +- docs/commands/lagoon_list_deploytargets.md | 2 +- docs/commands/lagoon_list_environments.md | 2 +- docs/commands/lagoon_list_group-projects.md | 2 +- docs/commands/lagoon_list_groups.md | 2 +- docs/commands/lagoon_list_invokable-tasks.md | 2 +- docs/commands/lagoon_list_notification.md | 2 +- .../lagoon_list_projects-by-metadata.md | 2 +- docs/commands/lagoon_list_projects.md | 2 +- docs/commands/lagoon_list_tasks.md | 2 +- docs/commands/lagoon_list_users.md | 2 +- docs/commands/lagoon_list_variables.md | 2 +- go.mod | 24 +++-- go.sum | 7 +- internal/lagoon/client/lgraphql/lgraphql.go | 12 ++- 22 files changed, 111 insertions(+), 71 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 193aef2c..484c33ba 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -1,14 +1,16 @@ package cmd import ( + "context" "encoding/json" "fmt" "os" "github.com/spf13/cobra" "github.com/spf13/pflag" - "github.com/uselagoon/lagoon-cli/pkg/api" "github.com/uselagoon/lagoon-cli/pkg/output" + l "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" ) // GetFlags . @@ -71,41 +73,77 @@ var getProjectCmd = &cobra.Command{ }, } -var getDeploymentCmd = &cobra.Command{ +var getDeploymentByNameCmd = &cobra.Command{ Use: "deployment", Aliases: []string{"d"}, - Short: "Get a build log by remote id", - Run: func(cmd *cobra.Command, args []string) { - getProjectFlags := parseGetFlags(*cmd.Flags()) - if getProjectFlags.RemoteID == "" { - fmt.Println("Missing arguments: Remote ID is not defined") - cmd.Help() - os.Exit(1) + Short: "Get a deployment by name", + Long: `Get a deployment by name +This returns information about a deployment, the logs of this build can also be retrieved`, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err } - returnedJSON, err := eClient.GetDeploymentLog(getProjectFlags.RemoteID) + + buildName, err := cmd.Flags().GetString("name") if err != nil { - output.RenderError(err.Error(), outputOptions) - os.Exit(1) + return err } - if string(returnedJSON) == "null" { - output.RenderInfo(fmt.Sprintf("No deployment for remoteId '%s'", getProjectFlags.RemoteID), outputOptions) - os.Exit(0) + showLogs, err := cmd.Flags().GetBool("logs") + if err != nil { + return err } - var deployment api.Deployment - err = json.Unmarshal([]byte(returnedJSON), &deployment) + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + &token, + debug) + deployment, err := l.GetDeploymentByName(context.TODO(), cmdProjectName, cmdProjectEnvironment, buildName, showLogs, lc) if err != nil { - output.RenderError(err.Error(), outputOptions) - os.Exit(1) + return err } - if deployment.BuildLog != "" { - fmt.Println(deployment.BuildLog) - } else { - fmt.Println("Log data is not available") + if showLogs { + dataMain := output.Table{ + Header: []string{ + "Logs", + }, + Data: []output.Data{ + { + returnNonEmptyString(deployment.BuildLog), + }, + }, + } + output.RenderOutput(dataMain, outputOptions) + return nil } - + dataMain := output.Table{ + Header: []string{ + "ID", + "RemoteID", + "Name", + "Status", + "Created", + "Started", + "Completed", + }, + Data: []output.Data{ + { + returnNonEmptyString(fmt.Sprintf("%v", deployment.ID)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)), + }, + }, + } + output.RenderOutput(dataMain, outputOptions) + return nil }, } - var getEnvironmentCmd = &cobra.Command{ Use: "environment", Aliases: []string{"e"}, @@ -168,15 +206,16 @@ var getToken = &cobra.Command{ func init() { getCmd.AddCommand(getAllUserKeysCmd) - getCmd.AddCommand(getDeploymentCmd) getCmd.AddCommand(getEnvironmentCmd) getCmd.AddCommand(getProjectCmd) getCmd.AddCommand(getProjectKeyCmd) getCmd.AddCommand(getUserKeysCmd) getCmd.AddCommand(getTaskByID) getCmd.AddCommand(getToken) + getCmd.AddCommand(getDeploymentByNameCmd) getTaskByID.Flags().IntP("id", "I", 0, "ID of the task") getTaskByID.Flags().BoolP("logs", "L", false, "Show the task logs if available") getProjectKeyCmd.Flags().BoolVarP(&revealValue, "reveal", "", false, "Reveal the variable values") - getDeploymentCmd.Flags().StringVarP(&remoteID, "remoteid", "R", "", "The remote ID of the deployment") + getDeploymentByNameCmd.Flags().StringP("name", "N", "", "The name of the deployment (eg, lagoon-build-abcdef)") + getDeploymentByNameCmd.Flags().BoolP("logs", "L", false, "Show the build logs if available") } diff --git a/docs/commands/lagoon.md b/docs/commands/lagoon.md index 6cfb47c0..7ab9ad66 100644 --- a/docs/commands/lagoon.md +++ b/docs/commands/lagoon.md @@ -39,7 +39,7 @@ lagoon [flags] * [lagoon get](lagoon_get.md) - Get info on a resource * [lagoon import](lagoon_import.md) - Import a config from a yaml file * [lagoon kibana](lagoon_kibana.md) - Launch the kibana interface -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications * [lagoon login](lagoon_login.md) - Log into a Lagoon instance * [lagoon retrieve](lagoon_retrieve.md) - Trigger a retrieval operation on backups * [lagoon run](lagoon_run.md) - Run a task against an environment diff --git a/docs/commands/lagoon_get.md b/docs/commands/lagoon_get.md index f6ceda5b..95a8d6c1 100644 --- a/docs/commands/lagoon_get.md +++ b/docs/commands/lagoon_get.md @@ -34,7 +34,7 @@ Get info on a resource * [lagoon](lagoon.md) - Command line integration for Lagoon * [lagoon get all-user-sshkeys](lagoon_get_all-user-sshkeys.md) - Get all user SSH keys * [lagoon get backup](lagoon_get_backup.md) - Get a backup download link -* [lagoon get deployment](lagoon_get_deployment.md) - Get a build log by remote id +* [lagoon get deployment](lagoon_get_deployment.md) - Get a deployment by name * [lagoon get environment](lagoon_get_environment.md) - Get details about an environment * [lagoon get project](lagoon_get_project.md) - Get details about a project * [lagoon get project-key](lagoon_get_project-key.md) - Get a projects public key diff --git a/docs/commands/lagoon_get_deployment.md b/docs/commands/lagoon_get_deployment.md index e98efa59..5bdbcc47 100644 --- a/docs/commands/lagoon_get_deployment.md +++ b/docs/commands/lagoon_get_deployment.md @@ -1,10 +1,11 @@ ## lagoon get deployment -Get a build log by remote id +Get a deployment by name ### Synopsis -Get a build log by remote id +Get a deployment by name +This returns information about a deployment, the logs of this build can also be retrieved ``` lagoon get deployment [flags] @@ -13,8 +14,9 @@ lagoon get deployment [flags] ### Options ``` - -h, --help help for deployment - -R, --remoteid string The remote ID of the deployment + -h, --help help for deployment + -L, --logs Show the build logs if available + -N, --name string The name of the deployment (eg, lagoon-build-abcdef) ``` ### Options inherited from parent commands diff --git a/docs/commands/lagoon_list.md b/docs/commands/lagoon_list.md index 2b48e078..f80566ae 100644 --- a/docs/commands/lagoon_list.md +++ b/docs/commands/lagoon_list.md @@ -1,10 +1,10 @@ ## lagoon list -List projects, deployments, variables or notifications +List projects, environments, deployments, variables or notifications ### Synopsis -List projects, deployments, variables or notifications +List projects, environments, deployments, variables or notifications ### Options diff --git a/docs/commands/lagoon_list_backups.md b/docs/commands/lagoon_list_backups.md index 962e9c92..6a209b04 100644 --- a/docs/commands/lagoon_list_backups.md +++ b/docs/commands/lagoon_list_backups.md @@ -35,5 +35,5 @@ lagoon list backups [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deployments.md b/docs/commands/lagoon_list_deployments.md index 6175372a..25a09aff 100644 --- a/docs/commands/lagoon_list_deployments.md +++ b/docs/commands/lagoon_list_deployments.md @@ -35,5 +35,5 @@ lagoon list deployments [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deploytarget-configs.md b/docs/commands/lagoon_list_deploytarget-configs.md index d3806da4..723d714e 100644 --- a/docs/commands/lagoon_list_deploytarget-configs.md +++ b/docs/commands/lagoon_list_deploytarget-configs.md @@ -35,5 +35,5 @@ lagoon list deploytarget-configs [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_deploytargets.md b/docs/commands/lagoon_list_deploytargets.md index eb899903..3791e812 100644 --- a/docs/commands/lagoon_list_deploytargets.md +++ b/docs/commands/lagoon_list_deploytargets.md @@ -35,5 +35,5 @@ lagoon list deploytargets [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_environments.md b/docs/commands/lagoon_list_environments.md index 504151f2..5186199d 100644 --- a/docs/commands/lagoon_list_environments.md +++ b/docs/commands/lagoon_list_environments.md @@ -35,5 +35,5 @@ lagoon list environments [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_group-projects.md b/docs/commands/lagoon_list_group-projects.md index a1213b98..803d32db 100644 --- a/docs/commands/lagoon_list_group-projects.md +++ b/docs/commands/lagoon_list_group-projects.md @@ -36,5 +36,5 @@ lagoon list group-projects [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_groups.md b/docs/commands/lagoon_list_groups.md index 40f5cf53..cad64322 100644 --- a/docs/commands/lagoon_list_groups.md +++ b/docs/commands/lagoon_list_groups.md @@ -35,5 +35,5 @@ lagoon list groups [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_invokable-tasks.md b/docs/commands/lagoon_list_invokable-tasks.md index 0c27bef6..77e92550 100644 --- a/docs/commands/lagoon_list_invokable-tasks.md +++ b/docs/commands/lagoon_list_invokable-tasks.md @@ -35,5 +35,5 @@ lagoon list invokable-tasks [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_notification.md b/docs/commands/lagoon_list_notification.md index 5b4f86b5..f89a4300 100644 --- a/docs/commands/lagoon_list_notification.md +++ b/docs/commands/lagoon_list_notification.md @@ -31,7 +31,7 @@ List all notifications or notifications on projects ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications * [lagoon list notification email](lagoon_list_notification_email.md) - List all email notification details (alias: e) * [lagoon list notification microsoftteams](lagoon_list_notification_microsoftteams.md) - List all Microsoft Teams notification details (alias: m) * [lagoon list notification project-email](lagoon_list_notification_project-email.md) - List email details about a project (alias: pe) diff --git a/docs/commands/lagoon_list_projects-by-metadata.md b/docs/commands/lagoon_list_projects-by-metadata.md index ca245d5e..981142ac 100644 --- a/docs/commands/lagoon_list_projects-by-metadata.md +++ b/docs/commands/lagoon_list_projects-by-metadata.md @@ -38,5 +38,5 @@ lagoon list projects-by-metadata [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_projects.md b/docs/commands/lagoon_list_projects.md index 7b9fa690..ba3b8559 100644 --- a/docs/commands/lagoon_list_projects.md +++ b/docs/commands/lagoon_list_projects.md @@ -35,5 +35,5 @@ lagoon list projects [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_tasks.md b/docs/commands/lagoon_list_tasks.md index 6d3aac8c..11e2fe80 100644 --- a/docs/commands/lagoon_list_tasks.md +++ b/docs/commands/lagoon_list_tasks.md @@ -35,5 +35,5 @@ lagoon list tasks [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_users.md b/docs/commands/lagoon_list_users.md index 7a22d8d7..7988ae11 100644 --- a/docs/commands/lagoon_list_users.md +++ b/docs/commands/lagoon_list_users.md @@ -36,5 +36,5 @@ lagoon list users [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_variables.md b/docs/commands/lagoon_list_variables.md index a4c01425..59f6eed4 100644 --- a/docs/commands/lagoon_list_variables.md +++ b/docs/commands/lagoon_list_variables.md @@ -36,5 +36,5 @@ lagoon list variables [flags] ### SEE ALSO -* [lagoon list](lagoon_list.md) - List projects, deployments, variables or notifications +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/go.mod b/go.mod index 4ec1069e..9f02972f 100644 --- a/go.mod +++ b/go.mod @@ -4,36 +4,32 @@ go 1.16 require ( github.com/Masterminds/semver v1.4.2 + github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/golang/mock v1.6.0 github.com/google/go-github v0.0.0-20180716180158-c0b63e2f9bb1 + github.com/google/go-querystring v1.0.0 // indirect github.com/google/uuid v1.3.0 + github.com/guregu/null v4.0.0+incompatible github.com/hashicorp/go-version v1.6.0 github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434 github.com/machinebox/graphql v0.2.3-0.20181106130121-3a9253180225 github.com/manifoldco/promptui v0.3.2 + // workaround for https://github.com/manifoldco/promptui/issues/98 + github.com/nicksnyder/go-i18n v1.10.1 // indirect github.com/olekukonko/tablewriter v0.0.4 github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.3 github.com/stretchr/testify v1.2.2 + github.com/uselagoon/machinery v0.0.12 golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b - gopkg.in/yaml.v2 v2.2.8 - sigs.k8s.io/yaml v1.2.0 -) - -require ( - github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect - github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect - github.com/google/go-querystring v1.0.0 // indirect - github.com/guregu/null v4.0.0+incompatible - // workaround for https://github.com/manifoldco/promptui/issues/98 - github.com/nicksnyder/go-i18n v1.10.1 // indirect - github.com/uselagoon/machinery v0.0.11 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780 // indirect + gopkg.in/yaml.v2 v2.2.8 + sigs.k8s.io/yaml v1.2.0 ) // use this version for fixes to formatting of end header @@ -41,4 +37,6 @@ replace github.com/olekukonko/tablewriter => github.com/shreddedbacon/tablewrite // replace github.com/machinebox/graphql => ../../shreddedbacon/graphql -// replace github.com/olekukonko/tablewriter => ../../shreddedbacon/tablewriter \ No newline at end of file +// replace github.com/olekukonko/tablewriter => ../../shreddedbacon/tablewriter + +// replace github.com/uselagoon/machinery => ../machinery diff --git a/go.sum b/go.sum index fe18d60a..0976d395 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= -github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 h1:I4BOK3PBMjhWfQM2zPJKK7lOBGsrsvOB7kBELP33hiE= github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= @@ -105,8 +104,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 h1:vY5WqiEon0ZSTGM3ayVVi+twaHKHDFUVloaQ/wug9/c= github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/uselagoon/machinery v0.0.11 h1:s6EhyU/pj1+C4FdS0EqmR6C0dLsoeCd9n+5xHL1YDag= -github.com/uselagoon/machinery v0.0.11/go.mod h1:IXLxlkahEAEgpCmu9Xa/Wmjo6ja4Aoq7tf8G7VrileE= +github.com/uselagoon/machinery v0.0.12 h1:TJnA+FrL1uEhRTjJ6dExiL4G7SOQ+hUfGuWDmbW2HBA= +github.com/uselagoon/machinery v0.0.12/go.mod h1:h/qeMWQR4Qqu33x+8AulNDeolEwvb/G+aIsn/jyUtwk= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/internal/lagoon/client/lgraphql/lgraphql.go b/internal/lagoon/client/lgraphql/lgraphql.go index 15b4f101..92394f86 100644 --- a/internal/lagoon/client/lgraphql/lgraphql.go +++ b/internal/lagoon/client/lgraphql/lgraphql.go @@ -1564,11 +1564,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error