5
5
"fmt"
6
6
"strings"
7
7
8
- "github.com/gosimple/slug"
9
8
hookdecksdk "github.com/hookdeck/hookdeck-go-sdk"
10
9
hookdeckclient "github.com/hookdeck/hookdeck-go-sdk/client"
11
10
log "github.com/sirupsen/logrus"
@@ -80,14 +79,17 @@ func ensureConnections(client *hookdeckclient.Client, connections []*hookdecksdk
80
79
log .Debug (fmt .Sprintf ("No connection found. Creating a connection for Source \" %s\" , Connection \" %s\" , and CLI path \" %s\" " , sources [0 ].Name , connectionFilterString , cliPath ))
81
80
82
81
connectionDetails := struct {
83
- Label string `survey:"label"`
84
- Path string `survey:"path"`
82
+ ConnectionName string
83
+ DestinationName string
84
+ Path string
85
85
}{}
86
86
87
+ connectionDetails .DestinationName = fmt .Sprintf ("%s-%s" , "cli" , sources [0 ].Name )
88
+
87
89
if len (connectionFilterString ) == 0 {
88
- connectionDetails .Label = "cli"
90
+ connectionDetails .ConnectionName = fmt . Sprintf ( "%s_to_%s" , sources [ 0 ]. Name , connectionDetails . DestinationName )
89
91
} else {
90
- connectionDetails .Label = connectionFilterString
92
+ connectionDetails .ConnectionName = connectionFilterString
91
93
}
92
94
93
95
if len (cliPath ) == 0 {
@@ -96,13 +98,11 @@ func ensureConnections(client *hookdeckclient.Client, connections []*hookdecksdk
96
98
connectionDetails .Path = cliPath
97
99
}
98
100
99
- alias := slug .Make (connectionDetails .Label )
100
-
101
101
connection , err := client .Connection .Create (context .Background (), & hookdecksdk.ConnectionCreateRequest {
102
- Name : hookdecksdk .OptionalOrNull (& alias ),
102
+ Name : hookdecksdk .OptionalOrNull (& connectionDetails . ConnectionName ),
103
103
SourceId : hookdecksdk .OptionalOrNull (& sources [0 ].Id ),
104
104
Destination : hookdecksdk .OptionalOrNull (& hookdecksdk.ConnectionCreateRequestDestination {
105
- Name : alias ,
105
+ Name : connectionDetails . DestinationName ,
106
106
CliPath : & connectionDetails .Path ,
107
107
}),
108
108
})
0 commit comments