diff --git a/.claude/skills/development/SKILL.md b/.claude/skills/development/SKILL.md index f02bc69d..4f75fb0a 100644 --- a/.claude/skills/development/SKILL.md +++ b/.claude/skills/development/SKILL.md @@ -1,6 +1,6 @@ --- name: development -description: How the meshStack CLI's Go code is laid out and built - where a command, its logic and an HTTP call go, and what the client and settings must keep. Use when writing, changing or reviewing Go code here - a new command or package, a change to client/, pkg/ or internal/http, an HTTP request, a new setting or dependency, or a depguard or forbidigo finding. +description: How the meshStack CLI's Go code is laid out and built - where a command, its logic and an HTTP call go, and what the client and settings must keep. Use when writing, changing or reviewing Go code here - a new command or package, a change to client/, client/http or pkg/, an HTTP request, a new setting or dependency, or a depguard or forbidigo finding. --- # Developing the meshStack CLI @@ -145,25 +145,26 @@ authorization always agree with what was resolved. Do **not** add a login exchan second one gets a static token and starts returning 401 once it expires, and for a browser login it would end the user's session. -**`client/` does not own HTTP.** The client, the request options and the retry policy are -`internal/http`, because `internal/oidc` and `pkg/auth` need them and Go's internal rule closes -`client/internal` to both. Its names carry no `Http` prefix: `http.Client`, `http.Error`. +**HTTP is `client/http`.** The client, the request options and the retry policy are there, because +`internal/oidc` and `pkg/auth` need them as well, and another module calls `client.New` with them. +No exported name of `client/` may use an `internal/` type, because another module cannot name it. +Its names carry no `Http` prefix: `http.Client`, `http.Error`. **Every request names the front end and version that sent it.** `http.NewClient` takes an `http.UserAgent`, which `auth.ResolveSessionOptions` embeds: the front end sets its `GitHubRepo` and `Version` once, the CLI in `cmd/internal.ResolveClientOptions`, and the release check reads the same two. So code below `cmd/` takes its client from its caller, and a command that needs one for anything but a meshStack client calls `internal.ResolveClientOptions().HttpClient()`. `forbidigo` -keeps `http.UserAgent` to those options, and the transport to `internal/http`. +keeps `http.UserAgent` to those options, and the transport to `client/http`. **`net/http` is always imported as `gohttp`**, which `importas` settles. That leaves the plain name -to `internal/http`, and `net/http` to the status and method constants and to the loopback server. +to `client/http`, and `net/http` to the status and method constants and to the loopback server. The `forbidigo` rule matches on the type rather than the written name, so it catches `gohttp.Client` and leaves `http.Client` alone. **Logging goes through `slog`'s default logger**, on which each front end installs its own handler: `cmd/meshstack` a `charmbracelet/log` one, the Terraform provider a `tflog` bridge. A handler -installed that late constrains every log call, and `internal/http/logging.go` states how. +installed that late constrains every log call, and `client/http/logging.go` states how. ## Settings diff --git a/.golangci.yml b/.golangci.yml index e79805fb..61fb998b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -87,12 +87,12 @@ linters: - gosec text: G101 path: _test\.go - - path: internal/http/ + - path: client/http/ linters: - forbidigo text: one HTTP client # The options of a session carry the user agent the front end sets. - - path: (internal/http/|internal/auth/session\.go|internal/testutil/|_test\.go) + - path: (client/http/|internal/auth/session\.go|internal/testutil/|_test\.go) linters: - forbidigo text: user agent of the front end @@ -130,17 +130,17 @@ linters: - gosec settings: - # The process has one HTTP client, built in internal/http. + # The process has one HTTP client, built in client/http. forbidigo: analyze-types: true forbid: # Anchored to the package, as net/http has more methods named Get, such as Header.Get. - pattern: ^http\.(Client|DefaultClient|Transport|DefaultTransport|Get|Head|Post|PostForm)$ pkg: ^net/http$ - msg: the process has one HTTP client, built in internal/http; take it from there rather than making another + msg: the process has one HTTP client, built in client/http; take it from there rather than making another # A user agent made anywhere else drifts from the one the front end names itself by. - pattern: ^http\.UserAgent$ - pkg: ^github\.com/meshcloud/meshstack-cli/internal/http$ + pkg: ^github\.com/meshcloud/meshstack-cli/client/http$ msg: a client carries the user agent of the front end; take the client from your caller, or from auth.ResolveSessionOptions.HttpClient # A test that sleeps for real is slow, and flaky once the machine is slower than the # sleep assumed. synctest.Sleep panics outside a bubble, so it cannot be used the same way. @@ -308,9 +308,6 @@ linters: - encoding/json/v2 - github.com/meshcloud/meshstack-cli/cmd/internal - github.com/meshcloud/meshstack-cli/client - # the request options client.Raw.DoRequest takes, which pkg/ does not expose: they are for the - # CLI alone - - github.com/meshcloud/meshstack-cli/internal/http # the API docs choose the version of a request - github.com/meshcloud/meshstack-cli/internal/apidocs # a full URL picks the stored profile whose endpoint holds it, and has to fit an endpoint @@ -334,8 +331,7 @@ linters: allow: - $gostd - log/slog - # the proxy that serves the state to tofu. It needs the request options of - # client.Raw.DoRequest, and pkg/ does not expose them, because they are for the CLI alone. + # the proxy that serves the state to tofu - github.com/meshcloud/meshstack-cli/internal/tfstate - github.com/meshcloud/meshstack-cli/cmd/internal - github.com/meshcloud/meshstack-cli/pkg/setting @@ -432,7 +428,7 @@ linters: - github.com/charmbracelet/colorprofile # The package the Terraform provider consumes most directly, so it reaches nothing - # beyond the standard library and the three packages below. + # beyond the standard library and the packages below. client: files: # Both patterns are needed: '**/dir/**/*.go' only matches files in @@ -450,9 +446,7 @@ linters: - encoding/json/jsontext - log/slog - github.com/meshcloud/meshstack-cli/client - - github.com/meshcloud/meshstack-cli/internal/http - github.com/meshcloud/meshstack-cli/internal/json - - github.com/meshcloud/meshstack-cli/internal/version pkg: files: @@ -470,9 +464,9 @@ linters: - github.com/meshcloud/meshstack-cli/internal # client reaches these two, so whatever they may import, client gets. - internal-http: + client-http: files: - - "**/internal/http/*.go" + - "**/client/http/*.go" - "**/internal/json/*.go" - "!$test" list-mode: strict @@ -482,9 +476,9 @@ linters: - encoding/json/jsontext - github.com/meshcloud/meshstack-cli/internal/json - internal-version: + client-types-version: files: - - "**/internal/version/*.go" + - "**/client/types/version/*.go" - "!$test" list-mode: strict deny: diff --git a/AGENTS.md b/AGENTS.md index ad9c80b8..ac9f9862 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,7 +47,7 @@ The binary gets its name from its directory, `cmd/meshstack`, which is what `tas **Load the `development` skill before you write or review Go code here.** It holds the package layout, the split of a command into a front end in `cmd/` and its logic in `internal/`, the command -tree, the dependency policy, and what `client/`, `internal/http` and the settings must keep. +tree, the dependency policy, and what `client/`, `client/http` and the settings must keep. [`skills/meshstack-cli`](skills/meshstack-cli/SKILL.md) is the skill for those who **use** the CLI; other repositories link to it. A change to what a command does, prints or needs updates it in the diff --git a/client/building_block_definition.go b/client/building_block_definition.go index ba1a951e..246dbbf4 100644 --- a/client/building_block_definition.go +++ b/client/building_block_definition.go @@ -3,10 +3,10 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types" "github.com/meshcloud/meshstack-cli/client/types/enum" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshBuildingBlockType string diff --git a/client/building_block_definition_version.go b/client/building_block_definition_version.go index b5f00764..dfac2ab2 100644 --- a/client/building_block_definition_version.go +++ b/client/building_block_definition_version.go @@ -8,10 +8,10 @@ import ( "fmt" "uuid" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types" "github.com/meshcloud/meshstack-cli/client/types/enum" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshBuildingBlockDefinitionVersionState string diff --git a/client/building_block_run_action.go b/client/building_block_run_action.go index f85fe026..5be77174 100644 --- a/client/building_block_run_action.go +++ b/client/building_block_run_action.go @@ -6,8 +6,8 @@ import ( gohttp "net/http" "net/url" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) // Link is a HAL link. meshStack sends the link of an action only while the caller may take it. diff --git a/client/building_block_runner.go b/client/building_block_runner.go index a18ec871..d94ebac8 100644 --- a/client/building_block_runner.go +++ b/client/building_block_runner.go @@ -4,8 +4,8 @@ import ( "context" "errors" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshBuildingBlockRunnerImplementationType string diff --git a/client/building_block_v2.go b/client/building_block_v2.go index a98cc7dc..1aa6a11e 100644 --- a/client/building_block_v2.go +++ b/client/building_block_v2.go @@ -8,10 +8,10 @@ import ( "fmt" "slices" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types" "github.com/meshcloud/meshstack-cli/client/types/enum" - "github.com/meshcloud/meshstack-cli/internal/http" ) type BuildingBlockLifecycleState string diff --git a/client/client.go b/client/client.go index 90dd0d8c..8a265544 100644 --- a/client/client.go +++ b/client/client.go @@ -3,16 +3,14 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" + "github.com/meshcloud/meshstack-cli/client/types/version" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" - "github.com/meshcloud/meshstack-cli/internal/version" ) var MinMeshStackVersion = version.MustParse("2026.47.0") -// Version is re-exported because MinMeshStackVersion is one and internal/version is closed to -// another module. type Version = version.Version type HttpError = http.Error diff --git a/internal/http/auth.go b/client/http/auth.go similarity index 100% rename from internal/http/auth.go rename to client/http/auth.go diff --git a/internal/http/download.go b/client/http/download.go similarity index 100% rename from internal/http/download.go rename to client/http/download.go diff --git a/internal/http/download_test.go b/client/http/download_test.go similarity index 98% rename from internal/http/download_test.go rename to client/http/download_test.go index 45e73223..f1714b0d 100644 --- a/internal/http/download_test.go +++ b/client/http/download_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/logs" ) diff --git a/internal/http/http_client.go b/client/http/http_client.go similarity index 100% rename from internal/http/http_client.go rename to client/http/http_client.go diff --git a/internal/http/http_client_test.go b/client/http/http_client_test.go similarity index 99% rename from internal/http/http_client_test.go rename to client/http/http_client_test.go index ddd57ca1..3823545a 100644 --- a/internal/http/http_client_test.go +++ b/client/http/http_client_test.go @@ -1,5 +1,5 @@ // Package http_test drives the client from the outside, so that it can parse answers into the -// types real callers declare. internal/http may not import any of them. +// types real callers declare. client/http may not import any of them. package http_test import ( @@ -19,8 +19,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/logs" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" diff --git a/internal/http/http_error.go b/client/http/http_error.go similarity index 100% rename from internal/http/http_error.go rename to client/http/http_error.go diff --git a/internal/http/http_error_test.go b/client/http/http_error_test.go similarity index 100% rename from internal/http/http_error_test.go rename to client/http/http_error_test.go diff --git a/internal/http/logging.go b/client/http/logging.go similarity index 100% rename from internal/http/logging.go rename to client/http/logging.go diff --git a/internal/http/logging_internal_test.go b/client/http/logging_internal_test.go similarity index 100% rename from internal/http/logging_internal_test.go rename to client/http/logging_internal_test.go diff --git a/internal/http/logging_test.go b/client/http/logging_test.go similarity index 96% rename from internal/http/logging_test.go rename to client/http/logging_test.go index 8bcbf189..b9533d66 100644 --- a/internal/http/logging_test.go +++ b/client/http/logging_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" ) // TestJsonLogRedactsTheToken uses a handler that encodes attributes as JSON rather than diff --git a/internal/http/method.go b/client/http/method.go similarity index 100% rename from internal/http/method.go rename to client/http/method.go diff --git a/internal/http/options.go b/client/http/options.go similarity index 100% rename from internal/http/options.go rename to client/http/options.go diff --git a/internal/http/retry.go b/client/http/retry.go similarity index 100% rename from internal/http/retry.go rename to client/http/retry.go diff --git a/internal/http/retry_test.go b/client/http/retry_test.go similarity index 100% rename from internal/http/retry_test.go rename to client/http/retry_test.go diff --git a/internal/http/stall.go b/client/http/stall.go similarity index 100% rename from internal/http/stall.go rename to client/http/stall.go diff --git a/internal/http/stall_test.go b/client/http/stall_test.go similarity index 100% rename from internal/http/stall_test.go rename to client/http/stall_test.go diff --git a/internal/http/user_agent.go b/client/http/user_agent.go similarity index 100% rename from internal/http/user_agent.go rename to client/http/user_agent.go diff --git a/client/internal/mesh_object.go b/client/internal/mesh_object.go index 9147f6f0..8f3cbe40 100644 --- a/client/internal/mesh_object.go +++ b/client/internal/mesh_object.go @@ -13,8 +13,8 @@ import ( "strings" "unicode" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" ) type HttpClient struct { diff --git a/client/landingzone.go b/client/landingzone.go index 80fd4cc3..1f3b3f3b 100644 --- a/client/landingzone.go +++ b/client/landingzone.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshLandingZone struct { diff --git a/client/mesh_info.go b/client/mesh_info.go index 6c7d8306..e2c123e4 100644 --- a/client/mesh_info.go +++ b/client/mesh_info.go @@ -4,10 +4,10 @@ import ( "context" "fmt" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/enum" + "github.com/meshcloud/meshstack-cli/client/types/version" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" - "github.com/meshcloud/meshstack-cli/internal/version" ) // MeshFeatureFlag names an optional meshStack capability. /mesh/info reports each one as a bool of diff --git a/client/platform.go b/client/platform.go index 53dd9c56..f20e8983 100644 --- a/client/platform.go +++ b/client/platform.go @@ -3,9 +3,9 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshPlatform struct { diff --git a/client/platform_type.go b/client/platform_type.go index 69cb3bfe..37ea81f4 100644 --- a/client/platform_type.go +++ b/client/platform_type.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshPlatformType struct { diff --git a/client/project.go b/client/project.go index 5da6d19b..c8e06165 100644 --- a/client/project.go +++ b/client/project.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshProject struct { diff --git a/client/project_group_binding.go b/client/project_group_binding.go index 59204123..4aa3bc91 100644 --- a/client/project_group_binding.go +++ b/client/project_group_binding.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshProjectGroupBinding struct { diff --git a/client/project_user_binding.go b/client/project_user_binding.go index 7bd62cb8..086d8375 100644 --- a/client/project_user_binding.go +++ b/client/project_user_binding.go @@ -3,9 +3,9 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types/enum" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshProjectUserBinding struct { diff --git a/client/raw.go b/client/raw.go index 17bdd4c5..665580b7 100644 --- a/client/raw.go +++ b/client/raw.go @@ -10,8 +10,8 @@ import ( "time" "uuid" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type ListOptions = internal.ListOptions @@ -21,9 +21,7 @@ type Page = internal.Page // SortCriteria holds one `property,(asc|desc)` criterion per element, such as createdAt,desc. type SortCriteria []string -// RawClient answers with the JSON meshStack sent, for the CLI, which writes it out as it came. It -// is the CLI's alone: DoRequest takes the options of internal/http, which Go's internal rule closes -// to the Terraform provider. +// RawClient answers with the JSON meshStack sent, for the CLI, which writes it out as it came. type RawClient struct { httpClient internal.HttpClient apis map[reflect.Type]rawApi diff --git a/client/raw_test.go b/client/raw_test.go index 8f8f4a4c..4f1a1922 100644 --- a/client/raw_test.go +++ b/client/raw_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" ) diff --git a/client/service_instance.go b/client/service_instance.go index 3b111413..f62ab334 100644 --- a/client/service_instance.go +++ b/client/service_instance.go @@ -3,9 +3,9 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshServiceInstance struct { diff --git a/client/tenant_v4.go b/client/tenant_v4.go index 696723c4..43a2427f 100644 --- a/client/tenant_v4.go +++ b/client/tenant_v4.go @@ -5,9 +5,9 @@ import ( "errors" "fmt" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" "github.com/meshcloud/meshstack-cli/client/types/enum" - "github.com/meshcloud/meshstack-cli/internal/http" ) type TenantLifecycleState string diff --git a/internal/version/version.go b/client/types/version/version.go similarity index 100% rename from internal/version/version.go rename to client/types/version/version.go diff --git a/internal/version/version_test.go b/client/types/version/version_test.go similarity index 100% rename from internal/version/version_test.go rename to client/types/version/version_test.go diff --git a/client/user.go b/client/user.go index 14c95684..f0b433f0 100644 --- a/client/user.go +++ b/client/user.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshUser struct { diff --git a/client/workspace_group_binding.go b/client/workspace_group_binding.go index d2e4bc54..187da981 100644 --- a/client/workspace_group_binding.go +++ b/client/workspace_group_binding.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshWorkspaceGroupBinding struct { diff --git a/client/workspace_user_binding.go b/client/workspace_user_binding.go index d8a37dd4..3575eae8 100644 --- a/client/workspace_user_binding.go +++ b/client/workspace_user_binding.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshWorkspaceUserBinding struct { diff --git a/client/workspace_user_group.go b/client/workspace_user_group.go index cc9fa35d..e6a74478 100644 --- a/client/workspace_user_group.go +++ b/client/workspace_user_group.go @@ -3,8 +3,8 @@ package client import ( "context" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/internal" - "github.com/meshcloud/meshstack-cli/internal/http" ) type MeshWorkspaceUserGroup struct { diff --git a/cmd/api/api.go b/cmd/api/api.go index 727c3640..d870a155 100644 --- a/cmd/api/api.go +++ b/cmd/api/api.go @@ -16,9 +16,9 @@ import ( "github.com/spf13/cobra" "github.com/meshcloud/meshstack-cli/client" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/openapi" "github.com/meshcloud/meshstack-cli/cmd/internal" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/setting" ) diff --git a/cmd/buildingblock/tfstate/tfstate_test.go b/cmd/buildingblock/tfstate/tfstate_test.go index e56b2d32..0857473c 100644 --- a/cmd/buildingblock/tfstate/tfstate_test.go +++ b/cmd/buildingblock/tfstate/tfstate_test.go @@ -17,9 +17,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/cmd/buildingblock/tfstate" "github.com/meshcloud/meshstack-cli/cmd/internal" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" "github.com/meshcloud/meshstack-cli/internal/testutil/testlogin" diff --git a/cmd/buildingblockrun/logs.go b/cmd/buildingblockrun/logs.go index 33b5a37c..c4b5c58c 100644 --- a/cmd/buildingblockrun/logs.go +++ b/cmd/buildingblockrun/logs.go @@ -78,7 +78,7 @@ const ( const ( pollInterval = 2 * time.Second maxPollWait = time.Minute - // The HTTP client has retried each failed poll for minutes already, see internal/http. + // The HTTP client has retried each failed poll for minutes already, see client/http. maxFailedPollsInARow = 5 ) diff --git a/cmd/internal/buildingblock/run_wait_test.go b/cmd/internal/buildingblock/run_wait_test.go index 8f5109a8..91ab5aaf 100644 --- a/cmd/internal/buildingblock/run_wait_test.go +++ b/cmd/internal/buildingblock/run_wait_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/require" "github.com/meshcloud/meshstack-cli/client" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" ) diff --git a/cmd/internal/testacc/api_get_test.go b/cmd/internal/testacc/api_get_test.go index 13c1f387..ae05ac28 100644 --- a/cmd/internal/testacc/api_get_test.go +++ b/cmd/internal/testacc/api_get_test.go @@ -19,10 +19,10 @@ import ( "github.com/stretchr/testify/require" "github.com/meshcloud/meshstack-cli/client" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/openapi" "github.com/meshcloud/meshstack-cli/cmd/internal" "github.com/meshcloud/meshstack-cli/internal/apidocs" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/pkg/auth" ) diff --git a/cmd/meshstack/meshstack.go b/cmd/meshstack/meshstack.go index 5c1b2759..720e82ae 100644 --- a/cmd/meshstack/meshstack.go +++ b/cmd/meshstack/meshstack.go @@ -28,7 +28,7 @@ import ( func main() { // No deadline bounds a command as a whole, since a listing takes as long as it is long. The - // HTTP client gives up on a server that stopped answering, see internal/http. + // HTTP client gives up on a server that stopped answering, see client/http. ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) err := newRootCommand().ExecuteContext(ctx) stop() diff --git a/go.mod b/go.mod index ec971b2c..d379a20b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/meshcloud/meshstack-cli -// 1.27 is the floor because internal/http declares generic methods, which no earlier release +// 1.27 is the floor because client/http declares generic methods, which no earlier release // compiles. Keep the pins in flake.nix (go_1_27 and GOROOT) and in the // Dockerfile in lock-step. The nixpkgs package (pkgs/by-name/me/meshstack-cli/package.nix // of NixOS/nixpkgs) builds with the default Go of nixpkgs, so raising the floor above that diff --git a/internal/apidocs/apidocs.go b/internal/apidocs/apidocs.go index cdf5d27c..f88ba1c2 100644 --- a/internal/apidocs/apidocs.go +++ b/internal/apidocs/apidocs.go @@ -14,12 +14,12 @@ import ( "os" "strings" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/openapi" + "github.com/meshcloud/meshstack-cli/client/types/version" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/config" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/setting" - "github.com/meshcloud/meshstack-cli/internal/version" ) var ( diff --git a/internal/apidocs/apidocs_test.go b/internal/apidocs/apidocs_test.go index f10cbe6f..586bca45 100644 --- a/internal/apidocs/apidocs_test.go +++ b/internal/apidocs/apidocs_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/config" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" ) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 13bf060c..541617d0 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -8,7 +8,7 @@ import ( "time" "github.com/meshcloud/meshstack-cli/client" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" ) diff --git a/internal/auth/credential/apikey.go b/internal/auth/credential/apikey.go index bb61217a..cfc69195 100644 --- a/internal/auth/credential/apikey.go +++ b/internal/auth/credential/apikey.go @@ -6,8 +6,8 @@ import ( "fmt" "uuid" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" ) diff --git a/internal/auth/credential/credential.go b/internal/auth/credential/credential.go index 1b5e214d..f0b1bcfb 100644 --- a/internal/auth/credential/credential.go +++ b/internal/auth/credential/credential.go @@ -7,7 +7,7 @@ import ( "reflect" "strings" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" ) diff --git a/internal/auth/credential/manual.go b/internal/auth/credential/manual.go index 55a27dbc..66a7e6cd 100644 --- a/internal/auth/credential/manual.go +++ b/internal/auth/credential/manual.go @@ -4,8 +4,8 @@ import ( "context" "fmt" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" ) diff --git a/internal/auth/credential/oidclogin.go b/internal/auth/credential/oidclogin.go index fc5f494f..33a7aaf0 100644 --- a/internal/auth/credential/oidclogin.go +++ b/internal/auth/credential/oidclogin.go @@ -8,8 +8,8 @@ import ( gohttp "net/http" "time" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/oidc" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" diff --git a/internal/auth/login.go b/internal/auth/login.go index ccb87644..41cce365 100644 --- a/internal/auth/login.go +++ b/internal/auth/login.go @@ -8,8 +8,8 @@ import ( "sync" "github.com/meshcloud/meshstack-cli/client" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/auth/credential" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/profile" "github.com/meshcloud/meshstack-cli/internal/setting" diff --git a/internal/auth/session.go b/internal/auth/session.go index 4f0d5507..b9892d97 100644 --- a/internal/auth/session.go +++ b/internal/auth/session.go @@ -8,9 +8,9 @@ import ( "sync" "github.com/meshcloud/meshstack-cli/client" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/auth/credential" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/profile" "github.com/meshcloud/meshstack-cli/internal/setting" diff --git a/internal/auth/session_test.go b/internal/auth/session_test.go index 0b9408e6..513451fa 100644 --- a/internal/auth/session_test.go +++ b/internal/auth/session_test.go @@ -13,11 +13,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/auth" "github.com/meshcloud/meshstack-cli/internal/auth/credential" "github.com/meshcloud/meshstack-cli/internal/config" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/logs" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/profile" diff --git a/internal/auth/version_check.go b/internal/auth/version_check.go index 7ceb31ed..91ce02f0 100644 --- a/internal/auth/version_check.go +++ b/internal/auth/version_check.go @@ -8,11 +8,11 @@ import ( "log/slog" "time" + "github.com/meshcloud/meshstack-cli/client/http" + "github.com/meshcloud/meshstack-cli/client/types/version" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/config" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/json" - "github.com/meshcloud/meshstack-cli/internal/version" ) const ( @@ -20,7 +20,7 @@ const ( releaseCheckTimeout = 10 * time.Second ) -// warnIfNewerReleasePresent lives here rather than in internal/version, which the depguard rule +// warnIfNewerReleasePresent lives here rather than in client/types/version, which the depguard rule // in .golangci.yml keeps closed to everything but the standard library. func warnIfNewerReleasePresent(ctx context.Context, configDir config.Directory, client http.Client, opts ResolveSessionOptions) (err error) { currentVersion, err := version.Parse(opts.Version) diff --git a/internal/auth/workspace_test.go b/internal/auth/workspace_test.go index c72234d3..4f5e8f1b 100644 --- a/internal/auth/workspace_test.go +++ b/internal/auth/workspace_test.go @@ -7,10 +7,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" "github.com/meshcloud/meshstack-cli/internal/auth" "github.com/meshcloud/meshstack-cli/internal/auth/credential" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/oidc" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" diff --git a/internal/oidc/client.go b/internal/oidc/client.go index f5482ac6..9b669660 100644 --- a/internal/oidc/client.go +++ b/internal/oidc/client.go @@ -8,8 +8,8 @@ import ( "net/url" "time" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/json" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" "github.com/meshcloud/meshstack-cli/internal/oidc/scope" diff --git a/internal/oidc/client_test.go b/internal/oidc/client_test.go index 53981140..de6cb87f 100644 --- a/internal/oidc/client_test.go +++ b/internal/oidc/client_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/client/types/xurl" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/oidc" "github.com/meshcloud/meshstack-cli/internal/oidc/scope" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" diff --git a/internal/testutil/fakemeshstack/fakemeshstack.go b/internal/testutil/fakemeshstack/fakemeshstack.go index 80f524f3..8bb6372c 100644 --- a/internal/testutil/fakemeshstack/fakemeshstack.go +++ b/internal/testutil/fakemeshstack/fakemeshstack.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" ) // DefaultVersion is at least client.MinMeshStackVersion, or the CLI refuses the backend. diff --git a/internal/tfstate/apiproxy/apiproxy.go b/internal/tfstate/apiproxy/apiproxy.go index b2944a78..1bbc56ef 100644 --- a/internal/tfstate/apiproxy/apiproxy.go +++ b/internal/tfstate/apiproxy/apiproxy.go @@ -1,6 +1,6 @@ // Package apiproxy passes requests on to the meshStack API. It stands apart from internal/tfstate // because httputil.ReverseProxy takes a transport rather than a client, and forbidigo keeps the -// transport to internal/http and this package. +// transport to client/http and this package. package apiproxy import ( @@ -9,7 +9,7 @@ import ( "net/url" "strings" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" ) // New replaces the Authorization a request came with by that of client, and passes a request diff --git a/internal/tfstate/lock.go b/internal/tfstate/lock.go index 9b5bd114..b5ec920f 100644 --- a/internal/tfstate/lock.go +++ b/internal/tfstate/lock.go @@ -9,7 +9,7 @@ import ( "uuid" "github.com/meshcloud/meshstack-cli/client" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" ) type Lock struct { diff --git a/internal/tfstate/proxy.go b/internal/tfstate/proxy.go index 6a35ed81..5c6de5ff 100644 --- a/internal/tfstate/proxy.go +++ b/internal/tfstate/proxy.go @@ -17,8 +17,8 @@ import ( "sync" "time" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/auth" - "github.com/meshcloud/meshstack-cli/internal/http" "github.com/meshcloud/meshstack-cli/internal/meshstack" "github.com/meshcloud/meshstack-cli/internal/profile" "github.com/meshcloud/meshstack-cli/internal/tfstate/apiproxy" diff --git a/internal/tfstate/proxy_test.go b/internal/tfstate/proxy_test.go index 072bc81a..890a5030 100644 --- a/internal/tfstate/proxy_test.go +++ b/internal/tfstate/proxy_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" "github.com/meshcloud/meshstack-cli/internal/oidc/jwt" "github.com/meshcloud/meshstack-cli/internal/testutil/fakemeshstack" ) diff --git a/internal/tfstate/store.go b/internal/tfstate/store.go index 46872449..a5430b84 100644 --- a/internal/tfstate/store.go +++ b/internal/tfstate/store.go @@ -10,7 +10,7 @@ import ( gohttp "net/http" "uuid" - "github.com/meshcloud/meshstack-cli/internal/http" + "github.com/meshcloud/meshstack-cli/client/http" ) // ErrNoState is meshStack's 404, which tofu's http backend takes for a state not written yet.