-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utm parameters to
module.*
commands (#923)
* Add utm parameters to module.* commands * update test data * log error instead of returning it
- Loading branch information
1 parent
dd6733a
commit ba5501c
Showing
10 changed files
with
104 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
"github.com/hashicorp/terraform-ls/internal/utm" | ||
) | ||
|
||
func docsURL(ctx context.Context, rawURL, utmContent string) (*url.URL, error) { | ||
u, err := url.Parse(rawURL) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
q := u.Query() | ||
q.Set("utm_source", utm.UtmSource) | ||
if medium := utm.UtmMedium(ctx); medium != "" { | ||
q.Set("utm_medium", medium) | ||
} | ||
|
||
if utmContent != "" { | ||
q.Set("utm_content", utmContent) | ||
} | ||
|
||
u.RawQuery = q.Encode() | ||
|
||
return u, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package command | ||
|
||
import "github.com/hashicorp/terraform-ls/internal/state" | ||
import ( | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-ls/internal/state" | ||
) | ||
|
||
type CmdHandler struct { | ||
StateStore *state.StateStore | ||
Logger *log.Logger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package utm | ||
|
||
import ( | ||
"context" | ||
|
||
ilsp "github.com/hashicorp/terraform-ls/internal/lsp" | ||
) | ||
|
||
const UtmSource = "terraform-ls" | ||
|
||
func UtmMedium(ctx context.Context) string { | ||
clientName, ok := ilsp.ClientName(ctx) | ||
if ok { | ||
return clientName | ||
} | ||
|
||
return "" | ||
} |