mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package list
|
|
|
|
import (
|
|
pkgcmd "github.com/foomo/sesamy-cli/pkg/cmd"
|
|
"github.com/foomo/sesamy-cli/pkg/tagmanager"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// NewServer represents the server command
|
|
func NewServer(root *cobra.Command) {
|
|
cmd := &cobra.Command{
|
|
Use: "server",
|
|
Short: "List Google Tag Manager Server Container",
|
|
Args: cobra.OnlyValidArgs,
|
|
ValidArgs: []cobra.Completion{
|
|
"built-in-variables",
|
|
"clients",
|
|
"environments",
|
|
"folders",
|
|
"gtag-config",
|
|
"status",
|
|
"tags",
|
|
"templates",
|
|
"templates-data",
|
|
"transformations",
|
|
"triggers",
|
|
"variables",
|
|
"zones",
|
|
},
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
resource := args[0]
|
|
l := pkgcmd.Logger()
|
|
l.Info("☕ Listing Server Container resources: " + resource)
|
|
|
|
cfg, err := pkgcmd.ReadConfig(l, cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tm, err := tagmanager.New(
|
|
cmd.Context(),
|
|
l,
|
|
cfg.GoogleTagManager.AccountID,
|
|
cfg.GoogleTagManager.ServerContainer,
|
|
tagmanager.WithRequestQuota(cfg.GoogleAPI.RequestQuota),
|
|
tagmanager.WithClientOptions(cfg.GoogleAPI.GetClientOption()),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := tm.EnsureWorkspaceID(cmd.Context()); err != nil {
|
|
return err
|
|
}
|
|
|
|
return list(cmd.Context(), l, tm, resource)
|
|
},
|
|
}
|
|
|
|
root.AddCommand(cmd)
|
|
}
|