11package resources
22
33import (
4+ "encoding/json"
45 "fmt"
56
67 "github.com/MakeNowJust/heredoc/v2"
@@ -19,6 +20,7 @@ func NewResourcesCmd() *cobra.Command {
1920 var version string
2021 var metadata map [string ]string
2122 var configArray map [string ]string
23+ var links map [string ]string
2224
2325 cmd := & cobra.Command {
2426 Use : "resources [flags]" ,
@@ -42,6 +44,14 @@ func NewResourcesCmd() *cobra.Command {
4244 // Convert configArray into a nested map[string]interface{}
4345 config := cliutil .ConvertConfigArrayToNestedMap (configArray )
4446
47+ if len (links ) > 0 {
48+ linksJSON , err := json .Marshal (links )
49+ if err != nil {
50+ return fmt .Errorf ("failed to marshal links: %w" , err )
51+ }
52+ metadata ["ctrlplane/links" ] = string (linksJSON )
53+ }
54+
4555 // Extrat into vars
4656 resp , err := client .UpsertTargets (cmd .Context (), api.UpsertTargetsJSONRequestBody {
4757 Targets : []struct {
@@ -86,6 +96,7 @@ func NewResourcesCmd() *cobra.Command {
8696 cmd .Flags ().StringVar (& version , "version" , "" , "Version of the resource (required)" )
8797 cmd .Flags ().StringToStringVar (& metadata , "metadata" , make (map [string ]string ), "Metadata key-value pairs (e.g. --metadata key=value)" )
8898 cmd .Flags ().StringToStringVar (& configArray , "config" , make (map [string ]string ), "Config key-value pairs with nested values (can be specified multiple times)" )
99+ cmd .Flags ().StringToStringVar (& links , "link" , make (map [string ]string ), "Links key-value pairs (can be specified multiple times)" )
89100
90101 cmd .MarkFlagRequired ("version" )
91102 cmd .MarkFlagRequired ("workspace" )
0 commit comments