Skip to content

Commit

Permalink
Add withTags for tailscale
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Jan 6, 2023
1 parent c74d157 commit 4e1d2cf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type TailscaleInContainer struct {
headscaleCert []byte
headscaleHostname string
withSSH bool
withTags []string
}

type Option = func(c *TailscaleInContainer)
Expand Down Expand Up @@ -87,6 +88,12 @@ func WithHeadscaleName(hsName string) Option {
}
}

func WithTags(tags []string) Option {
return func(tsic *TailscaleInContainer) {
tsic.withTags = tags
}
}

func WithSSH() Option {
return func(tsic *TailscaleInContainer) {
tsic.withSSH = true
Expand Down Expand Up @@ -233,6 +240,12 @@ func (t *TailscaleInContainer) Up(
command = append(command, "--ssh")
}

if len(t.withTags) > 0 {
command = append(command,
fmt.Sprintf(`--advertise-tags=%s`, strings.Join(t.withTags, ",")),
)
}

if _, _, err := t.Execute(command); err != nil {
return fmt.Errorf("failed to join tailscale client: %w", err)
}
Expand Down

0 comments on commit 4e1d2cf

Please sign in to comment.