Skip to content

Commit

Permalink
Merge pull request #195 from ngrok/kc/add-name-to-tunnels
Browse files Browse the repository at this point in the history
Plumb `name` field through for agent and cli flags
  • Loading branch information
KristopherPaulsen authored Oct 15, 2024
2 parents 88d3d64 + 99aabfd commit f7c015f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type commonOpts struct {
// user supplied description of the endpoint
Description string

// user supplied name for the endpoint
Name string

// If not set, defaults to a URI in the format `app://hostname/path/to/executable?pid=12345`
ForwardsTo string

Expand Down
1 change: 1 addition & 0 deletions config/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (cfg *httpOptions) WithForwardsTo(url *url.URL) {

func (cfg httpOptions) Extra() proto.BindExtra {
return proto.BindExtra{
Name: cfg.Name,
Metadata: cfg.Metadata,
Description: cfg.Description,
Bindings: cfg.Bindings,
Expand Down
1 change: 1 addition & 0 deletions config/labeled.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (cfg *labeledOptions) WithForwardsTo(url *url.URL) {

func (cfg labeledOptions) Extra() proto.BindExtra {
return proto.BindExtra{
Name: cfg.Name,
Metadata: cfg.Metadata,
Description: cfg.Description,
}
Expand Down
28 changes: 28 additions & 0 deletions config/name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package config

type nameOption string

func WithName(name string) interface {
HTTPEndpointOption
TCPEndpointOption
TLSEndpointOption
LabeledTunnelOption
} {
return nameOption(name)
}

func (opt nameOption) ApplyHTTP(opts *httpOptions) {
opts.Name = string(opt)
}

func (opt nameOption) ApplyTLS(opts *tlsOptions) {
opts.Name = string(opt)
}

func (opt nameOption) ApplyTCP(opts *tcpOptions) {
opts.Name = string(opt)
}

func (opt nameOption) ApplyLabeled(opts *labeledOptions) {
opts.Name = string(opt)
}
1 change: 1 addition & 0 deletions config/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (cfg *tcpOptions) WithForwardsTo(url *url.URL) {

func (cfg tcpOptions) Extra() proto.BindExtra {
return proto.BindExtra{
Name: cfg.Name,
Metadata: cfg.Metadata,
Description: cfg.Description,
Bindings: cfg.Bindings,
Expand Down
1 change: 1 addition & 0 deletions config/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (cfg *tlsOptions) WithForwardsTo(url *url.URL) {

func (cfg tlsOptions) Extra() proto.BindExtra {
return proto.BindExtra{
Name: cfg.Name,
Metadata: cfg.Metadata,
Description: cfg.Description,
Bindings: cfg.Bindings,
Expand Down
1 change: 1 addition & 0 deletions internal/tunnel/proto/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ type Bind struct {
}

type BindExtra struct {
Name string
Token string
IPPolicyRef string
Metadata string
Expand Down

0 comments on commit f7c015f

Please sign in to comment.