diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3cd3d6..19f368e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,29 @@ jobs: - name: Verify Build run: go build ./... + - name: Compile documented import path + # Guards the public import path used in the README and docs. + run: | + mkdir -p /tmp/consumer && cd /tmp/consumer + cat > main.go <<'GO' + package main + + import ( + "github.com/keymint-dev/keymint-go" + legacy "github.com/keymint-dev/keymint-go/src" + ) + + func main() { + c, _ := keymint.New("key", "") + _, _ = c.ActivateKey(keymint.ActivateKeyParams{HostID: keymint.String("host")}) + _, _ = legacy.New("key", "") + } + GO + go mod init consumer + go mod edit -require=github.com/keymint-dev/keymint-go@v0.0.0 -replace="github.com/keymint-dev/keymint-go=$GITHUB_WORKSPACE" + go mod tidy + go build ./... + - name: Run contract tests run: go test ./... -run 'TestSignKey|TestGetKey|TestActivateKey|TestCreateKey|TestFloating|TestApiErrors' -v @@ -61,4 +84,4 @@ jobs: KEYMINT_TEST_READONLY_API_KEY: ${{ secrets.KEYMINT_TEST_READONLY_API_KEY }} KEYMINT_TEST_CLIENT_API_KEY: ${{ secrets.KEYMINT_TEST_CLIENT_API_KEY }} KEYMINT_TEST_PRODUCT_ID: ${{ vars.KEYMINT_TEST_PRODUCT_ID }} - run: go test ./src/ -run TestLiveLicenseWorkflowsEndToEnd -v + run: go test . -run TestLiveLicenseWorkflowsEndToEnd -v diff --git a/src/Identity.go b/Identity.go similarity index 100% rename from src/Identity.go rename to Identity.go diff --git a/src/Index.go b/Index.go similarity index 100% rename from src/Index.go rename to Index.go diff --git a/Pointers.go b/Pointers.go new file mode 100644 index 0000000..06394df --- /dev/null +++ b/Pointers.go @@ -0,0 +1,11 @@ +package keymint + +// String returns a pointer to s, for optional string fields such as +// ActivateKeyParams.HostID. +func String(s string) *string { return &s } + +// Int returns a pointer to i, for optional integer fields. +func Int(i int) *int { return &i } + +// Bool returns a pointer to b, for optional boolean fields. +func Bool(b bool) *bool { return &b } diff --git a/README.md b/README.md index 3be54e0..ccf3d20 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,15 @@ Add the SDK to your project: go get github.com/keymint-dev/keymint-go ``` +### Upgrading from v1.5.0 or earlier + +Import the module root, `github.com/keymint-dev/keymint-go`. The old +`github.com/keymint-dev/keymint-go/src` path still compiles but is deprecated +and will be removed in a future major version. + +Optional fields take pointers; use the helpers `keymint.String`, `keymint.Int` +and `keymint.Bool`, for example `HostID: keymint.String(hostId)`. + ## Usage ```go diff --git a/src/Types.go b/Types.go similarity index 100% rename from src/Types.go rename to Types.go diff --git a/src/Webhook.go b/Webhook.go similarity index 100% rename from src/Webhook.go rename to Webhook.go diff --git a/src/contract_test.go b/contract_test.go similarity index 100% rename from src/contract_test.go rename to contract_test.go diff --git a/src/live_test.go b/live_test.go similarity index 100% rename from src/live_test.go rename to live_test.go diff --git a/src/compat.go b/src/compat.go new file mode 100644 index 0000000..8bb739c --- /dev/null +++ b/src/compat.go @@ -0,0 +1,71 @@ +// Package keymint (import path github.com/keymint-dev/keymint-go/src) is +// deprecated: import github.com/keymint-dev/keymint-go instead. This package +// only forwards to the module root so existing /src imports keep compiling. +package keymint + +import km "github.com/keymint-dev/keymint-go" + +// Types. +type ( + Client = km.Client + NewCustomer = km.NewCustomer + KeyFormat = km.KeyFormat + CreateKeyParams = km.CreateKeyParams + CreateKeyResponse = km.CreateKeyResponse + ApiErrorDetails = km.ApiErrorDetails + ApiError = km.ApiError + ActivateKeyParams = km.ActivateKeyParams + ActivationLicensee = km.ActivationLicensee + ActivateKeyResponse = km.ActivateKeyResponse + DeactivateKeyParams = km.DeactivateKeyParams + DeactivateKeyResponse = km.DeactivateKeyResponse + DeviceDetails = km.DeviceDetails + LicenseDetails = km.LicenseDetails + CustomerDetails = km.CustomerDetails + GetKeyParams = km.GetKeyParams + GetKeyResponse = km.GetKeyResponse + BlockKeyParams = km.BlockKeyParams + BlockKeyResponse = km.BlockKeyResponse + UnblockKeyParams = km.UnblockKeyParams + UnblockKeyResponse = km.UnblockKeyResponse + CreateCustomerParams = km.CreateCustomerParams + CreateCustomerResponse = km.CreateCustomerResponse + Customer = km.Customer + GetAllCustomersParams = km.GetAllCustomersParams + PaginationMeta = km.PaginationMeta + GetAllCustomersResponse = km.GetAllCustomersResponse + GetCustomerWithKeysParams = km.GetCustomerWithKeysParams + CustomerLicenseKey = km.CustomerLicenseKey + GetCustomerWithKeysResponse = km.GetCustomerWithKeysResponse + UpdateCustomerParams = km.UpdateCustomerParams + UpdateCustomerResponse = km.UpdateCustomerResponse + ToggleCustomerStatusParams = km.ToggleCustomerStatusParams + ToggleCustomerStatusResponse = km.ToggleCustomerStatusResponse + GetCustomerByIdParams = km.GetCustomerByIdParams + GetCustomerByIdResponse = km.GetCustomerByIdResponse + DeleteCustomerParams = km.DeleteCustomerParams + DeleteCustomerResponse = km.DeleteCustomerResponse + FloatingCheckoutParams = km.FloatingCheckoutParams + FloatingCheckoutResponse = km.FloatingCheckoutResponse + FloatingHeartbeatParams = km.FloatingHeartbeatParams + FloatingHeartbeatResponse = km.FloatingHeartbeatResponse + FloatingCheckinParams = km.FloatingCheckinParams + FloatingCheckinResponse = km.FloatingCheckinResponse + UpdateKeyParams = km.UpdateKeyParams + UpdateKeyResponse = km.UpdateKeyResponse + SignKeyParams = km.SignKeyParams + SignKeyResponse = km.SignKeyResponse + RequestOptions = km.RequestOptions +) + +// Functions. +var ( + GetMachineID = km.GetMachineID + GetOrCreateInstallationID = km.GetOrCreateInstallationID + GenerateSessionSignature = km.GenerateSessionSignature + New = km.New + VerifyWebhookSignature = km.VerifyWebhookSignature + String = km.String + Int = km.Int + Bool = km.Bool +)