From 5da08f5890a77c92cd402409c87e476bf103c60c Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Wed, 13 Nov 2024 15:31:09 -0500 Subject: [PATCH] add links command --- cmd/ctrlc/root/api/create/release/release.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/ctrlc/root/api/create/release/release.go b/cmd/ctrlc/root/api/create/release/release.go index e4a8718..9de2bae 100644 --- a/cmd/ctrlc/root/api/create/release/release.go +++ b/cmd/ctrlc/root/api/create/release/release.go @@ -1,6 +1,7 @@ package release import ( + "encoding/json" "fmt" "time" @@ -16,8 +17,10 @@ func NewReleaseCmd() *cobra.Command { var deploymentID string var metadata map[string]string var configArray map[string]string + var links map[string]string var createdAt string var name string + cmd := &cobra.Command{ Use: "release [flags]", Short: "Create a new release", @@ -46,6 +49,15 @@ func NewReleaseCmd() *cobra.Command { parsedTime = &t } + if len(links) > 0 { + linksJSON, err := json.Marshal(links) + if err != nil { + return fmt.Errorf("failed to marshal links: %w", err) + } + metadata["ctrlplane/links"] = string(linksJSON) + } + + config := cliutil.ConvertConfigArrayToNestedMap(configArray) resp, err := client.CreateRelease(cmd.Context(), api.CreateReleaseJSONRequestBody{ Version: versionFlag, @@ -68,6 +80,7 @@ func NewReleaseCmd() *cobra.Command { cmd.Flags().StringVar(&deploymentID, "deployment", "", "ID of the deployment (required)") cmd.Flags().StringToStringVar(&metadata, "metadata", make(map[string]string), "Metadata key-value pairs (e.g. --metadata key=value)") cmd.Flags().StringToStringVar(&configArray, "config", make(map[string]string), "Config key-value pairs with nested values (can be specified multiple times)") + cmd.Flags().StringToStringVar(&links, "link", make(map[string]string), "Links key-value pairs (can be specified multiple times)") cmd.Flags().StringVar(&createdAt, "created-at", "", "Created at timestamp (e.g. --created-at 2024-01-01T00:00:00Z) for the release channel") cmd.Flags().StringVar(&name, "name", "", "Name of the release channel")