Skip to content

Commit

Permalink
feat: reafactor terraform to opentofu
Browse files Browse the repository at this point in the history
  • Loading branch information
gamunu committed Mar 3, 2024
1 parent d34132f commit 7925dcc
Show file tree
Hide file tree
Showing 42 changed files with 120 additions and 240 deletions.
88 changes: 0 additions & 88 deletions docs/telemetry.md

This file was deleted.

6 changes: 3 additions & 3 deletions internal/cmd/serve_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *ServeCommand) Run(args []string) int {
logger.Printf("Custom request concurrency set to %d", c.reqConcurrency)
}

logger.Printf("Starting terraform-ls %s", c.Version)
logger.Printf("Starting opentofu-ls %s", c.Version)

ctx = lsctx.WithLanguageServerVersion(ctx, c.Version)

Expand Down Expand Up @@ -148,7 +148,7 @@ func (c *ServeCommand) Run(args []string) int {

func (c *ServeCommand) otelResourceAttributes() []attribute.KeyValue {
return []attribute.KeyValue{
semconv.ServiceName("terraform-ls"),
semconv.ServiceName("opentofu-ls"),
semconv.ServiceVersion(c.Version),
attribute.Int("process.pid", os.Getpid()),
attribute.Int("runtime.NumCPU", runtime.NumCPU()),
Expand Down Expand Up @@ -202,7 +202,7 @@ func writeMemoryProfileInto(rawPath string) error {

func (c *ServeCommand) Help() string {
helpText := `
Usage: terraform-ls serve [options]
Usage: opentofu-ls serve [options]
` + c.Synopsis() + "\n\n" + helpForFlags(c.flags())

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/version_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *VersionCommand) Run(args []string) int {

func (c *VersionCommand) Help() string {
helpText := `
Usage: terraform-ls version [-json]
Usage: opentofu-ls version [-json]
` + c.Synopsis() + "\n\n" + helpForFlags(c.flags())

Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestDecoder_CodeLensesForFile_concurrencyBug(t *testing.T) {
defer wg.Done()
_, err := d.CodeLensesForFile(ctx, lang.Path{
Path: dirName,
LanguageID: "terraform",
LanguageID: "opentofu",
}, "main.tf")
if err != nil {
t.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/validations/unreferenced_origin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestUnreferencedOrigins(t *testing.T) {
},
TargetPath: lang.Path{
Path: "./submodule",
LanguageID: "terraform",
LanguageID: "opentofu",
},
Constraints: reference.OriginConstraints{},
},
Expand Down
12 changes: 6 additions & 6 deletions internal/filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestFilesystem_ReadFile_memOnly(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte(content),
},
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestFilesystem_ReadFile_memAndOs(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte(memContent),
},
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestFilesystem_ReadDir_memAndOs(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte("test"),
},
Expand All @@ -167,7 +167,7 @@ func TestFilesystem_ReadDir_memFsOnly(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte("test"),
},
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestFilesystem_Open_memOnly(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte("test"),
},
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestFilesystem_Open_memAndOs(t *testing.T) {
testHandle: &document.Document{
Dir: testHandle.Dir,
Filename: testHandle.Filename,
LanguageID: "terraform",
LanguageID: "opentofu",
Version: 0,
Text: []byte(memContent),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/hooks/module_source_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestHooks_LocalModuleSources(t *testing.T) {

ctx = decoder.WithPath(ctx, lang.Path{
Path: tmpDir,
LanguageID: "terraform",
LanguageID: "opentofu",
})
s, err := state.NewStateStore()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/hooks/module_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestHooks_RegistryModuleVersions(t *testing.T) {

ctx = decoder.WithPath(ctx, lang.Path{
Path: tmpDir,
LanguageID: "terraform",
LanguageID: "opentofu",
})
ctx = decoder.WithPos(ctx, hcl.Pos{
Line: 2,
Expand Down
22 changes: 11 additions & 11 deletions internal/langserver/handlers/code_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestLangServer_codeActionWithoutInitialization(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": "provider \"github\" {}",
"uri": "%s/main.tf"
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestLangServer_codeAction_basic(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": "provider \"test\" {\n\n }\n",
"uri": "%s/main.tf"
}
Expand All @@ -117,14 +117,14 @@ func TestLangServer_codeAction_basic(t *testing.T) {
"start": { "line": 0, "character": 0 },
"end": { "line": 1, "character": 0 }
},
"context": { "diagnostics": [], "only": ["source.formatAll.terraform"] }
"context": { "diagnostics": [], "only": ["source.formatAll.opentofu"] }
}`, tmpDir.URI)}, fmt.Sprintf(`{
"jsonrpc": "2.0",
"id": 3,
"result": [
{
"title": "Format Document",
"kind": "source.formatAll.terraform",
"kind": "source.formatAll.opentofu",
"edit":{
"changes":{
"%s/main.tf": [
Expand Down Expand Up @@ -189,7 +189,7 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
}`,
},
{
name: "source.formatAll.terraform code action requested",
name: "source.formatAll.opentofu code action requested",
request: &langserver.CallRequest{
Method: "textDocument/codeAction",
ReqParams: fmt.Sprintf(`{
Expand All @@ -198,15 +198,15 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
"start": { "line": 0, "character": 0 },
"end": { "line": 1, "character": 0 }
},
"context": { "diagnostics": [], "only": ["source.formatAll.terraform"] }
"context": { "diagnostics": [], "only": ["source.formatAll.opentofu"] }
}`, tmpDir.URI)},
want: fmt.Sprintf(`{
"jsonrpc": "2.0",
"id": 3,
"result": [
{
"title":"Format Document",
"kind":"source.formatAll.terraform",
"kind":"source.formatAll.opentofu",
"edit":{
"changes": {
"%s/main.tf": [
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
}`, tmpDir.URI),
},
{
name: "source.fixAll and source.formatAll.terraform code action requested",
name: "source.fixAll and source.formatAll.opentofu code action requested",
request: &langserver.CallRequest{
Method: "textDocument/codeAction",
ReqParams: fmt.Sprintf(`{
Expand All @@ -247,7 +247,7 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
"start": { "line": 0, "character": 0 },
"end": { "line": 1, "character": 0 }
},
"context": { "diagnostics": [], "only": ["source.fixAll", "source.formatAll.terraform"] }
"context": { "diagnostics": [], "only": ["source.fixAll", "source.formatAll.opentofu"] }
}`, tmpDir.URI),
},
want: fmt.Sprintf(`{
Expand All @@ -256,7 +256,7 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
"result": [
{
"title": "Format Document",
"kind": "source.formatAll.terraform",
"kind": "source.formatAll.opentofu",
"edit": {
"changes": {
"%s/main.tf": [
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestLangServer_codeAction_no_code_action_requested(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": "provider \"test\" {\n\n }\n",
"uri": "%s/main.tf"
}
Expand Down
6 changes: 3 additions & 3 deletions internal/langserver/handlers/code_lens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestCodeLens_withoutOptIn(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": "provider \"test\" {\n\n}\n",
"uri": "%s/main.tf"
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestCodeLens_referenceCount(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": %q,
"uri": "%s/main.tf"
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestCodeLens_referenceCount_crossModule(t *testing.T) {
ReqParams: fmt.Sprintf(`{
"textDocument": {
"version": 0,
"languageId": "terraform",
"languageId": "opentofu",
"text": %q,
"uri": "%s/main.tf"
}
Expand Down
Loading

0 comments on commit 7925dcc

Please sign in to comment.