From 7925dccbfc24c7e3ad641c1f3f0f5cc2394aaba1 Mon Sep 17 00:00:00 2001 From: Gamunu Balagalla Date: Mon, 4 Mar 2024 02:31:51 +0530 Subject: [PATCH] feat: reafactor terraform to opentofu --- docs/telemetry.md | 88 ------------------- internal/cmd/serve_command.go | 6 +- internal/cmd/version_command.go | 2 +- internal/decoder/decoder_test.go | 2 +- .../validations/unreferenced_origin_test.go | 2 +- internal/filesystem/filesystem_test.go | 12 +-- internal/hooks/module_source_local_test.go | 2 +- internal/hooks/module_version_test.go | 2 +- .../langserver/handlers/code_action_test.go | 22 ++--- .../langserver/handlers/code_lens_test.go | 6 +- internal/langserver/handlers/complete_test.go | 18 ++-- .../langserver/handlers/did_change_test.go | 2 +- internal/langserver/handlers/did_open_test.go | 6 +- .../langserver/handlers/document_link_test.go | 2 +- .../langserver/handlers/execute_command.go | 14 +-- .../handlers/execute_command_init_test.go | 12 +-- .../execute_command_module_callers_test.go | 4 +- .../execute_command_module_providers_test.go | 2 +- .../handlers/execute_command_modules_test.go | 2 +- .../handlers/execute_command_test.go | 2 +- .../handlers/execute_command_validate_test.go | 4 +- .../langserver/handlers/formatting_test.go | 10 +-- .../handlers/go_to_ref_target_test.go | 12 +-- internal/langserver/handlers/handlers_test.go | 4 +- internal/langserver/handlers/hover_test.go | 6 +- .../langserver/handlers/references_test.go | 4 +- .../handlers/semantic_tokens_test.go | 10 +-- .../handlers/signature_help_test.go | 2 +- internal/langserver/handlers/symbols_test.go | 4 +- .../handlers/workspace_symbol_test.go | 12 +-- internal/lsp/code_actions.go | 4 +- internal/lsp/language_id.go | 4 +- internal/protocol/experimental.go | 12 --- internal/registry/module.go | 17 ---- internal/registry/registry.go | 5 +- internal/state/documents_test.go | 28 +++--- internal/state/module_changes_test.go | 4 +- internal/state/module_test.go | 2 +- .../terraform/module/terraform_executor.go | 2 +- internal/utm/utm.go | 2 +- main.go | 2 +- version/VERSION | 2 +- 42 files changed, 120 insertions(+), 240 deletions(-) delete mode 100644 docs/telemetry.md diff --git a/docs/telemetry.md b/docs/telemetry.md deleted file mode 100644 index c2d18838c..000000000 --- a/docs/telemetry.md +++ /dev/null @@ -1,88 +0,0 @@ -# Telemetry - -The language server is capable of sending telemetry using the native LSP `telemetry/event` method. -Telemetry is off by default and can enabled by passing a supported request format version -as an experimental client capability. - -```json -{ - "capabilities": { - "experimental": { - "telemetryVersion": 1 - } - } -} -``` - -Clients then implement opt-in or opt-out in the UI and should reflect the user's choice. - -## Privacy - -Sensitive data, such as filesystem paths or addresses of providers sourced from outside the Terraform Registry -are anonymized. Random UUID is generated in memory and tracked instead of a path or a private provider address. - -Mapping of such UUIDs is not persisted anywhere other than in memory during process lifetime. - -## Request Format - -The only supported version is currently `1`. Version negotiation allows the server -to introduce breaking changes to the format and have clients adopt gradually. - -### `v1` - -[`telemetry/event`](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#telemetry_event) structure - -```json -{ - "v": 1, - "name": "eventName", - "properties": {} -} -``` - -`properties` may contain **any (valid) JSON types** -including arrays and arbitrarily nested objects. It is client's -reponsibility to serialize these properties when and if necessary. - -Example events: - -```json -{ - "v": 1, - "name": "initialize", - "properties": { - "experimentalCapabilities.referenceCountCodeLens": true, - "lsVersion": "0.23.0", - "options.commandPrefix": true, - "options.excludeModulePaths": false, - "options.experimentalFeatures.prefillRequiredFields": false, - "options.experimentalFeatures.validateOnSave": false, - "options.rootModulePaths": false, - "options.terraformExecPath": false, - "options.terraformExecTimeout": "", - "options.terraformLogFilePath": false, - "root_uri": "dir" - } -} -``` -```json -{ - "v": 1, - "name": "moduleData", - "properties": { - "backend": "remote", - "backend.remote.hostname": "app.terraform.io", - "installedProviders": { - "registry.terraform.io/hashicorp/aws": "3.57.0", - "registry.terraform.io/hashicorp/null": "3.1.0" - }, - "moduleId": "8aa5a4dc-4780-2d90-b8fb-57de8288fb32", - "providerRequirements": { - "registry.terraform.io/hashicorp/aws": "", - "registry.terraform.io/hashicorp/null": "~> 3.1" - }, - "tfRequirements": "~> 1.0", - "tfVersion": "1.0.7" - } -} -``` diff --git a/internal/cmd/serve_command.go b/internal/cmd/serve_command.go index 08b944bd8..533d4e9d1 100644 --- a/internal/cmd/serve_command.go +++ b/internal/cmd/serve_command.go @@ -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) @@ -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()), @@ -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()) diff --git a/internal/cmd/version_command.go b/internal/cmd/version_command.go index a28f159a0..d7f07e243 100644 --- a/internal/cmd/version_command.go +++ b/internal/cmd/version_command.go @@ -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()) diff --git a/internal/decoder/decoder_test.go b/internal/decoder/decoder_test.go index 343d8e582..96d57a372 100644 --- a/internal/decoder/decoder_test.go +++ b/internal/decoder/decoder_test.go @@ -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) diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index 7c39cd6b2..b1ded5f22 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -112,7 +112,7 @@ func TestUnreferencedOrigins(t *testing.T) { }, TargetPath: lang.Path{ Path: "./submodule", - LanguageID: "terraform", + LanguageID: "opentofu", }, Constraints: reference.OriginConstraints{}, }, diff --git a/internal/filesystem/filesystem_test.go b/internal/filesystem/filesystem_test.go index 61856a139..48c320500 100644 --- a/internal/filesystem/filesystem_test.go +++ b/internal/filesystem/filesystem_test.go @@ -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), }, @@ -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), }, @@ -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"), }, @@ -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"), }, @@ -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"), }, @@ -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), }, diff --git a/internal/hooks/module_source_local_test.go b/internal/hooks/module_source_local_test.go index fab8dede7..1fe78e531 100644 --- a/internal/hooks/module_source_local_test.go +++ b/internal/hooks/module_source_local_test.go @@ -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 { diff --git a/internal/hooks/module_version_test.go b/internal/hooks/module_version_test.go index 7802a76bd..ba0d782b8 100644 --- a/internal/hooks/module_version_test.go +++ b/internal/hooks/module_version_test.go @@ -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, diff --git a/internal/langserver/handlers/code_action_test.go b/internal/langserver/handlers/code_action_test.go index bc7f0adb1..8159494fd 100644 --- a/internal/langserver/handlers/code_action_test.go +++ b/internal/langserver/handlers/code_action_test.go @@ -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" } @@ -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" } @@ -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": [ @@ -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(`{ @@ -198,7 +198,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.formatAll.terraform"] } + "context": { "diagnostics": [], "only": ["source.formatAll.opentofu"] } }`, tmpDir.URI)}, want: fmt.Sprintf(`{ "jsonrpc": "2.0", @@ -206,7 +206,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": [ @@ -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(`{ @@ -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(`{ @@ -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": [ @@ -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" } diff --git a/internal/langserver/handlers/code_lens_test.go b/internal/langserver/handlers/code_lens_test.go index 0794ba00f..0aa136759 100644 --- a/internal/langserver/handlers/code_lens_test.go +++ b/internal/langserver/handlers/code_lens_test.go @@ -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" } @@ -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" } @@ -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" } diff --git a/internal/langserver/handlers/complete_test.go b/internal/langserver/handlers/complete_test.go index 21071b39c..7e8198214 100644 --- a/internal/langserver/handlers/complete_test.go +++ b/internal/langserver/handlers/complete_test.go @@ -127,7 +127,7 @@ func TestModuleCompletion_withValidData_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -320,7 +320,7 @@ func TestModuleCompletion_withValidData_tooOldVersion(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -473,7 +473,7 @@ func TestModuleCompletion_withValidData_tooNewVersion(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -709,7 +709,7 @@ func TestModuleCompletion_withValidDataAndSnippets(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -1005,7 +1005,7 @@ func TestVarsCompletion_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"test\" {\n type=string\n}\n", "uri": "%s/variables.tf" } @@ -1015,7 +1015,7 @@ func TestVarsCompletion_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform-vars", + "languageId": "opentofu-vars", "uri": "%s/terraform.tfvars" } }`, tmpDir.URI)}) @@ -1160,7 +1160,7 @@ output "test" { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": %q, "uri": "%s/main.tf" } @@ -1413,7 +1413,7 @@ output "test" { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": %q, "uri": "%s/main.tf" } @@ -1728,7 +1728,7 @@ variable "ccc" {} ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "output \"test\" {\n value = var.\n}\n", "uri": "%s/outputs.tf" } diff --git a/internal/langserver/handlers/did_change_test.go b/internal/langserver/handlers/did_change_test.go index 696616a7a..3d4cfd865 100644 --- a/internal/langserver/handlers/did_change_test.go +++ b/internal/langserver/handlers/did_change_test.go @@ -69,7 +69,7 @@ module "app" { Method: "textDocument/didOpen", ReqParams: fmt.Sprintf(`{ "textDocument": { - "languageId": "terraform", + "languageId": "opentofu", "version": 0, "uri": "%s/main.tf", "text": %q diff --git a/internal/langserver/handlers/did_open_test.go b/internal/langserver/handlers/did_open_test.go index 5bc62193e..2ebf8ca19 100644 --- a/internal/langserver/handlers/did_open_test.go +++ b/internal/langserver/handlers/did_open_test.go @@ -28,7 +28,7 @@ func TestLangServer_didOpenWithoutInitialization(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/main.tf" } @@ -77,7 +77,7 @@ func TestLangServer_didOpenLanguageIdStored(t *testing.T) { Method: "textDocument/didOpen", ReqParams: fmt.Sprintf(`{ "textDocument": { - "languageId": "terraform", + "languageId": "opentofu", "version": 0, "uri": "%s/main.tf", "text": %q @@ -91,7 +91,7 @@ func TestLangServer_didOpenLanguageIdStored(t *testing.T) { if err != nil { t.Fatal(err) } - if diff := cmp.Diff(doc.LanguageID, string("terraform")); diff != "" { + if diff := cmp.Diff(doc.LanguageID, string("opentofu")); diff != "" { t.Fatalf("unexpected languageID: %s", diff) } fullPath := doc.FullPath() diff --git a/internal/langserver/handlers/document_link_test.go b/internal/langserver/handlers/document_link_test.go index e3f3fff14..55417555b 100644 --- a/internal/langserver/handlers/document_link_test.go +++ b/internal/langserver/handlers/document_link_test.go @@ -99,7 +99,7 @@ func TestDocumentLink_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } diff --git a/internal/langserver/handlers/execute_command.go b/internal/langserver/handlers/execute_command.go index fcce8b93b..cdb16f031 100644 --- a/internal/langserver/handlers/execute_command.go +++ b/internal/langserver/handlers/execute_command.go @@ -20,13 +20,13 @@ func cmdHandlers(svc *service) cmd.Handlers { Logger: svc.logger, } return cmd.Handlers{ - cmd.Name("rootmodules"): removedHandler("use module.callers instead"), - cmd.Name("module.callers"): cmdHandler.ModuleCallersHandler, - cmd.Name("terraform.init"): cmdHandler.TerraformInitHandler, - cmd.Name("terraform.validate"): cmdHandler.TerraformValidateHandler, - cmd.Name("module.calls"): cmdHandler.ModuleCallsHandler, - cmd.Name("module.providers"): cmdHandler.ModuleProvidersHandler, - cmd.Name("module.terraform"): cmdHandler.TerraformVersionRequestHandler, + cmd.Name("rootmodules"): removedHandler("use module.callers instead"), + cmd.Name("module.callers"): cmdHandler.ModuleCallersHandler, + cmd.Name("tofu.init"): cmdHandler.TerraformInitHandler, + cmd.Name("tofu.validate"): cmdHandler.TerraformValidateHandler, + cmd.Name("module.calls"): cmdHandler.ModuleCallsHandler, + cmd.Name("module.providers"): cmdHandler.ModuleProvidersHandler, + cmd.Name("module.terraform"): cmdHandler.TerraformVersionRequestHandler, } } diff --git a/internal/langserver/handlers/execute_command_init_test.go b/internal/langserver/handlers/execute_command_init_test.go index 44ac1d97a..4e06ea208 100644 --- a/internal/langserver/handlers/execute_command_init_test.go +++ b/internal/langserver/handlers/execute_command_init_test.go @@ -58,7 +58,7 @@ func TestLangServer_workspaceExecuteCommand_init_argumentError(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } @@ -69,7 +69,7 @@ func TestLangServer_workspaceExecuteCommand_init_argumentError(t *testing.T) { Method: "workspace/executeCommand", ReqParams: fmt.Sprintf(`{ "command": %q - }`, cmd.Name("terraform.init"))}, jrpc2.InvalidParams.Err()) + }`, cmd.Name("tofu.init"))}, jrpc2.InvalidParams.Err()) } func TestLangServer_workspaceExecuteCommand_init_basic(t *testing.T) { @@ -143,7 +143,7 @@ func TestLangServer_workspaceExecuteCommand_init_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } @@ -155,7 +155,7 @@ func TestLangServer_workspaceExecuteCommand_init_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "command": %q, "arguments": ["uri=%s"] - }`, cmd.Name("terraform.init"), tmpDir.URI)}, `{ + }`, cmd.Name("tofu.init"), tmpDir.URI)}, `{ "jsonrpc": "2.0", "id": 3, "result": null @@ -233,7 +233,7 @@ func TestLangServer_workspaceExecuteCommand_init_error(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } @@ -245,5 +245,5 @@ func TestLangServer_workspaceExecuteCommand_init_error(t *testing.T) { ReqParams: fmt.Sprintf(`{ "command": %q, "arguments": ["uri=%s"] - }`, cmd.Name("terraform.init"), testFileURI)}, jrpc2.SystemError.Err()) + }`, cmd.Name("tofu.init"), testFileURI)}, jrpc2.SystemError.Err()) } diff --git a/internal/langserver/handlers/execute_command_module_callers_test.go b/internal/langserver/handlers/execute_command_module_callers_test.go index 2721714ef..488a525a8 100644 --- a/internal/langserver/handlers/execute_command_module_callers_test.go +++ b/internal/langserver/handlers/execute_command_module_callers_test.go @@ -59,7 +59,7 @@ func TestLangServer_workspaceExecuteCommand_moduleCallers_argumentError(t *testi ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } @@ -117,7 +117,7 @@ func TestLangServer_workspaceExecuteCommand_moduleCallers_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } diff --git a/internal/langserver/handlers/execute_command_module_providers_test.go b/internal/langserver/handlers/execute_command_module_providers_test.go index c14781754..b4a3b8ca5 100644 --- a/internal/langserver/handlers/execute_command_module_providers_test.go +++ b/internal/langserver/handlers/execute_command_module_providers_test.go @@ -59,7 +59,7 @@ func TestLangServer_workspaceExecuteCommand_moduleProviders_argumentError(t *tes ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } diff --git a/internal/langserver/handlers/execute_command_modules_test.go b/internal/langserver/handlers/execute_command_modules_test.go index 0e1a56544..e12cafb50 100644 --- a/internal/langserver/handlers/execute_command_modules_test.go +++ b/internal/langserver/handlers/execute_command_modules_test.go @@ -56,7 +56,7 @@ func TestLangServer_workspaceExecuteCommand_modules_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } diff --git a/internal/langserver/handlers/execute_command_test.go b/internal/langserver/handlers/execute_command_test.go index e7c03fc1f..5f17c9d00 100644 --- a/internal/langserver/handlers/execute_command_test.go +++ b/internal/langserver/handlers/execute_command_test.go @@ -57,7 +57,7 @@ func TestLangServer_workspaceExecuteCommand_noCommandHandlerError(t *testing.T) ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } diff --git a/internal/langserver/handlers/execute_command_validate_test.go b/internal/langserver/handlers/execute_command_validate_test.go index 9f244e08d..141b4d115 100644 --- a/internal/langserver/handlers/execute_command_validate_test.go +++ b/internal/langserver/handlers/execute_command_validate_test.go @@ -55,7 +55,7 @@ func TestLangServer_workspaceExecuteCommand_validate_argumentError(t *testing.T) ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": %q } @@ -66,5 +66,5 @@ func TestLangServer_workspaceExecuteCommand_validate_argumentError(t *testing.T) Method: "workspace/executeCommand", ReqParams: fmt.Sprintf(`{ "command": %q - }`, cmd.Name("terraform.validate"))}, jrpc2.InvalidParams.Err()) + }`, cmd.Name("tofu.validate"))}, jrpc2.InvalidParams.Err()) } diff --git a/internal/langserver/handlers/formatting_test.go b/internal/langserver/handlers/formatting_test.go index f96e5ae24..dfa171ea3 100644 --- a/internal/langserver/handlers/formatting_test.go +++ b/internal/langserver/handlers/formatting_test.go @@ -28,7 +28,7 @@ func TestLangServer_formattingWithoutInitialization(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/main.tf" } @@ -105,7 +105,7 @@ func TestLangServer_formatting_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -204,7 +204,7 @@ func TestLangServer_formatting_oldVersion(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -291,7 +291,7 @@ func TestLangServer_formatting_variables(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform-vars", + "languageId": "opentofu-vars", "text": "test = \"dev\"", "uri": "%s/terraform.tfvars" } @@ -407,7 +407,7 @@ func TestLangServer_formatting_diffBug(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", cfg)+`, "uri": "%s/main.tf" } diff --git a/internal/langserver/handlers/go_to_ref_target_test.go b/internal/langserver/handlers/go_to_ref_target_test.go index 9dae3ab7d..7d816a799 100644 --- a/internal/langserver/handlers/go_to_ref_target_test.go +++ b/internal/langserver/handlers/go_to_ref_target_test.go @@ -78,7 +78,7 @@ func TestDefinition_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `variable "test" { } @@ -207,7 +207,7 @@ func TestDefinition_withLinkToDefLessBlock(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `resource "test_resource_2" "foo" { setting { @@ -362,7 +362,7 @@ func TestDefinition_withLinkToDefBlock(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `resource "test_resource_2" "foo" { setting { @@ -472,7 +472,7 @@ func TestDefinition_moduleInputToVariable(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `module "gorilla-app" { source = "./application" @@ -575,7 +575,7 @@ func TestDeclaration_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `variable "test" { } @@ -704,7 +704,7 @@ func TestDeclaration_withLinkSupport(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `resource "test_resource_2" "foo" { setting { diff --git a/internal/langserver/handlers/handlers_test.go b/internal/langserver/handlers/handlers_test.go index fa8d8b242..646d84713 100644 --- a/internal/langserver/handlers/handlers_test.go +++ b/internal/langserver/handlers/handlers_test.go @@ -51,7 +51,7 @@ func initializeResponse(t *testing.T, commandPrefix string) string { "referencesProvider": true, "documentSymbolProvider": true, "codeActionProvider": { - "codeActionKinds": ["source.formatAll.terraform"] + "codeActionKinds": ["source.formatAll.opentofu"] }, "codeLensProvider": {}, "documentLinkProvider": {}, @@ -265,7 +265,7 @@ func validTfMockCalls() []*mock.Call { // // The returned filehandler is the parent tmp dir func TempDir(t *testing.T, nested ...string) document.DirHandle { - tmpDir := filepath.Join(os.TempDir(), "terraform-ls", t.Name()) + tmpDir := filepath.Join(os.TempDir(), "opentofu-ls", t.Name()) err := os.MkdirAll(tmpDir, 0755) if err != nil && !os.IsExist(err) { t.Fatal(err) diff --git a/internal/langserver/handlers/hover_test.go b/internal/langserver/handlers/hover_test.go index 6694e0511..1cbcb1c41 100644 --- a/internal/langserver/handlers/hover_test.go +++ b/internal/langserver/handlers/hover_test.go @@ -112,7 +112,7 @@ func TestHover_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -221,7 +221,7 @@ func TestVarsHover_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"test\" {\n type=string\n sensitive=true}\n", "uri": "%s/variables.tf" } @@ -231,7 +231,7 @@ func TestVarsHover_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform-vars", + "languageId": "opentofu-vars", "text": "test = \"dev\"\n", "uri": "%s/terraform.tfvars" } diff --git a/internal/langserver/handlers/references_test.go b/internal/langserver/handlers/references_test.go index beadab808..5a34b2958 100644 --- a/internal/langserver/handlers/references_test.go +++ b/internal/langserver/handlers/references_test.go @@ -79,7 +79,7 @@ func TestReferences_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `variable "test" { } @@ -186,7 +186,7 @@ func TestReferences_variableToModuleInput(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": `+fmt.Sprintf("%q", `variable "environment_name" { type = string diff --git a/internal/langserver/handlers/semantic_tokens_test.go b/internal/langserver/handlers/semantic_tokens_test.go index 0bd22394b..53a0e90c7 100644 --- a/internal/langserver/handlers/semantic_tokens_test.go +++ b/internal/langserver/handlers/semantic_tokens_test.go @@ -111,7 +111,7 @@ func TestSemanticTokensFull(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -232,7 +232,7 @@ func TestSemanticTokensFull_clientSupportsDelta(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"test\" {\n\n}\n", "uri": "%s/main.tf" } @@ -350,7 +350,7 @@ func TestVarsSemanticTokensFull(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"test\" {\n type=string\n}\n", "uri": "%s/variables.tf" } @@ -360,7 +360,7 @@ func TestVarsSemanticTokensFull(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform-vars", + "languageId": "opentofu-vars", "text": "test = \"dev\"\n", "uri": "%s/terraform.tfvars" } @@ -479,7 +479,7 @@ func TestVarsSemanticTokensFull_functionToken(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "locals {\n foo = abs(-42)\n}\n", "uri": "%s/locals.tf" } diff --git a/internal/langserver/handlers/signature_help_test.go b/internal/langserver/handlers/signature_help_test.go index 0a09c36cc..261a87934 100644 --- a/internal/langserver/handlers/signature_help_test.go +++ b/internal/langserver/handlers/signature_help_test.go @@ -117,7 +117,7 @@ func TestSignatureHelp_withValidData(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "variable \"name\" {\n default = file(\"~/foo\")\n}", "uri": "%s/main.tf" } diff --git a/internal/langserver/handlers/symbols_test.go b/internal/langserver/handlers/symbols_test.go index f42492bc1..c608de771 100644 --- a/internal/langserver/handlers/symbols_test.go +++ b/internal/langserver/handlers/symbols_test.go @@ -70,7 +70,7 @@ func TestLangServer_symbols_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/main.tf" } @@ -149,7 +149,7 @@ func TestLangServer_symbols_missing(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/main.tf" } diff --git a/internal/langserver/handlers/workspace_symbol_test.go b/internal/langserver/handlers/workspace_symbol_test.go index 2b654edef..8ebbcad65 100644 --- a/internal/langserver/handlers/workspace_symbol_test.go +++ b/internal/langserver/handlers/workspace_symbol_test.go @@ -68,7 +68,7 @@ func TestLangServer_workspace_symbol_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/first.tf" } @@ -78,7 +78,7 @@ func TestLangServer_workspace_symbol_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"google\" {}", "uri": "%s/second.tf" } @@ -88,7 +88,7 @@ func TestLangServer_workspace_symbol_basic(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "myblock \"custom\" {}", "uri": "%s/blah/third.tf" } @@ -206,7 +206,7 @@ func TestLangServer_workspace_symbol_missing(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"github\" {}", "uri": "%s/first.tf" } @@ -216,7 +216,7 @@ func TestLangServer_workspace_symbol_missing(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "provider \"google\" {}", "uri": "%s/second.tf" } @@ -226,7 +226,7 @@ func TestLangServer_workspace_symbol_missing(t *testing.T) { ReqParams: fmt.Sprintf(`{ "textDocument": { "version": 0, - "languageId": "terraform", + "languageId": "opentofu", "text": "myblock \"custom\" {}", "uri": "%s/blah/third.tf" } diff --git a/internal/lsp/code_actions.go b/internal/lsp/code_actions.go index b4dc6bf65..efe07f449 100644 --- a/internal/lsp/code_actions.go +++ b/internal/lsp/code_actions.go @@ -11,7 +11,7 @@ import ( const ( // SourceFormatAllTerraform is a Terraform specific format code action. - SourceFormatAllTerraform = "source.formatAll.terraform" + SourceFormatAllTerraform = "source.formatAll.opentofu" ) type CodeActions map[lsp.CodeActionKind]bool @@ -31,7 +31,7 @@ var ( // `source.formatAll`: Generic format code action. // We do not register this for terraform to allow fine grained selection of actions. - // A user should be able to set `source.formatAll` to true, and source.formatAll.terraform to false to allow all + // A user should be able to set `source.formatAll` to true, and source.formatAll.opentofu to false to allow all // files to be formatted, but not terraform files (or vice versa). SupportedCodeActions = CodeActions{ SourceFormatAllTerraform: true, diff --git a/internal/lsp/language_id.go b/internal/lsp/language_id.go index 623771f3c..59a55e2ee 100644 --- a/internal/lsp/language_id.go +++ b/internal/lsp/language_id.go @@ -8,8 +8,8 @@ package lsp type LanguageID string const ( - Terraform LanguageID = "terraform" - Tfvars LanguageID = "terraform-vars" + Terraform LanguageID = "opentofu" + Tfvars LanguageID = "opentofu-vars" ) func (l LanguageID) String() string { diff --git a/internal/protocol/experimental.go b/internal/protocol/experimental.go index cf34a1c90..79efbae54 100644 --- a/internal/protocol/experimental.go +++ b/internal/protocol/experimental.go @@ -54,15 +54,3 @@ func (cc ExpClientCapabilities) RefreshTerraformVersionCommandId() (string, bool cmdId, ok := cc["refreshTerraformVersionCommandId"].(string) return cmdId, ok } - -func (cc ExpClientCapabilities) TelemetryVersion() (int, bool) { - if cc == nil { - return 0, false - } - - // numbers are unmarshalled as float64 from JSON - // per https://pkg.go.dev/encoding/json#Unmarshal - v, ok := cc["telemetryVersion"].(float64) - - return int(v), ok -} diff --git a/internal/registry/module.go b/internal/registry/module.go index b3932733d..5c7e942a0 100644 --- a/internal/registry/module.go +++ b/internal/registry/module.go @@ -16,9 +16,6 @@ import ( "github.com/hashicorp/go-version" tfaddr "github.com/hashicorp/terraform-registry-address" "go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace" - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/trace" ) type ModuleResponse struct { @@ -67,8 +64,6 @@ func (rce ClientError) Error() string { } func (c Client) GetModuleData(ctx context.Context, addr tfaddr.Module, cons version.Constraints) (*ModuleResponse, error) { - ctx, span := otel.Tracer(tracerName).Start(ctx, "registry:GetModuleData") - defer span.End() var response ModuleResponse v, err := c.GetMatchingModuleVersion(ctx, addr, cons) @@ -113,8 +108,6 @@ func (c Client) GetModuleData(ctx context.Context, addr tfaddr.Module, cons vers } func (c Client) GetMatchingModuleVersion(ctx context.Context, addr tfaddr.Module, con version.Constraints) (*version.Version, error) { - ctx, span := otel.Tracer(tracerName).Start(ctx, "registry:GetMatchingModuleVersion") - defer span.End() foundVersions, err := c.GetModuleVersions(ctx, addr) if err != nil { return nil, err @@ -130,9 +123,6 @@ func (c Client) GetMatchingModuleVersion(ctx context.Context, addr tfaddr.Module } func (c Client) GetModuleVersions(ctx context.Context, addr tfaddr.Module) (version.Collection, error) { - ctx, span := otel.Tracer(tracerName).Start(ctx, "registry:GetModuleVersions") - defer span.End() - url := fmt.Sprintf("%s/v1/modules/%s/%s/%s/versions", c.BaseURL, addr.Package.Namespace, addr.Package.Name, @@ -160,13 +150,11 @@ func (c Client) GetModuleVersions(ctx context.Context, addr tfaddr.Module) (vers return nil, ClientError{StatusCode: resp.StatusCode, Body: string(bodyBytes)} } - _, decodeSpan := otel.Tracer(tracerName).Start(ctx, "registry:GetModuleVersions:decodeJson") var response ModuleVersionsResponse err = json.NewDecoder(resp.Body).Decode(&response) if err != nil { return nil, err } - decodeSpan.End() var foundVersions version.Collection for _, module := range response.Modules { @@ -177,11 +165,6 @@ func (c Client) GetModuleVersions(ctx context.Context, addr tfaddr.Module) (vers } } } - span.AddEvent("registry:foundModuleVersions", - trace.WithAttributes(attribute.KeyValue{ - Key: attribute.Key("moduleVersionCount"), - Value: attribute.IntValue(len(foundVersions)), - })) sort.Sort(sort.Reverse(foundVersions)) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index cdd38f104..4e50a4f79 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -8,13 +8,11 @@ import ( "time" "github.com/hashicorp/go-cleanhttp" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) const ( - defaultBaseURL = "https://registry.terraform.io" + defaultBaseURL = "https://registry.opentofu.org" defaultTimeout = 5 * time.Second - tracerName = "github.com/hashicorp/terraform-ls/internal/registry" ) type Client struct { @@ -27,7 +25,6 @@ type Client struct { func NewClient() Client { client := cleanhttp.DefaultClient() client.Timeout = defaultTimeout - client.Transport = otelhttp.NewTransport(client.Transport) return Client{ BaseURL: defaultBaseURL, diff --git a/internal/state/documents_test.go b/internal/state/documents_test.go index b569ea248..78957deb7 100644 --- a/internal/state/documents_test.go +++ b/internal/state/documents_test.go @@ -57,7 +57,7 @@ func TestDocumentStore_UpdateDocument_emptyText(t *testing.T) { testHandle := document.HandleFromURI("file:///dir/test.tf") - err = s.DocumentStore.OpenDocument(testHandle, "terraform", 0, []byte("foo")) + err = s.DocumentStore.OpenDocument(testHandle, "opentofu", 0, []byte("foo")) if err != nil { t.Fatal(err) } @@ -76,7 +76,7 @@ func TestDocumentStore_UpdateDocument_basic(t *testing.T) { testHandle := document.HandleFromURI("file:///dir/test.tf") - err = s.DocumentStore.OpenDocument(testHandle, "terraform", 0, []byte("foo")) + err = s.DocumentStore.OpenDocument(testHandle, "opentofu", 0, []byte("foo")) if err != nil { t.Fatal(err) } @@ -95,7 +95,7 @@ func TestDocumentStore_GetDocument_basic(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle := document.HandleFromURI("file:///dir/test.tf") - err = s.DocumentStore.OpenDocument(testHandle, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } @@ -110,7 +110,7 @@ func TestDocumentStore_GetDocument_basic(t *testing.T) { Dir: testHandle.Dir, Filename: testHandle.Filename, ModTime: testTimeProvider(), - LanguageID: "terraform", + LanguageID: "opentofu", Version: 0, Text: text, Lines: source.MakeSourceLines(testHandle.Filename, text), @@ -148,13 +148,13 @@ func TestDocumentStore_ListDocumentsInDir(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle1 := document.HandleFromURI("file:///dir/test1.tf") - err = s.DocumentStore.OpenDocument(testHandle1, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle1, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } testHandle2 := document.HandleFromURI("file:///dir/test2.tf") - err = s.DocumentStore.OpenDocument(testHandle2, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle2, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } @@ -170,7 +170,7 @@ func TestDocumentStore_ListDocumentsInDir(t *testing.T) { Dir: dirHandle, Filename: "test1.tf", ModTime: testTimeProvider(), - LanguageID: "terraform", + LanguageID: "opentofu", Version: 0, Text: []byte("foobar"), Lines: source.MakeSourceLines("test1.tf", []byte("foobar")), @@ -179,7 +179,7 @@ func TestDocumentStore_ListDocumentsInDir(t *testing.T) { Dir: dirHandle, Filename: "test2.tf", ModTime: testTimeProvider(), - LanguageID: "terraform", + LanguageID: "opentofu", Version: 0, Text: []byte("foobar"), Lines: source.MakeSourceLines("test2.tf", []byte("foobar")), @@ -199,13 +199,13 @@ func TestDocumentStore_ListDocumentsInDir_parentDir(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle1 := document.HandleFromURI("file:///dir/test1.tf") - err = s.DocumentStore.OpenDocument(testHandle1, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle1, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } testHandle2 := document.HandleFromURI("file:///dir/sub/test2.tf") - err = s.DocumentStore.OpenDocument(testHandle2, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle2, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } @@ -221,7 +221,7 @@ func TestDocumentStore_ListDocumentsInDir_parentDir(t *testing.T) { Dir: dirHandle, Filename: "test1.tf", ModTime: testTimeProvider(), - LanguageID: "terraform", + LanguageID: "opentofu", Version: 0, Text: []byte("foobar"), Lines: source.MakeSourceLines("test1.tf", []byte("foobar")), @@ -241,7 +241,7 @@ func TestDocumentStore_IsDocumentOpen(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle1 := document.HandleFromURI("file:///dir/test1.tf") - err = s.DocumentStore.OpenDocument(testHandle1, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle1, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } @@ -273,7 +273,7 @@ func TestDocumentStore_HasOpenDocuments(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle1 := document.HandleFromURI("file:///dir/test1.tf") - err = s.DocumentStore.OpenDocument(testHandle1, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle1, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } @@ -306,7 +306,7 @@ func TestDocumentStore_HasOpenDocuments_parentDir(t *testing.T) { s.DocumentStore.TimeProvider = testTimeProvider testHandle := document.HandleFromURI("file:///dir/sub/test2.tf") - err = s.DocumentStore.OpenDocument(testHandle, "terraform", 0, []byte("foobar")) + err = s.DocumentStore.OpenDocument(testHandle, "opentofu", 0, []byte("foobar")) if err != nil { t.Fatal(err) } diff --git a/internal/state/module_changes_test.go b/internal/state/module_changes_test.go index 4dd8b16f5..28a48abf1 100644 --- a/internal/state/module_changes_test.go +++ b/internal/state/module_changes_test.go @@ -28,7 +28,7 @@ func TestModuleChanges_dirOpenMark_openBeforeChange(t *testing.T) { Dir: modHandle, Filename: "main.tf", } - err = ss.DocumentStore.OpenDocument(docHandle, "terraform", 0, []byte{}) + err = ss.DocumentStore.OpenDocument(docHandle, "opentofu", 0, []byte{}) if err != nil { t.Fatal(err) } @@ -69,7 +69,7 @@ func TestModuleChanges_dirOpenMark_openAfterChange(t *testing.T) { Dir: modHandle, Filename: "main.tf", } - err = ss.DocumentStore.OpenDocument(docHandle, "terraform", 0, []byte{}) + err = ss.DocumentStore.OpenDocument(docHandle, "opentofu", 0, []byte{}) if err != nil { t.Fatal(err) } diff --git a/internal/state/module_test.go b/internal/state/module_test.go index 83b9e22bd..290dec142 100644 --- a/internal/state/module_test.go +++ b/internal/state/module_test.go @@ -686,7 +686,7 @@ func TestModuleStore_UpdateVarsReferenceOrigins(t *testing.T) { }, TargetPath: lang.Path{ Path: tmpDir, - LanguageID: "terraform", + LanguageID: "opentofu", }, Constraints: reference.OriginConstraints{ reference.OriginConstraint{ diff --git a/internal/terraform/module/terraform_executor.go b/internal/terraform/module/terraform_executor.go index 134bd99ac..dcdeb9792 100644 --- a/internal/terraform/module/terraform_executor.go +++ b/internal/terraform/module/terraform_executor.go @@ -13,7 +13,7 @@ import ( func TerraformExecutorForModule(ctx context.Context, modPath string) (exec.TerraformExecutor, error) { newExecutor, ok := exec.ExecutorFactoryFromContext(ctx) if !ok { - return nil, fmt.Errorf("no terraform executor provided") + return nil, fmt.Errorf("no opentofu executor provided") } execPath, err := TerraformExecPath(ctx) diff --git a/internal/utm/utm.go b/internal/utm/utm.go index 71893d43c..9a7d6155b 100644 --- a/internal/utm/utm.go +++ b/internal/utm/utm.go @@ -9,7 +9,7 @@ import ( ilsp "github.com/hashicorp/terraform-ls/internal/lsp" ) -const UtmSource = "terraform-ls" +const UtmSource = "opentofu-ls" func UtmMedium(ctx context.Context) string { clientName, ok := ilsp.ClientName(ctx) diff --git a/main.go b/main.go index dc946af51..252fb2051 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ import ( func main() { c := &cli.CLI{ - Name: "terraform-ls", + Name: "opentofu-ls", Version: VersionString(), Args: os.Args[1:], HelpWriter: os.Stdout, diff --git a/version/VERSION b/version/VERSION index 6eb78516d..0d4d12494 100644 --- a/version/VERSION +++ b/version/VERSION @@ -1 +1 @@ -0.33.0-dev +0.1.0-dev