From 095cd7b17f0a7b2a76bc87cda8bedb2ca3f859f9 Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:09:19 +1000 Subject: [PATCH 1/4] Add golangci-lint --- .github/workflows/lint.yml | 22 +++++++++++++++++++ .golangci.yml | 43 ++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 ++ Makefile | 19 +++++++++++++++++ README.md | 17 +++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yml create mode 100644 Makefile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..8ddafea7 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint +on: + push: + paths-ignore: + - '**.md' + - 'releases.json' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: go.mod + + - name: Lint + uses: golangci/golangci-lint-action@v8 + with: + version: v2.14.0 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..89491778 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,43 @@ +version: "2" +linters: + settings: + staticcheck: + checks: + # S1002 - should omit comparison to bool constant + # Justification (opinion): comparison to bool constant can be clearer in some cases + - -S1002 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofumpt + # Disabled this formatter temporarily because it reports too many issues. + # - golines + - gci + settings: + # Disabled this formatter temporarily because it reports too many issues. + # golines: + # max-len: 120 + gci: + sections: + - standard + - default + - blank + - dot + - alias + - localmodule + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 443130bd..a522cd6c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,8 @@ Issues will be triaged and modified (if necessary) by the [CODEOWNERS](CODEOWNER This project employs [branch protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule); the `main` branch is protected. Therefore, your changes MUST be committed to a branch and submitted as a pull request. Also, this project requires the use of [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for all commit messages. Using Conventional Commits enables this project to autogenerate its [CHANGELOG.md](../CHANGELOG.md) and release notes. +Your pull request must pass `golangci-lint`. For instructions, see "Linting and formatting" in the [Developer Guide](README.md#linting-and-formatting). + ### Your Pull Request is Merged! Now What? Congratulations! :tada: And thank you very much for your contribution to this project! diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..5107d525 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +.PHONY: test lint fmt + +test: + go test -v ./... + +.PHONY: check-golangci-lint +check-golangci-lint: + @command -v golangci-lint >/dev/null 2>&1 || { \ + echo "golangci-lint is not installed. See https://golangci-lint.run for instructions."; \ + exit 1; \ + } + +.PHONY: lint +lint: check-golangci-lint + golangci-lint run ./... + +.PHONY: fmt +fmt: check-golangci-lint + golangci-lint fmt ./... \ No newline at end of file diff --git a/README.md b/README.md index 10cb6659..47a0f4a7 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,23 @@ and add a Visual Studio Code workspace setting (`.vscode/settings.json`) for the "go.testEnvFile": "${workspaceFolder}/.env" } ``` + +### Linting and formatting + +We use [golangci-lint](https://golangci-lint.run) to lint and format the code. The configuration is in `.golangci.yml`. +The pull request workflow runs golangci-lint, and your pull request must pass it. + +See the [golangci-lint website](https://golangci-lint.run) for the install instructions. + +To format the code, and then find lint issues, run these commands in the cli root folder: + +```shell +golangci-lint fmt ./... +golangci-lint run ./... +``` + +If you have make, you can run make fmt and make lint instead. + ## Release Once your pull request has been approved: From 667cee4c7d334d048d93574349595509d0210021 Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:12:44 +1000 Subject: [PATCH 2/4] Run golangci-lint --- examples/accounts/create_azure_oidc.go | 3 +- .../create_azure_service_principal.go | 3 +- .../create_azure_subscription_account.go | 3 +- .../get_steps_using_role.go | 1 - .../get_library_variable_set_by_id.go | 2 +- examples/projects/delete_project.go | 2 +- examples/projects/get_project_by_id.go | 2 +- examples/projects/update_project.go | 2 +- examples/spaces/delete_space.go | 2 +- examples/spaces/get_space_by_id.go | 2 +- examples/teams/create_team.go | 3 +- examples/user_roles/delete_user_role.go | 2 +- examples/users/delete_user.go | 2 +- internal/util_test.go | 4 +- internal/utilities.go | 5 +- internal/validation.go | 3 +- pkg/accounts/account.go | 5 +- pkg/accounts/account_resource.go | 6 +- pkg/accounts/account_resource_test.go | 5 +- pkg/accounts/account_service.go | 4 +- pkg/accounts/account_service_test.go | 5 +- pkg/accounts/account_test.go | 5 +- pkg/accounts/account_utilities_test.go | 3 +- pkg/accounts/accounts.go | 3 +- pkg/accounts/amazon_web_services_account.go | 5 +- .../amazon_web_services_account_test.go | 5 +- pkg/accounts/aws_oidc_account.go | 5 +- pkg/accounts/aws_oidc_account_test.go | 3 +- pkg/accounts/azure_oidc_account.go | 6 +- pkg/accounts/azure_oidc_account_test.go | 6 +- .../azure_service_principal_account.go | 8 ++- .../azure_service_principal_account_test.go | 6 +- pkg/accounts/azure_subscription_account.go | 8 ++- .../azure_subscription_account_test.go | 6 +- pkg/accounts/generic_oidc_account.go | 5 +- pkg/accounts/generic_oidc_account_test.go | 6 +- pkg/accounts/google_cloud_platform_account.go | 5 +- pkg/accounts/queries_test.go | 3 +- pkg/accounts/ssh_key_account.go | 5 +- pkg/accounts/ssh_key_account_test.go | 3 +- pkg/accounts/token_account.go | 5 +- pkg/accounts/token_account_test.go | 3 +- pkg/accounts/username_password_account.go | 5 +- .../username_password_account_test.go | 3 +- pkg/actions/community_action_template.go | 8 ++- .../community_action_template_service.go | 5 +- .../community_action_template_service_test.go | 7 ++- pkg/actiontemplates/action_template.go | 5 +- .../action_template_service.go | 11 ++-- .../action_template_service_test.go | 7 ++- pkg/actiontemplates/query_test.go | 3 +- .../approval_rules_service_test.go | 3 +- pkg/approvals/approvals_service.go | 8 ++- pkg/approvals/approvals_service_test.go | 3 +- pkg/artifacts/artifact_service.go | 5 +- pkg/authentication/authentication_service.go | 3 +- .../authentication_service_test.go | 3 +- pkg/azure/azure_environment_service.go | 3 +- pkg/azure/azure_environment_service_test.go | 3 +- ...azure_devops_connectivity_check_service.go | 3 +- .../build_information_service.go | 3 +- .../build_information_service_test.go | 3 +- pkg/certificates/certificate.go | 3 +- pkg/certificates/certificate_service.go | 3 +- pkg/certificates/certificate_service_test.go | 7 ++- pkg/channels/channel.go | 5 +- .../channel_git_resource_rule_test.go | 3 +- pkg/channels/channel_rule.go | 4 +- pkg/channels/channel_service.go | 9 ++- pkg/channels/channel_service_test.go | 7 ++- pkg/client/client_test.go | 7 ++- pkg/client/octopusdeploy.go | 6 +- pkg/client/root_resource.go | 6 +- pkg/client/root_service.go | 4 +- pkg/client/root_service_test.go | 5 +- pkg/cloudtemplate/cloud_template_service.go | 3 +- .../certificate_configuration_service.go | 3 +- pkg/configuration/configuration_service.go | 3 +- .../configuration_service_test.go | 5 +- pkg/configuration/features_configuration.go | 3 +- .../lets_encrypt_configuration_service.go | 3 +- .../maintenance_configuration_service.go | 3 +- .../performance_configuration_service.go | 3 +- .../server_configuration_service.go | 3 +- .../smtp_configuration_service.go | 3 +- .../upgrade_configuration_service.go | 3 +- pkg/core/sensitive_value_test.go | 3 +- pkg/credentials/anonymous_test.go | 3 +- pkg/credentials/reference_test.go | 5 +- pkg/credentials/resource.go | 1 + pkg/credentials/resource_test.go | 5 +- pkg/credentials/service.go | 3 +- pkg/credentials/service_test.go | 5 +- .../dashboard_configuration_service.go | 3 +- pkg/dashboard/dashboard_service.go | 3 +- .../dashboard_service_httptest_test.go | 3 +- pkg/dashboard/dashboard_service_test.go | 5 +- pkg/defects/defect_test.go | 4 +- .../deploymentfreeze_service_test.go | 6 +- .../deploymentfreezes_service.go | 4 +- pkg/deployments/channel_rule.go | 4 +- pkg/deployments/deploy_release_v1.go | 1 + pkg/deployments/deployment.go | 3 +- pkg/deployments/deployment_action.go | 5 +- pkg/deployments/deployment_process_service.go | 3 +- .../deployment_process_service_test.go | 7 ++- pkg/deployments/deployment_process_test.go | 5 +- pkg/deployments/deployment_service.go | 3 +- pkg/deployments/deployment_service_test.go | 5 +- pkg/deployments/deployment_step.go | 3 +- pkg/environments/environment.go | 3 +- pkg/environments/environment_service.go | 3 +- pkg/environments/environment_service_test.go | 7 ++- pkg/environments/environment_test.go | 5 +- ...a_service_management_extension_settings.go | 6 +- .../servicenow_extension_settings.go | 6 +- .../ephemeral_environment_service.go | 3 - pkg/environments/v2/route.go | 10 ++-- pkg/events/event_service.go | 3 +- pkg/extensions/dynamic_extension_service.go | 3 +- pkg/extensions/extension_settings_test.go | 5 +- ...xternal_security_group_provider_service.go | 3 +- pkg/feeds/artifactory_generic.go | 3 +- pkg/feeds/aws_elastic_container_registry.go | 5 +- pkg/feeds/azure_container_registry.go | 6 +- pkg/feeds/built_in_feed.go | 3 +- pkg/feeds/docker_container_registry.go | 3 +- pkg/feeds/feed.go | 5 +- pkg/feeds/feed_resource.go | 55 ++++++++--------- pkg/feeds/feed_service.go | 5 +- pkg/feeds/feed_service_test.go | 7 ++- pkg/feeds/feed_utilities_test.go | 19 ------ pkg/feeds/gcs_storage_feed.go | 5 +- pkg/feeds/github_feed.go | 3 +- pkg/feeds/google_container_registry.go | 6 +- pkg/feeds/helm_feed.go | 3 +- pkg/feeds/maven_feed.go | 3 +- pkg/feeds/npm_feed.go | 13 ++-- pkg/feeds/nuget_feed.go | 3 +- pkg/feeds/oci_registry_feed.go | 3 +- pkg/feeds/octopus_project_feed.go | 3 +- pkg/feeds/oidc_authentication_test.go | 60 +++++++++---------- pkg/feeds/pypi_feed.go | 5 +- pkg/feeds/s3_bucket.go | 5 +- pkg/githubconnections/settings_test.go | 3 +- pkg/interruptions/interruption.go | 6 +- pkg/interruptions/interruption_service.go | 3 +- .../interruption_service_test.go | 5 +- pkg/invitations/invitation_service.go | 3 +- pkg/issuetrackers/issue_tracker_service.go | 3 +- pkg/jira/jira_integration_service.go | 3 +- .../register_kubernetes_monitor_command.go | 6 +- pkg/licenses/licenses_service.go | 3 +- pkg/lifecycles/lifecycle.go | 4 +- pkg/lifecycles/lifecycle_service.go | 5 +- pkg/lifecycles/lifecycle_service_test.go | 7 ++- pkg/lifecycles/lifecycle_test.go | 5 +- pkg/machinepolicies/machine_policy.go | 27 +++++---- pkg/machines/aws_ecs_cluster_endpoint.go | 6 +- pkg/machines/aws_ecs_cluster_endpoint_test.go | 3 +- pkg/machines/azure_cloud_service_endpoint.go | 6 +- pkg/machines/azure_service_fabric_endpoint.go | 3 +- pkg/machines/azure_web_app_endpoint.go | 6 +- pkg/machines/deployment_target.go | 3 +- pkg/machines/endpoint.go | 3 +- pkg/machines/endpoint_resource.go | 3 +- pkg/machines/kubernetes_endpoint.go | 13 ++-- pkg/machines/kubernetes_endpoint_test.go | 3 +- pkg/machines/kubernetes_tentacle_endpoint.go | 3 +- .../listening_tentacle_endpoint_test.go | 1 - pkg/machines/machine.go | 3 +- pkg/machines/machine_policy.go | 27 +++++---- pkg/machines/machine_policy_service.go | 3 +- pkg/machines/machine_policy_service_test.go | 7 ++- pkg/machines/machine_role_service.go | 3 +- pkg/machines/machine_service.go | 3 +- pkg/machines/machine_service_test.go | 7 ++- pkg/machines/ssh_endpoint.go | 15 +++-- pkg/machines/worker.go | 3 +- pkg/machines/worker_service.go | 6 +- pkg/machines/worker_service_test.go | 7 ++- pkg/machines/worker_test.go | 3 +- pkg/migrations/migration_service.go | 3 +- pkg/newclient/httpsession.go | 11 ++-- pkg/observability/container_logs.go | 31 +++++----- pkg/observability/container_logs_service.go | 2 +- pkg/observability/resource.go | 1 - pkg/observability/resource_events.go | 20 +++---- pkg/observability/resource_events_test.go | 24 ++++---- pkg/observability/resource_test.go | 12 ++-- .../octopus_server_nodes_service.go | 3 +- pkg/packages/multipartstreaming_test.go | 8 ++- pkg/packages/package_delta_upload.go | 20 ++++--- pkg/packages/package_metadata_service.go | 3 +- pkg/packages/package_service.go | 5 +- pkg/packages/package_service_test.go | 7 ++- pkg/packages/package_upload_v2.go | 3 +- pkg/permissions/permission_service.go | 3 +- .../platform_hub_account.go | 5 +- .../platform_hub_account_resource.go | 44 +++++++------- .../platform_hub_account_resource_test.go | 3 +- .../platform_hub_account_service.go | 4 +- .../platform_hub_aws_account.go | 5 +- .../platform_hub_aws_account_test.go | 5 +- .../platform_hub_aws_oidc_account.go | 5 +- .../platform_hub_aws_oidc_account_test.go | 3 +- .../platform_hub_azure_oidc_account.go | 5 +- .../platform_hub_azure_oidc_account_test.go | 3 +- ...orm_hub_azure_service_principal_account.go | 19 +++--- ...ub_azure_service_principal_account_test.go | 5 +- .../platform_hub_gcp_account.go | 5 +- .../platform_hub_gcp_account_test.go | 5 +- .../platform_hub_generic_oidc_account.go | 5 +- .../platform_hub_generic_oidc_account_test.go | 3 +- .../platform_hub_username_password_account.go | 5 +- ...form_hub_username_password_account_test.go | 5 +- .../platform_hub_git_credential.go | 1 + .../service_test.go | 5 +- pkg/platformhubpolicies/service_test.go | 19 +++--- .../resource_test.go | 3 +- .../project_branches_service.go | 8 ++- pkg/projectgroups/project_group_service.go | 4 +- .../project_group_service_test.go | 8 +-- pkg/projects/git_persistence_settings.go | 6 +- pkg/projects/git_persistence_settings_test.go | 5 +- ...a_service_management_extension_settings.go | 8 ++- ...vice_management_extension_settings_test.go | 5 +- pkg/projects/persistence_settings_types.go | 2 +- pkg/projects/project.go | 3 +- pkg/projects/project_service.go | 10 +--- pkg/projects/project_service_git_refs.go | 4 +- pkg/projects/project_service_git_refs_test.go | 6 +- pkg/projects/project_service_test.go | 5 +- pkg/projects/project_test.go | 5 +- pkg/projects/servicenow_extension_settings.go | 8 ++- .../servicenow_extension_settings_test.go | 5 +- .../project_variables_service.go | 3 +- pkg/proxies/proxy_service.go | 3 +- pkg/releases/release.go | 1 - pkg/releases/release_service.go | 7 +-- pkg/releases/release_service_test.go | 3 +- pkg/reporting/reporting_service.go | 3 +- pkg/resources/resources.go | 3 +- pkg/runbooks/queries_test.go | 3 +- pkg/runbooks/run_runbook_v1.go | 1 + pkg/runbooks/runbook.go | 3 +- pkg/runbooks/runbook_process_service.go | 3 +- pkg/runbooks/runbook_process_service_test.go | 3 +- pkg/runbooks/runbook_run_service.go | 3 +- pkg/runbooks/runbook_service.go | 3 +- pkg/runbooks/runbook_service_test.go | 7 ++- pkg/runbooks/runbook_snapshot.go | 7 ++- pkg/runbooks/runbook_snapshot_service.go | 3 +- pkg/runbooks/runbook_snapshot_service_test.go | 7 ++- pkg/scheduler/scheduler_service.go | 3 +- pkg/serverstatus/logs_query_test.go | 3 +- pkg/serverstatus/server_status_service.go | 3 +- pkg/services/api/api.go | 9 ++- .../api/automation_environment_provider.go | 2 +- .../automation_environment_provider_test.go | 6 +- pkg/services/api/environment.go | 3 +- pkg/services/new_service_tests.go | 3 +- pkg/services/service.go | 4 +- pkg/spaces/space.go | 3 +- pkg/spaces/space_service.go | 3 +- pkg/spaces/space_service_test.go | 5 +- pkg/subscriptions/subscription.go | 3 +- pkg/subscriptions/subscription_service.go | 3 +- pkg/subscriptions/subscription_test.go | 3 +- pkg/tagsets/tag_set_service.go | 4 +- pkg/tagsets/tag_set_service_test.go | 5 +- pkg/tasks/task_service.go | 3 +- pkg/teammembership/team_membership_service.go | 3 +- pkg/teams/team.go | 3 +- pkg/teams/team_service.go | 3 +- pkg/teams/team_service_test.go | 5 +- pkg/tenants/tenant.go | 3 +- pkg/tenants/tenant_service.go | 9 ++- pkg/tenants/tenant_service_test.go | 5 +- pkg/triggers/project_trigger.go | 3 +- pkg/triggers/project_trigger_service.go | 7 +-- pkg/triggers/project_trigger_service_test.go | 5 +- pkg/triggers/project_trigger_test.go | 19 +++--- .../scheduled_project_triggers_service.go | 3 +- pkg/useronboarding/user_onboarding_service.go | 3 +- pkg/userroles/scoped_user_role.go | 3 +- pkg/userroles/scoped_user_role_service.go | 3 +- .../scoped_user_role_service_test.go | 7 ++- pkg/userroles/user_role_service.go | 3 +- pkg/users/api_key_service.go | 3 +- pkg/users/api_key_service_test.go | 5 +- pkg/users/user_service.go | 9 +-- pkg/users/user_service_test.go | 23 ++++--- pkg/variables/library_variable_set.go | 3 +- pkg/variables/library_variable_set_service.go | 3 +- .../library_variable_set_service_test.go | 7 ++- pkg/variables/script_module.go | 3 +- pkg/variables/script_module_service.go | 3 +- pkg/variables/script_module_service_test.go | 7 ++- pkg/variables/tenant_variable_service.go | 3 +- pkg/variables/variable_service.go | 3 +- pkg/variables/variable_service_test.go | 5 +- pkg/workerpools/worker_pool.go | 9 ++- pkg/workerpools/worker_pool_resource.go | 3 +- pkg/workerpools/worker_pool_service.go | 5 +- pkg/workerpools/worker_pool_service_test.go | 7 ++- pkg/workerpools/worker_pool_utilities.go | 28 ++++----- .../worker_tools_latest_images_service.go | 3 +- test/e2e/account_service_test.go | 7 ++- test/e2e/action_template_service_test.go | 5 +- test/e2e/api_keys_test.go | 5 +- test/e2e/artifact_service_test.go | 6 +- test/e2e/build_information_test.go | 7 ++- test/e2e/certificate_service_test.go | 5 +- test/e2e/channel_service_test.go | 5 +- .../community_action_template_service_test.go | 5 +- test/e2e/dashboard_service_test.go | 3 +- test/e2e/deployment_freeze_service_test.go | 10 ++-- test/e2e/deployment_process_test.go | 5 +- test/e2e/environment_service_test.go | 5 +- .../e2e/ephemeral_environment_service_test.go | 3 +- test/e2e/event_service_test.go | 3 +- test/e2e/feed_service_test.go | 7 +-- test/e2e/git_credential_service_test.go | 5 +- test/e2e/kubernetes_monitor_test.go | 6 +- test/e2e/library_variables_test.go | 7 ++- test/e2e/lifecycle_service_test.go | 5 +- test/e2e/machine_service_test.go | 5 +- test/e2e/package_service_test.go | 18 +++--- test/e2e/parent_environment_service_test.go | 5 +- test/e2e/project_group_service_test.go | 5 +- test/e2e/project_service_test.go | 5 +- test/e2e/project_test.go | 3 +- test/e2e/project_trigger_test.go | 5 +- test/e2e/rate_limiting_policy_service_test.go | 5 +- test/e2e/release_service_test.go | 12 ++-- test/e2e/root_test.go | 3 +- test/e2e/runbook_service_test.go | 5 +- test/e2e/runbook_snapshot_service_test.go | 18 +++--- test/e2e/script_module_service_test.go | 5 +- test/e2e/server_status_service_test.go | 3 +- ...e_default_retention_policy_service_test.go | 3 +- test/e2e/space_service_test.go | 5 +- test/e2e/tag_service_test.go | 5 +- test/e2e/tagset_service_test.go | 5 +- test/e2e/task_service_test.go | 5 +- test/e2e/team_service_test.go | 5 +- test/e2e/tenant_service_test.go | 5 +- test/e2e/tenant_variables_service_test.go | 3 +- test/e2e/user_role_service_test.go | 5 +- test/e2e/user_service_test.go | 5 +- test/e2e/variable_service_test.go | 5 +- test/e2e/worker_pool_service_test.go | 7 +-- test/e2e/worker_service_test.go | 7 ++- .../anonymous_git_credential_test.go | 3 +- test/resources/build_information_test.go | 3 +- test/resources/certificate_test.go | 3 +- test/resources/channel_test.go | 5 +- test/resources/deployment_action_test.go | 3 +- test/resources/deployment_target_test.go | 3 +- test/resources/display_settings_test.go | 5 +- test/resources/feed_utilities_test.go | 3 +- .../machine_health_check_policy_test.go | 4 +- test/resources/not_all_validator_test.go | 3 +- test/resources/project_test.go | 5 +- test/resources/property_value_test.go | 3 +- test/resources/sensitive_value_test.go | 5 +- test/resources/task_test.go | 3 +- .../username_password_git_credential_test.go | 5 +- test/resources/variable_scope_test.go | 3 +- test/testutil.go | 5 +- uritemplates/uritemplates.go | 7 +-- 372 files changed, 1194 insertions(+), 869 deletions(-) diff --git a/examples/accounts/create_azure_oidc.go b/examples/accounts/create_azure_oidc.go index 507a8a88..eab3923f 100644 --- a/examples/accounts/create_azure_oidc.go +++ b/examples/accounts/create_azure_oidc.go @@ -4,9 +4,10 @@ import ( "fmt" "net/url" + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - uuid "github.com/google/uuid" ) func CreateAzureOIDCExample() { diff --git a/examples/accounts/create_azure_service_principal.go b/examples/accounts/create_azure_service_principal.go index 0e995ff8..2572dff7 100644 --- a/examples/accounts/create_azure_service_principal.go +++ b/examples/accounts/create_azure_service_principal.go @@ -4,10 +4,11 @@ import ( "fmt" "net/url" + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - uuid "github.com/google/uuid" ) func CreateAzureServicePrincipalExample() { diff --git a/examples/accounts/create_azure_subscription_account.go b/examples/accounts/create_azure_subscription_account.go index 9ebe9966..8f2df2dd 100644 --- a/examples/accounts/create_azure_subscription_account.go +++ b/examples/accounts/create_azure_subscription_account.go @@ -4,9 +4,10 @@ import ( "fmt" "net/url" + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - uuid "github.com/google/uuid" ) func CreateAzureSubscriptionAccountExample() { diff --git a/examples/deployment_processes/get_steps_using_role.go b/examples/deployment_processes/get_steps_using_role.go index 344c8180..b0339456 100644 --- a/examples/deployment_processes/get_steps_using_role.go +++ b/examples/deployment_processes/get_steps_using_role.go @@ -39,7 +39,6 @@ func GetStepsUsingRoleExample() { // Loop through list for _, project := range projects { deploymentProcess, err := client.DeploymentProcesses.GetByID(project.DeploymentProcessID) - if err != nil { _ = fmt.Errorf("error: %w", err) } diff --git a/examples/library_variable_sets/get_library_variable_set_by_id.go b/examples/library_variable_sets/get_library_variable_set_by_id.go index 06e0ffcd..5e2b51e5 100644 --- a/examples/library_variable_sets/get_library_variable_set_by_id.go +++ b/examples/library_variable_sets/get_library_variable_set_by_id.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" ) func GetLibraryVariableSetByIDExample() { diff --git a/examples/projects/delete_project.go b/examples/projects/delete_project.go index deb969a5..0ad40cb9 100644 --- a/examples/projects/delete_project.go +++ b/examples/projects/delete_project.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" ) // DeleteProjectExample provides an example of how to delete a project from diff --git a/examples/projects/get_project_by_id.go b/examples/projects/get_project_by_id.go index a09fcb8a..9844af23 100644 --- a/examples/projects/get_project_by_id.go +++ b/examples/projects/get_project_by_id.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" ) func GetProjectByIDExample() { diff --git a/examples/projects/update_project.go b/examples/projects/update_project.go index c6b945b7..99ef8e88 100644 --- a/examples/projects/update_project.go +++ b/examples/projects/update_project.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" ) func UpdateProjectExample() { diff --git a/examples/spaces/delete_space.go b/examples/spaces/delete_space.go index f1ab01ae..d59c6648 100644 --- a/examples/spaces/delete_space.go +++ b/examples/spaces/delete_space.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" ) // DeleteSpaceExample provides an example of how to delete a space from Octopus diff --git a/examples/spaces/get_space_by_id.go b/examples/spaces/get_space_by_id.go index 6fc3fbb3..d85008f9 100644 --- a/examples/spaces/get_space_by_id.go +++ b/examples/spaces/get_space_by_id.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" ) // GetSpaceByIDExample provides an example of how to get a space from Octopus diff --git a/examples/teams/create_team.go b/examples/teams/create_team.go index ae86cb18..44db47b2 100644 --- a/examples/teams/create_team.go +++ b/examples/teams/create_team.go @@ -2,9 +2,10 @@ package examples import ( "fmt" + "net/url" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/teams" - "net/url" ) func CreateTeamExample() { diff --git a/examples/user_roles/delete_user_role.go b/examples/user_roles/delete_user_role.go index 86f6debf..bc1e7502 100644 --- a/examples/user_roles/delete_user_role.go +++ b/examples/user_roles/delete_user_role.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" ) // DeleteUserRoleExample provides an example of how to delete a user role from diff --git a/examples/users/delete_user.go b/examples/users/delete_user.go index 2974185e..43b4d34d 100644 --- a/examples/users/delete_user.go +++ b/examples/users/delete_user.go @@ -2,10 +2,10 @@ package examples import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" ) // DeleteUserExample provides an example of how to delete a user from Octopus diff --git a/internal/util_test.go b/internal/util_test.go index c1c33dfe..92f7a675 100644 --- a/internal/util_test.go +++ b/internal/util_test.go @@ -3,8 +3,9 @@ package internal import ( "testing" - uuid "github.com/google/uuid" "github.com/stretchr/testify/assert" + + uuid "github.com/google/uuid" ) func TestValidateRequiredUUID(t *testing.T) { @@ -90,5 +91,4 @@ func TestTrimTemplate(t *testing.T) { template = "/api/users/{userId}/apikeys" result = TrimTemplate(template) assert.Equal(t, "/api/users", result) - } diff --git a/internal/utilities.go b/internal/utilities.go index e02bae58..5b474696 100644 --- a/internal/utilities.go +++ b/internal/utilities.go @@ -8,9 +8,10 @@ import ( "strings" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/dghubble/sling" "github.com/google/uuid" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" ) const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" @@ -26,7 +27,7 @@ func GetRandomString(length int) string { func GetRandomName() string { fullName := fmt.Sprintf("test-id %s", uuid.New()) - fullName = fullName[0:44] //Some names in Octopus have a max limit of 50 characters (such as Environment Name) + fullName = fullName[0:44] // Some names in Octopus have a max limit of 50 characters (such as Environment Name) return fullName } diff --git a/internal/validation.go b/internal/validation.go index d083153e..492958e4 100644 --- a/internal/validation.go +++ b/internal/validation.go @@ -2,9 +2,10 @@ package internal import ( "fmt" - "github.com/google/uuid" "regexp" "strings" + + "github.com/google/uuid" ) // ValidateStringInSlice checks if a string is in the given slice diff --git a/pkg/accounts/account.go b/pkg/accounts/account.go index 932a6e59..e58ae225 100644 --- a/pkg/accounts/account.go +++ b/pkg/accounts/account.go @@ -1,11 +1,12 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // IAccount defines the interface for accounts. diff --git a/pkg/accounts/account_resource.go b/pkg/accounts/account_resource.go index cf26ea38..1bbc94e4 100644 --- a/pkg/accounts/account_resource.go +++ b/pkg/accounts/account_resource.go @@ -1,11 +1,13 @@ package accounts import ( + "github.com/go-playground/validator/v10" + + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" resources "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - uuid "github.com/google/uuid" ) // AccountResource represents account details used for deployments, including diff --git a/pkg/accounts/account_resource_test.go b/pkg/accounts/account_resource_test.go index 7041dc2e..96ea8e64 100644 --- a/pkg/accounts/account_resource_test.go +++ b/pkg/accounts/account_resource_test.go @@ -5,11 +5,12 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestAccountResource(t *testing.T) { diff --git a/pkg/accounts/account_service.go b/pkg/accounts/account_service.go index 32390b91..f62e3769 100644 --- a/pkg/accounts/account_service.go +++ b/pkg/accounts/account_service.go @@ -1,13 +1,14 @@ package accounts import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) // AccountService handles communication with the account endpoint. @@ -168,7 +169,6 @@ func Add(client newclient.Client, account IAccount) (IAccount, error) { // GetByID returns the account that matches the input ID. func GetByID(client newclient.Client, spaceID string, ID string) (IAccount, error) { - res, err := newclient.GetByID[AccountResource](client, template, spaceID, ID) if err != nil { return nil, err diff --git a/pkg/accounts/account_service_test.go b/pkg/accounts/account_service_test.go index be2701fe..6808a8f2 100644 --- a/pkg/accounts/account_service_test.go +++ b/pkg/accounts/account_service_test.go @@ -3,12 +3,13 @@ package accounts import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createAccountService(t *testing.T) *AccountService { diff --git a/pkg/accounts/account_test.go b/pkg/accounts/account_test.go index 4e4bdbb5..64bd4c9c 100644 --- a/pkg/accounts/account_test.go +++ b/pkg/accounts/account_test.go @@ -3,10 +3,11 @@ package accounts import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestAccount(t *testing.T) { diff --git a/pkg/accounts/account_utilities_test.go b/pkg/accounts/account_utilities_test.go index b105e4b5..1c546dc4 100644 --- a/pkg/accounts/account_utilities_test.go +++ b/pkg/accounts/account_utilities_test.go @@ -3,8 +3,9 @@ package accounts import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestToAccount(t *testing.T) { diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 82d6abea..6568cdff 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -3,9 +3,10 @@ package accounts import ( "encoding/json" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) // Accounts defines a collection of accounts with built-in support for paged diff --git a/pkg/accounts/amazon_web_services_account.go b/pkg/accounts/amazon_web_services_account.go index e7a4e491..ce23d2ea 100644 --- a/pkg/accounts/amazon_web_services_account.go +++ b/pkg/accounts/amazon_web_services_account.go @@ -1,12 +1,13 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // AmazonWebServicesAccount represents an Amazon Web Services (AWS) account. diff --git a/pkg/accounts/amazon_web_services_account_test.go b/pkg/accounts/amazon_web_services_account_test.go index 853a5ed5..ced8d18b 100644 --- a/pkg/accounts/amazon_web_services_account_test.go +++ b/pkg/accounts/amazon_web_services_account_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestAmazonWebServicesAccountNew(t *testing.T) { diff --git a/pkg/accounts/aws_oidc_account.go b/pkg/accounts/aws_oidc_account.go index 4dde3687..b9e7a789 100644 --- a/pkg/accounts/aws_oidc_account.go +++ b/pkg/accounts/aws_oidc_account.go @@ -1,10 +1,11 @@ package accounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) // AwsOIDCAccount represents an AWS OIDC account. diff --git a/pkg/accounts/aws_oidc_account_test.go b/pkg/accounts/aws_oidc_account_test.go index 46f70a8d..31e2e084 100644 --- a/pkg/accounts/aws_oidc_account_test.go +++ b/pkg/accounts/aws_oidc_account_test.go @@ -3,9 +3,10 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestAwsOIDCAccount(t *testing.T) { diff --git a/pkg/accounts/azure_oidc_account.go b/pkg/accounts/azure_oidc_account.go index 95dea57b..042566ff 100644 --- a/pkg/accounts/azure_oidc_account.go +++ b/pkg/accounts/azure_oidc_account.go @@ -1,11 +1,13 @@ package accounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + uuid "github.com/google/uuid" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) // AzureOIDCAccount represents an Azure OIDC account. diff --git a/pkg/accounts/azure_oidc_account_test.go b/pkg/accounts/azure_oidc_account_test.go index e5bc0c4a..a1d07e3c 100644 --- a/pkg/accounts/azure_oidc_account_test.go +++ b/pkg/accounts/azure_oidc_account_test.go @@ -3,10 +3,12 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - uuid "github.com/google/uuid" - "github.com/stretchr/testify/require" ) func TestAzureOIDCAccount(t *testing.T) { diff --git a/pkg/accounts/azure_service_principal_account.go b/pkg/accounts/azure_service_principal_account.go index c770d502..e17c7075 100644 --- a/pkg/accounts/azure_service_principal_account.go +++ b/pkg/accounts/azure_service_principal_account.go @@ -1,13 +1,15 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" - uuid "github.com/google/uuid" ) // AzureServicePrincipalAccount represents an Azure service principal account. diff --git a/pkg/accounts/azure_service_principal_account_test.go b/pkg/accounts/azure_service_principal_account_test.go index 80d5e870..2f5e50ed 100644 --- a/pkg/accounts/azure_service_principal_account_test.go +++ b/pkg/accounts/azure_service_principal_account_test.go @@ -3,10 +3,12 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - uuid "github.com/google/uuid" - "github.com/stretchr/testify/require" ) func TestAzureServicePrincipalAccount(t *testing.T) { diff --git a/pkg/accounts/azure_subscription_account.go b/pkg/accounts/azure_subscription_account.go index c30bf654..c069d256 100644 --- a/pkg/accounts/azure_subscription_account.go +++ b/pkg/accounts/azure_subscription_account.go @@ -1,12 +1,14 @@ package accounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + uuid "github.com/google/uuid" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) // AzureSubscriptionAccount represents an Azure subscription account. diff --git a/pkg/accounts/azure_subscription_account_test.go b/pkg/accounts/azure_subscription_account_test.go index 726f90cf..7543de5e 100644 --- a/pkg/accounts/azure_subscription_account_test.go +++ b/pkg/accounts/azure_subscription_account_test.go @@ -3,9 +3,11 @@ package accounts import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - uuid "github.com/google/uuid" "github.com/stretchr/testify/require" + + uuid "github.com/google/uuid" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestAzureSubscriptionAccountNew(t *testing.T) { diff --git a/pkg/accounts/generic_oidc_account.go b/pkg/accounts/generic_oidc_account.go index 74bb1835..84f3d908 100644 --- a/pkg/accounts/generic_oidc_account.go +++ b/pkg/accounts/generic_oidc_account.go @@ -1,10 +1,11 @@ package accounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) // GenericOIDCAccount represents a Generic OIDC account. diff --git a/pkg/accounts/generic_oidc_account_test.go b/pkg/accounts/generic_oidc_account_test.go index e7c4ef9b..f5fd3bd4 100644 --- a/pkg/accounts/generic_oidc_account_test.go +++ b/pkg/accounts/generic_oidc_account_test.go @@ -1,9 +1,11 @@ package accounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestGenericOIDCAccount(t *testing.T) { diff --git a/pkg/accounts/google_cloud_platform_account.go b/pkg/accounts/google_cloud_platform_account.go index 9668f881..822a077b 100644 --- a/pkg/accounts/google_cloud_platform_account.go +++ b/pkg/accounts/google_cloud_platform_account.go @@ -1,12 +1,13 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // GoogleCloudPlatformAccount represents a Google cloud account. diff --git a/pkg/accounts/queries_test.go b/pkg/accounts/queries_test.go index cf1fd918..0bb96ef7 100644 --- a/pkg/accounts/queries_test.go +++ b/pkg/accounts/queries_test.go @@ -4,8 +4,9 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) type TestQuery struct { diff --git a/pkg/accounts/ssh_key_account.go b/pkg/accounts/ssh_key_account.go index d9ac871b..129f5dea 100644 --- a/pkg/accounts/ssh_key_account.go +++ b/pkg/accounts/ssh_key_account.go @@ -1,12 +1,13 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // ISSHKeyAccount defines the interface for SSH key accounts. diff --git a/pkg/accounts/ssh_key_account_test.go b/pkg/accounts/ssh_key_account_test.go index 9d462142..15ed584e 100644 --- a/pkg/accounts/ssh_key_account_test.go +++ b/pkg/accounts/ssh_key_account_test.go @@ -3,9 +3,10 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestSSHKeyAccountNew(t *testing.T) { diff --git a/pkg/accounts/token_account.go b/pkg/accounts/token_account.go index df478d32..8483a512 100644 --- a/pkg/accounts/token_account.go +++ b/pkg/accounts/token_account.go @@ -1,11 +1,12 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // TokenAccount represents a token account. diff --git a/pkg/accounts/token_account_test.go b/pkg/accounts/token_account_test.go index de2ba837..dcf35a7c 100644 --- a/pkg/accounts/token_account_test.go +++ b/pkg/accounts/token_account_test.go @@ -3,9 +3,10 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestTokenAccountNew(t *testing.T) { diff --git a/pkg/accounts/username_password_account.go b/pkg/accounts/username_password_account.go index 89de15f6..a482d485 100644 --- a/pkg/accounts/username_password_account.go +++ b/pkg/accounts/username_password_account.go @@ -1,12 +1,13 @@ package accounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // IUsernamePasswordAccount defines the interface for username-password accounts. diff --git a/pkg/accounts/username_password_account_test.go b/pkg/accounts/username_password_account_test.go index 2405dc39..6ec0cc44 100644 --- a/pkg/accounts/username_password_account_test.go +++ b/pkg/accounts/username_password_account_test.go @@ -4,9 +4,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestUsernamePasswordAccountNew(t *testing.T) { diff --git a/pkg/actions/community_action_template.go b/pkg/actions/community_action_template.go index 48e77dcc..068dee22 100644 --- a/pkg/actions/community_action_template.go +++ b/pkg/actions/community_action_template.go @@ -1,13 +1,15 @@ package actions import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + + uuid "github.com/google/uuid" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" - uuid "github.com/google/uuid" ) // CommunityActionTemplate represents a community action template in Octopus diff --git a/pkg/actions/community_action_template_service.go b/pkg/actions/community_action_template_service.go index 1e23b452..67e6b8f8 100644 --- a/pkg/actions/community_action_template_service.go +++ b/pkg/actions/community_action_template_service.go @@ -3,13 +3,14 @@ package actions import ( "strings" + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) // CommunityActionTemplateService handles communication with Account-related methods of the Octopus API. diff --git a/pkg/actions/community_action_template_service_test.go b/pkg/actions/community_action_template_service_test.go index 2b4c1c08..58f3e6b2 100644 --- a/pkg/actions/community_action_template_service_test.go +++ b/pkg/actions/community_action_template_service_test.go @@ -3,12 +3,13 @@ package actions import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createCommunityActionTemplateService(t *testing.T) *CommunityActionTemplateService { diff --git a/pkg/actiontemplates/action_template.go b/pkg/actiontemplates/action_template.go index 44b6b621..8ea9f331 100644 --- a/pkg/actiontemplates/action_template.go +++ b/pkg/actiontemplates/action_template.go @@ -1,12 +1,13 @@ package actiontemplates import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // ActionTemplate represents an action template in Octopus Deploy. diff --git a/pkg/actiontemplates/action_template_service.go b/pkg/actiontemplates/action_template_service.go index 95bb905f..7b187978 100644 --- a/pkg/actiontemplates/action_template_service.go +++ b/pkg/actiontemplates/action_template_service.go @@ -3,6 +3,9 @@ package actiontemplates import ( "strings" + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -10,8 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) // ActionTemplateService handles communication for any operations in the @@ -182,8 +183,10 @@ func (s *ActionTemplateService) Update(actionTemplate *ActionTemplate) (*ActionT // --- new --- -const template = "/api/{spaceId}/actiontemplates{/id}{?skip,take,ids,partialName}" -const templateVersions = "/api/{spaceId}/actiontemplates/{id}/versions/{version}" +const ( + template = "/api/{spaceId}/actiontemplates{/id}{?skip,take,ids,partialName}" + templateVersions = "/api/{spaceId}/actiontemplates/{id}/versions/{version}" +) // Add creates a new action template. func Add(client newclient.Client, actionTemplate *ActionTemplate) (*ActionTemplate, error) { diff --git a/pkg/actiontemplates/action_template_service_test.go b/pkg/actiontemplates/action_template_service_test.go index 80e85847..ffb611ea 100644 --- a/pkg/actiontemplates/action_template_service_test.go +++ b/pkg/actiontemplates/action_template_service_test.go @@ -3,14 +3,15 @@ package actiontemplates import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createActionTemplate(t *testing.T) *ActionTemplate { diff --git a/pkg/actiontemplates/query_test.go b/pkg/actiontemplates/query_test.go index 702a97fe..4598abda 100644 --- a/pkg/actiontemplates/query_test.go +++ b/pkg/actiontemplates/query_test.go @@ -3,8 +3,9 @@ package actiontemplates import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) func expandCollectionTemplate(t *testing.T, query any) string { diff --git a/pkg/approvalrules/approval_rules_service_test.go b/pkg/approvalrules/approval_rules_service_test.go index b3559d1e..3c888c4d 100644 --- a/pkg/approvalrules/approval_rules_service_test.go +++ b/pkg/approvalrules/approval_rules_service_test.go @@ -3,8 +3,9 @@ package approvalrules import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) func createClient() newclient.Client { diff --git a/pkg/approvals/approvals_service.go b/pkg/approvals/approvals_service.go index 02e369c1..d24b7939 100644 --- a/pkg/approvals/approvals_service.go +++ b/pkg/approvals/approvals_service.go @@ -6,9 +6,11 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) -const serverTaskApprovalsTemplate = "/api/{spaceId}/servertaskapprovals{/id}{?skip,take,providerId,state}" -const serverTaskApprovalByTaskTemplate = "/api/{spaceId}/tasks/{taskId}/servertaskapproval" -const approvalsTemplate = "/api/{spaceId}/servertaskapprovals/{serverTaskApprovalId}/approvals{/id}" +const ( + serverTaskApprovalsTemplate = "/api/{spaceId}/servertaskapprovals{/id}{?skip,take,providerId,state}" + serverTaskApprovalByTaskTemplate = "/api/{spaceId}/tasks/{taskId}/servertaskapproval" + approvalsTemplate = "/api/{spaceId}/servertaskapprovals/{serverTaskApprovalId}/approvals{/id}" +) // ServerTaskApprovalsQuery is the query for the paginated server-task approvals list endpoint. type ServerTaskApprovalsQuery struct { diff --git a/pkg/approvals/approvals_service_test.go b/pkg/approvals/approvals_service_test.go index 5508a568..531a9a83 100644 --- a/pkg/approvals/approvals_service_test.go +++ b/pkg/approvals/approvals_service_test.go @@ -3,8 +3,9 @@ package approvals import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) func createClient() newclient.Client { diff --git a/pkg/artifacts/artifact_service.go b/pkg/artifacts/artifact_service.go index 9163c324..167c4718 100644 --- a/pkg/artifacts/artifact_service.go +++ b/pkg/artifacts/artifact_service.go @@ -1,13 +1,14 @@ package artifacts import ( + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) // ArtifactService handles communication for any operations in the diff --git a/pkg/authentication/authentication_service.go b/pkg/authentication/authentication_service.go index d857ae15..b0fae194 100644 --- a/pkg/authentication/authentication_service.go +++ b/pkg/authentication/authentication_service.go @@ -1,10 +1,11 @@ package authentication import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) // AuthenticationService handles communication with Authentication-related methods of the Octopus API. diff --git a/pkg/authentication/authentication_service_test.go b/pkg/authentication/authentication_service_test.go index 6114f7d9..ae18eea3 100644 --- a/pkg/authentication/authentication_service_test.go +++ b/pkg/authentication/authentication_service_test.go @@ -3,9 +3,10 @@ package authentication import ( "testing" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) func TestNewAuthenticationService(t *testing.T) { diff --git a/pkg/azure/azure_environment_service.go b/pkg/azure/azure_environment_service.go index 816fffb1..e143e195 100644 --- a/pkg/azure/azure_environment_service.go +++ b/pkg/azure/azure_environment_service.go @@ -1,9 +1,10 @@ package azure import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type AzureEnvironmentService struct { diff --git a/pkg/azure/azure_environment_service_test.go b/pkg/azure/azure_environment_service_test.go index 5e7bd13d..02141cb5 100644 --- a/pkg/azure/azure_environment_service_test.go +++ b/pkg/azure/azure_environment_service_test.go @@ -3,9 +3,10 @@ package azure import ( "testing" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) func TestNewAzureEnvironmentService(t *testing.T) { diff --git a/pkg/azure/devops/azure_devops_connectivity_check_service.go b/pkg/azure/devops/azure_devops_connectivity_check_service.go index fc936e02..238cf36e 100644 --- a/pkg/azure/devops/azure_devops_connectivity_check_service.go +++ b/pkg/azure/devops/azure_devops_connectivity_check_service.go @@ -1,9 +1,10 @@ package devops import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type AzureDevOpsConnectivityCheckService struct { diff --git a/pkg/buildinformation/build_information_service.go b/pkg/buildinformation/build_information_service.go index 5bf0275a..4d9370c5 100644 --- a/pkg/buildinformation/build_information_service.go +++ b/pkg/buildinformation/build_information_service.go @@ -1,12 +1,13 @@ package buildinformation import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type BuildInformationService struct { diff --git a/pkg/buildinformation/build_information_service_test.go b/pkg/buildinformation/build_information_service_test.go index 23577dda..82eb2fa1 100644 --- a/pkg/buildinformation/build_information_service_test.go +++ b/pkg/buildinformation/build_information_service_test.go @@ -3,9 +3,10 @@ package buildinformation import ( "testing" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) func TestNewBuildInformationService(t *testing.T) { diff --git a/pkg/certificates/certificate.go b/pkg/certificates/certificate.go index a53e2b7b..6291c1fa 100644 --- a/pkg/certificates/certificate.go +++ b/pkg/certificates/certificate.go @@ -1,9 +1,10 @@ package certificates import ( + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type CertificateResource struct { diff --git a/pkg/certificates/certificate_service.go b/pkg/certificates/certificate_service.go index 20c4a565..44302949 100644 --- a/pkg/certificates/certificate_service.go +++ b/pkg/certificates/certificate_service.go @@ -3,13 +3,14 @@ package certificates import ( "fmt" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) // certificateService handles communication with Certificate-related methods of the Octopus API. diff --git a/pkg/certificates/certificate_service_test.go b/pkg/certificates/certificate_service_test.go index 3ea0e483..7d5a0d3b 100644 --- a/pkg/certificates/certificate_service_test.go +++ b/pkg/certificates/certificate_service_test.go @@ -3,13 +3,14 @@ package certificates import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createCertificate(t *testing.T) (*CertificateResource, error) { diff --git a/pkg/channels/channel.go b/pkg/channels/channel.go index 5b84f80d..b89c7b77 100644 --- a/pkg/channels/channel.go +++ b/pkg/channels/channel.go @@ -3,10 +3,11 @@ package channels import ( "strings" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) type Channel struct { diff --git a/pkg/channels/channel_git_resource_rule_test.go b/pkg/channels/channel_git_resource_rule_test.go index cb298ec8..b1859553 100644 --- a/pkg/channels/channel_git_resource_rule_test.go +++ b/pkg/channels/channel_git_resource_rule_test.go @@ -3,8 +3,9 @@ package channels import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" ) func TestChannelValidateDivesIntoGitResourceRules(t *testing.T) { diff --git a/pkg/channels/channel_rule.go b/pkg/channels/channel_rule.go index 53c271ec..891893cc 100644 --- a/pkg/channels/channel_rule.go +++ b/pkg/channels/channel_rule.go @@ -10,8 +10,8 @@ type ChannelRule struct { ID string `json:"Id,omitempty"` Tag string `json:"Tag,omitempty"` - //Use the NuGet or Maven versioning syntax (depending on the feed type) - //to specify the range of versions to include + // Use the NuGet or Maven versioning syntax (depending on the feed type) + // to specify the range of versions to include VersionRange string `json:"VersionRange,omitempty"` // VersioningStrategy controls how packages are ordered to determine the latest version. diff --git a/pkg/channels/channel_service.go b/pkg/channels/channel_service.go index c211c908..f64426d1 100644 --- a/pkg/channels/channel_service.go +++ b/pkg/channels/channel_service.go @@ -1,13 +1,14 @@ package channels import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ChannelService struct { @@ -121,8 +122,10 @@ func (s *ChannelService) Update(channel *Channel) (*Channel, error) { // --- new --- -const template = "/api/{spaceId}/channels{/id}{?skip,take,ids,partialName}" -const templateV2 = "/api/{spaceId}/projects/{projectId}/channels{/id}{?skip,take,ids,partialName}" +const ( + template = "/api/{spaceId}/channels{/id}{?skip,take,ids,partialName}" + templateV2 = "/api/{spaceId}/projects/{projectId}/channels{/id}{?skip,take,ids,partialName}" +) // Add creates a new channel. func Add(client newclient.Client, channel *Channel) (*Channel, error) { diff --git a/pkg/channels/channel_service_test.go b/pkg/channels/channel_service_test.go index 9078e24c..e0266e5a 100644 --- a/pkg/channels/channel_service_test.go +++ b/pkg/channels/channel_service_test.go @@ -3,12 +3,13 @@ package channels import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createChannelService(t *testing.T) *ChannelService { diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 485f6c0a..111d3607 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -7,12 +7,13 @@ import ( "os" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" ) func TestNewClient(t *testing.T) { diff --git a/pkg/client/octopusdeploy.go b/pkg/client/octopusdeploy.go index ddb4e23a..629c7275 100644 --- a/pkg/client/octopusdeploy.go +++ b/pkg/client/octopusdeploy.go @@ -7,6 +7,8 @@ import ( "regexp" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" @@ -69,7 +71,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workertoolslatestimages" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) // Client is an OctopusDeploy for making Octopus API requests. @@ -169,7 +170,7 @@ func IsAPIKey(apiKey string) bool { return false } - var expression = regexp.MustCompile(`^(API-)([A-Z\d])+$`) + expression := regexp.MustCompile(`^(API-)([A-Z\d])+$`) return expression.MatchString(apiKey) } @@ -237,7 +238,6 @@ func NewClientWithCredentials(httpClient *http.Client, apiURL *url.URL, apiCrede if !internal.IsEmpty(spaceID) { spaceUrl, _ := url.JoinPath(baseURLWithAPI, spaceID) base, sroot, err = getRoot(httpClient, spaceUrl, apiCredentials, requestingTool) - if err != nil { if err == services.ErrItemNotFound { return nil, fmt.Errorf("the space ID (%s) cannot be found", spaceID) diff --git a/pkg/client/root_resource.go b/pkg/client/root_resource.go index d3544e5b..c0e19314 100644 --- a/pkg/client/root_resource.go +++ b/pkg/client/root_resource.go @@ -1,10 +1,12 @@ package client import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + uuid "github.com/google/uuid" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type RootResource struct { diff --git a/pkg/client/root_service.go b/pkg/client/root_service.go index 0cd2c687..14fdc424 100644 --- a/pkg/client/root_service.go +++ b/pkg/client/root_service.go @@ -1,11 +1,12 @@ package client import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type RootService struct { @@ -45,7 +46,6 @@ func GetSpaceRoot(client newclient.Client, spaceID *string) (*RootResource, erro values["spaceId"] = *spaceID } path, err := client.URITemplateCache().Expand(template, values) - if err != nil { return nil, err } diff --git a/pkg/client/root_service_test.go b/pkg/client/root_service_test.go index abc5625f..77d98a60 100644 --- a/pkg/client/root_service_test.go +++ b/pkg/client/root_service_test.go @@ -3,10 +3,11 @@ package client import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createRootService(t *testing.T) *RootService { diff --git a/pkg/cloudtemplate/cloud_template_service.go b/pkg/cloudtemplate/cloud_template_service.go index d23c71e3..b8d4a91f 100644 --- a/pkg/cloudtemplate/cloud_template_service.go +++ b/pkg/cloudtemplate/cloud_template_service.go @@ -1,9 +1,10 @@ package cloudtemplate import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type CloudTemplateService struct { diff --git a/pkg/configuration/certificate_configuration_service.go b/pkg/configuration/certificate_configuration_service.go index a087d71a..af521847 100644 --- a/pkg/configuration/certificate_configuration_service.go +++ b/pkg/configuration/certificate_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type CertificateConfigurationService struct { diff --git a/pkg/configuration/configuration_service.go b/pkg/configuration/configuration_service.go index 620504a4..2c838cb1 100644 --- a/pkg/configuration/configuration_service.go +++ b/pkg/configuration/configuration_service.go @@ -1,11 +1,12 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ConfigurationService struct { diff --git a/pkg/configuration/configuration_service_test.go b/pkg/configuration/configuration_service_test.go index deed0c89..15996bec 100644 --- a/pkg/configuration/configuration_service_test.go +++ b/pkg/configuration/configuration_service_test.go @@ -3,11 +3,12 @@ package configuration import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func TestNewConfigurationService(t *testing.T) { diff --git a/pkg/configuration/features_configuration.go b/pkg/configuration/features_configuration.go index 3cf7cca4..8e843369 100644 --- a/pkg/configuration/features_configuration.go +++ b/pkg/configuration/features_configuration.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type FeaturesConfigurationService struct { diff --git a/pkg/configuration/lets_encrypt_configuration_service.go b/pkg/configuration/lets_encrypt_configuration_service.go index e6c53cb8..e25d1a0f 100644 --- a/pkg/configuration/lets_encrypt_configuration_service.go +++ b/pkg/configuration/lets_encrypt_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type LetsEncryptConfigurationService struct { diff --git a/pkg/configuration/maintenance_configuration_service.go b/pkg/configuration/maintenance_configuration_service.go index b6d3c0ca..301a13e9 100644 --- a/pkg/configuration/maintenance_configuration_service.go +++ b/pkg/configuration/maintenance_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type MaintenanceConfigurationService struct { diff --git a/pkg/configuration/performance_configuration_service.go b/pkg/configuration/performance_configuration_service.go index 40ddf486..eb9c0f70 100644 --- a/pkg/configuration/performance_configuration_service.go +++ b/pkg/configuration/performance_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type PerformanceConfigurationService struct { diff --git a/pkg/configuration/server_configuration_service.go b/pkg/configuration/server_configuration_service.go index dc18dfc5..551ab24d 100644 --- a/pkg/configuration/server_configuration_service.go +++ b/pkg/configuration/server_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type ServerConfigurationService struct { diff --git a/pkg/configuration/smtp_configuration_service.go b/pkg/configuration/smtp_configuration_service.go index ee0f07d9..9026329e 100644 --- a/pkg/configuration/smtp_configuration_service.go +++ b/pkg/configuration/smtp_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type SmtpConfigurationService struct { diff --git a/pkg/configuration/upgrade_configuration_service.go b/pkg/configuration/upgrade_configuration_service.go index 11f6d2cb..1f1cc27b 100644 --- a/pkg/configuration/upgrade_configuration_service.go +++ b/pkg/configuration/upgrade_configuration_service.go @@ -1,9 +1,10 @@ package configuration import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type UpgradeConfigurationService struct { diff --git a/pkg/core/sensitive_value_test.go b/pkg/core/sensitive_value_test.go index e7a9c1a0..38874504 100644 --- a/pkg/core/sensitive_value_test.go +++ b/pkg/core/sensitive_value_test.go @@ -4,8 +4,9 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/stretchr/testify/assert" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func ValidateRequiredSensitiveValue(propertyName string, sensitiveValue *SensitiveValue) error { diff --git a/pkg/credentials/anonymous_test.go b/pkg/credentials/anonymous_test.go index 5d918366..9696850a 100644 --- a/pkg/credentials/anonymous_test.go +++ b/pkg/credentials/anonymous_test.go @@ -5,9 +5,10 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" ) func TestAnonymousMarshalJSON(t *testing.T) { diff --git a/pkg/credentials/reference_test.go b/pkg/credentials/reference_test.go index 1f71d02c..2ecf52ae 100644 --- a/pkg/credentials/reference_test.go +++ b/pkg/credentials/reference_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" ) func TestReferenceMarshalJSON(t *testing.T) { diff --git a/pkg/credentials/resource.go b/pkg/credentials/resource.go index 9d154164..14eef6f3 100644 --- a/pkg/credentials/resource.go +++ b/pkg/credentials/resource.go @@ -2,6 +2,7 @@ package credentials import ( "encoding/json" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) diff --git a/pkg/credentials/resource_test.go b/pkg/credentials/resource_test.go index a0af4ebf..0f443f3b 100644 --- a/pkg/credentials/resource_test.go +++ b/pkg/credentials/resource_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestResourceWithUsernamePasswordAsJSON(t *testing.T) { diff --git a/pkg/credentials/service.go b/pkg/credentials/service.go index f0235970..e38761f6 100644 --- a/pkg/credentials/service.go +++ b/pkg/credentials/service.go @@ -3,6 +3,8 @@ package credentials import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -10,7 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type Service struct { diff --git a/pkg/credentials/service_test.go b/pkg/credentials/service_test.go index 7d2e075a..fd68a4a5 100644 --- a/pkg/credentials/service_test.go +++ b/pkg/credentials/service_test.go @@ -3,12 +3,13 @@ package credentials_test import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createService(t *testing.T) *credentials.Service { diff --git a/pkg/dashboard/dashboard_configuration_service.go b/pkg/dashboard/dashboard_configuration_service.go index 519536c2..44ddf844 100644 --- a/pkg/dashboard/dashboard_configuration_service.go +++ b/pkg/dashboard/dashboard_configuration_service.go @@ -1,9 +1,10 @@ package dashboard import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type DashboardConfigurationService struct { diff --git a/pkg/dashboard/dashboard_service.go b/pkg/dashboard/dashboard_service.go index 1db7e059..8fa94a4e 100644 --- a/pkg/dashboard/dashboard_service.go +++ b/pkg/dashboard/dashboard_service.go @@ -1,12 +1,13 @@ package dashboard import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type DashboardService struct { diff --git a/pkg/dashboard/dashboard_service_httptest_test.go b/pkg/dashboard/dashboard_service_httptest_test.go index e424361b..cf4268be 100644 --- a/pkg/dashboard/dashboard_service_httptest_test.go +++ b/pkg/dashboard/dashboard_service_httptest_test.go @@ -6,10 +6,11 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" ) // The path tests expand the template without calling the method; this covers diff --git a/pkg/dashboard/dashboard_service_test.go b/pkg/dashboard/dashboard_service_test.go index 08c21066..21f8e50d 100644 --- a/pkg/dashboard/dashboard_service_test.go +++ b/pkg/dashboard/dashboard_service_test.go @@ -5,12 +5,13 @@ import ( "net/url" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/interruptions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createDashboardService(t *testing.T) *DashboardService { diff --git a/pkg/defects/defect_test.go b/pkg/defects/defect_test.go index 0da9deb4..4d7b8ee8 100644 --- a/pkg/defects/defect_test.go +++ b/pkg/defects/defect_test.go @@ -5,9 +5,10 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestDefectAsJSON(t *testing.T) { @@ -54,5 +55,4 @@ func TestDefectWithStatusAsJSON(t *testing.T) { require.NotNil(t, actualJSON) jsonassert.New(t).Assertf(expectedJSON, "%s", string(actualJSON)) - } diff --git a/pkg/deploymentfreezes/deploymentfreeze_service_test.go b/pkg/deploymentfreezes/deploymentfreeze_service_test.go index ee88694b..59832ced 100644 --- a/pkg/deploymentfreezes/deploymentfreeze_service_test.go +++ b/pkg/deploymentfreezes/deploymentfreeze_service_test.go @@ -1,9 +1,11 @@ package deploymentfreezes import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) func createClient() newclient.Client { diff --git a/pkg/deploymentfreezes/deploymentfreezes_service.go b/pkg/deploymentfreezes/deploymentfreezes_service.go index c6832156..ef2a0710 100644 --- a/pkg/deploymentfreezes/deploymentfreezes_service.go +++ b/pkg/deploymentfreezes/deploymentfreezes_service.go @@ -9,8 +9,7 @@ import ( const template = "/api/deploymentfreezes{/id}{?skip,take,ids,partialName,projectIds,tenantIds,environmentIds,includeComplete,status}" -type DeploymentFreezeService struct { -} +type DeploymentFreezeService struct{} func Get(client newclient.Client, deploymentFreezesQuery DeploymentFreezeQuery) (*DeploymentFreezes, error) { path, err := client.URITemplateCache().Expand(template, deploymentFreezesQuery) @@ -40,7 +39,6 @@ func GetById(client newclient.Client, id string) (*DeploymentFreeze, error) { } return res, nil - } func GetAll(client newclient.Client) (*DeploymentFreezes, error) { diff --git a/pkg/deployments/channel_rule.go b/pkg/deployments/channel_rule.go index d707bbcb..a86525bd 100644 --- a/pkg/deployments/channel_rule.go +++ b/pkg/deployments/channel_rule.go @@ -10,8 +10,8 @@ type ChannelRule struct { ID string `json:"Id,omitempty"` Tag string `json:"Tag,omitempty"` - //Use the NuGet or Maven versioning syntax (depending on the feed type) - //to specify the range of versions to include + // Use the NuGet or Maven versioning syntax (depending on the feed type) + // to specify the range of versions to include VersionRange string `json:"VersionRange,omitempty"` resources.Resource diff --git a/pkg/deployments/deploy_release_v1.go b/pkg/deployments/deploy_release_v1.go index 36fd9e8e..12251836 100644 --- a/pkg/deployments/deploy_release_v1.go +++ b/pkg/deployments/deploy_release_v1.go @@ -2,6 +2,7 @@ package deployments import ( "encoding/json" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" diff --git a/pkg/deployments/deployment.go b/pkg/deployments/deployment.go index 54e62fa6..f6d96800 100644 --- a/pkg/deployments/deployment.go +++ b/pkg/deployments/deployment.go @@ -3,10 +3,11 @@ package deployments import ( "time" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Deployment struct { diff --git a/pkg/deployments/deployment_action.go b/pkg/deployments/deployment_action.go index ed7a484f..645e7ba3 100644 --- a/pkg/deployments/deployment_action.go +++ b/pkg/deployments/deployment_action.go @@ -1,12 +1,13 @@ package deployments import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) type DeploymentAction struct { diff --git a/pkg/deployments/deployment_process_service.go b/pkg/deployments/deployment_process_service.go index fab60f6d..225ae21a 100644 --- a/pkg/deployments/deployment_process_service.go +++ b/pkg/deployments/deployment_process_service.go @@ -1,6 +1,8 @@ package deployments import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -8,7 +10,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type DeploymentProcessService struct { diff --git a/pkg/deployments/deployment_process_service_test.go b/pkg/deployments/deployment_process_service_test.go index ccf29879..8f4d1b2c 100644 --- a/pkg/deployments/deployment_process_service_test.go +++ b/pkg/deployments/deployment_process_service_test.go @@ -1,14 +1,15 @@ package deployments_test import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createDeploymentProcessService(t *testing.T) *deployments.DeploymentProcessService { diff --git a/pkg/deployments/deployment_process_test.go b/pkg/deployments/deployment_process_test.go index 3c78122d..442abaf3 100644 --- a/pkg/deployments/deployment_process_test.go +++ b/pkg/deployments/deployment_process_test.go @@ -7,10 +7,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" ) func TestDeploymentProcessAsJSON(t *testing.T) { diff --git a/pkg/deployments/deployment_service.go b/pkg/deployments/deployment_service.go index 3080ac1c..53d2b743 100644 --- a/pkg/deployments/deployment_service.go +++ b/pkg/deployments/deployment_service.go @@ -1,6 +1,8 @@ package deployments import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -10,7 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) // DeploymentService handles communication for any operations in the Octopus diff --git a/pkg/deployments/deployment_service_test.go b/pkg/deployments/deployment_service_test.go index 096ba40c..3d4e8ad0 100644 --- a/pkg/deployments/deployment_service_test.go +++ b/pkg/deployments/deployment_service_test.go @@ -4,11 +4,12 @@ import ( "encoding/json" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestDeploymentServiceGetByIDs(t *testing.T) { diff --git a/pkg/deployments/deployment_step.go b/pkg/deployments/deployment_step.go index d3426d8a..3a9a769a 100644 --- a/pkg/deployments/deployment_step.go +++ b/pkg/deployments/deployment_step.go @@ -1,9 +1,10 @@ package deployments import ( + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type DeploymentStep struct { diff --git a/pkg/environments/environment.go b/pkg/environments/environment.go index 94202b55..bfe7e8fd 100644 --- a/pkg/environments/environment.go +++ b/pkg/environments/environment.go @@ -3,9 +3,10 @@ package environments import ( "encoding/json" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Environment struct { diff --git a/pkg/environments/environment_service.go b/pkg/environments/environment_service.go index 69128bc5..655b6804 100644 --- a/pkg/environments/environment_service.go +++ b/pkg/environments/environment_service.go @@ -1,13 +1,14 @@ package environments import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type EnvironmentService struct { diff --git a/pkg/environments/environment_service_test.go b/pkg/environments/environment_service_test.go index 7a90a812..752a0986 100644 --- a/pkg/environments/environment_service_test.go +++ b/pkg/environments/environment_service_test.go @@ -3,12 +3,13 @@ package environments import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createEnvironmentService(t *testing.T) *EnvironmentService { diff --git a/pkg/environments/environment_test.go b/pkg/environments/environment_test.go index e61c7b02..0b417258 100644 --- a/pkg/environments/environment_test.go +++ b/pkg/environments/environment_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestEnvironmentExtensionSettingsAsJSON(t *testing.T) { diff --git a/pkg/environments/jira_service_management_extension_settings.go b/pkg/environments/jira_service_management_extension_settings.go index 338d384c..3fc9cb33 100644 --- a/pkg/environments/jira_service_management_extension_settings.go +++ b/pkg/environments/jira_service_management_extension_settings.go @@ -72,5 +72,7 @@ func (j *JiraServiceManagementExtensionSettings) UnmarshalJSON(b []byte) error { return nil } -var _ extensions.ExtensionSettings = &JiraServiceManagementExtensionSettings{} -var _ extensions.ChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} +var ( + _ extensions.ExtensionSettings = &JiraServiceManagementExtensionSettings{} + _ extensions.ChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} +) diff --git a/pkg/environments/servicenow_extension_settings.go b/pkg/environments/servicenow_extension_settings.go index 866147a8..65a826c4 100644 --- a/pkg/environments/servicenow_extension_settings.go +++ b/pkg/environments/servicenow_extension_settings.go @@ -72,5 +72,7 @@ func (s *ServiceNowExtensionSettings) UnmarshalJSON(b []byte) error { return nil } -var _ extensions.ExtensionSettings = &ServiceNowExtensionSettings{} -var _ extensions.ChangeControlExtensionSettings = &ServiceNowExtensionSettings{} +var ( + _ extensions.ExtensionSettings = &ServiceNowExtensionSettings{} + _ extensions.ChangeControlExtensionSettings = &ServiceNowExtensionSettings{} +) diff --git a/pkg/environments/v2/ephemeralenvironments/ephemeral_environment_service.go b/pkg/environments/v2/ephemeralenvironments/ephemeral_environment_service.go index fbfca4a5..d68c2754 100644 --- a/pkg/environments/v2/ephemeralenvironments/ephemeral_environment_service.go +++ b/pkg/environments/v2/ephemeralenvironments/ephemeral_environment_service.go @@ -61,7 +61,6 @@ func Add(client newclient.Client, spaceID string, projectID string, environmentN "projectId": projectID, "spaceId": spaceID, }) - if err != nil { return nil, err } @@ -77,7 +76,6 @@ func DeprovisionForProject(client newclient.Client, spaceID string, environmentI "projectId": projectId, "spaceId": spaceID, }) - if err != nil { return nil, err } @@ -92,7 +90,6 @@ func Deprovision(client newclient.Client, spaceID string, environmentId string) "id": environmentId, "spaceId": spaceID, }) - if err != nil { return nil, err } diff --git a/pkg/environments/v2/route.go b/pkg/environments/v2/route.go index 8ea6ada2..91b95b12 100644 --- a/pkg/environments/v2/route.go +++ b/pkg/environments/v2/route.go @@ -1,6 +1,8 @@ package v2 -const Template = "/api/{spaceId}/environments/v2{?name,skip,ids,take,partialName,type}" -const CreateEphemeralEnvironmentTemplate = "/api/{spaceId}/projects/{projectId}/environments/ephemeral" -const DeprovisionEphemeralEnvironmentForProjectTemplate = "/api/{spaceId}/projects/{projectId}/environments/ephemeral/{id}/deprovision" -const DeprovisionEphemeralEnvironmentTemplate = "/api/{spaceId}/environments/ephemeral/{id}/deprovision" +const ( + Template = "/api/{spaceId}/environments/v2{?name,skip,ids,take,partialName,type}" + CreateEphemeralEnvironmentTemplate = "/api/{spaceId}/projects/{projectId}/environments/ephemeral" + DeprovisionEphemeralEnvironmentForProjectTemplate = "/api/{spaceId}/projects/{projectId}/environments/ephemeral/{id}/deprovision" + DeprovisionEphemeralEnvironmentTemplate = "/api/{spaceId}/environments/ephemeral/{id}/deprovision" +) diff --git a/pkg/events/event_service.go b/pkg/events/event_service.go index 17fb168a..3c8bb307 100644 --- a/pkg/events/event_service.go +++ b/pkg/events/event_service.go @@ -3,12 +3,13 @@ package events import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) // EventService handles communication with event-related methods of the diff --git a/pkg/extensions/dynamic_extension_service.go b/pkg/extensions/dynamic_extension_service.go index be852827..3b010a60 100644 --- a/pkg/extensions/dynamic_extension_service.go +++ b/pkg/extensions/dynamic_extension_service.go @@ -1,9 +1,10 @@ package extensions import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type DynamicExtensionService struct { diff --git a/pkg/extensions/extension_settings_test.go b/pkg/extensions/extension_settings_test.go index b1709aab..9c5bab3d 100644 --- a/pkg/extensions/extension_settings_test.go +++ b/pkg/extensions/extension_settings_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestExtensionSettingsMarshalJSON(t *testing.T) { diff --git a/pkg/externalsecuritygroupproviders/external_security_group_provider_service.go b/pkg/externalsecuritygroupproviders/external_security_group_provider_service.go index 77ab34fc..75381502 100644 --- a/pkg/externalsecuritygroupproviders/external_security_group_provider_service.go +++ b/pkg/externalsecuritygroupproviders/external_security_group_provider_service.go @@ -1,9 +1,10 @@ package externalsecuritygroupproviders import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type ExternalSecurityGroupProviderService struct { diff --git a/pkg/feeds/artifactory_generic.go b/pkg/feeds/artifactory_generic.go index b0fe95eb..0bd59adb 100644 --- a/pkg/feeds/artifactory_generic.go +++ b/pkg/feeds/artifactory_generic.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) type ArtifactoryGenericFeed struct { diff --git a/pkg/feeds/aws_elastic_container_registry.go b/pkg/feeds/aws_elastic_container_registry.go index c4f0395a..691f31ba 100644 --- a/pkg/feeds/aws_elastic_container_registry.go +++ b/pkg/feeds/aws_elastic_container_registry.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // AwsElasticContainerRegistry represents an Amazon Web Services (AWS) Elastic diff --git a/pkg/feeds/azure_container_registry.go b/pkg/feeds/azure_container_registry.go index 07185927..6b445ea7 100644 --- a/pkg/feeds/azure_container_registry.go +++ b/pkg/feeds/azure_container_registry.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // AzureContainerRegistry represents an Azure Container Registry (ACR). @@ -33,7 +34,6 @@ func NewAzureContainerRegistry(name string, username string, password *core.Sens } dockerContainerRegistry, err := NewDockerContainerRegistryWithFeedType(name, FeedTypeAzureContainerRegistry) - if err != nil { return nil, err } diff --git a/pkg/feeds/built_in_feed.go b/pkg/feeds/built_in_feed.go index 43a71c32..f21a1bd6 100644 --- a/pkg/feeds/built_in_feed.go +++ b/pkg/feeds/built_in_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // BuiltInFeed represents a built-in feed. diff --git a/pkg/feeds/docker_container_registry.go b/pkg/feeds/docker_container_registry.go index 8eeca0da..6ed39012 100644 --- a/pkg/feeds/docker_container_registry.go +++ b/pkg/feeds/docker_container_registry.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // DockerContainerRegistry represents a Docker container registry. diff --git a/pkg/feeds/feed.go b/pkg/feeds/feed.go index 8a884c42..70290c80 100644 --- a/pkg/feeds/feed.go +++ b/pkg/feeds/feed.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type IFeed interface { diff --git a/pkg/feeds/feed_resource.go b/pkg/feeds/feed_resource.go index 4c2a6a78..42e383f6 100644 --- a/pkg/feeds/feed_resource.go +++ b/pkg/feeds/feed_resource.go @@ -1,38 +1,39 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type FeedResource struct { - AccessKey string `json:"AccessKey,omitempty"` - OidcAuthentication *OidcAuthentication `json:"OidcAuthentication,omitempty"` - APIVersion string `json:"ApiVersion,omitempty"` - DeletePackagesAssociatedWithReleases bool `json:"DeletePackagesAssociatedWithReleases"` - DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"` - DownloadAttempts int `json:"DownloadAttempts"` - DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"` - EnhancedMode bool `json:"EnhancedMode"` - FeedType FeedType `json:"FeedType" validate:"required,notblank"` - FeedURI string `json:"FeedUri,omitempty"` - IsBuiltInRepoSyncEnabled bool `json:"IsBuiltInRepoSyncEnabled"` - Name string `json:"Name" validate:"required,notblank"` - Password *core.SensitiveValue `json:"Password,omitempty"` - PackageAcquisitionLocationOptions []string `json:"PackageAcquisitionLocationOptions,omitempty"` - Region string `json:"Region,omitempty"` - RegistryPath string `json:"RegistryPath,omitempty"` - SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"` - SpaceID string `json:"SpaceId,omitempty"` - Username string `json:"Username,omitempty"` - LayoutRegex string `json:"LayoutRegex,omitempty"` - Repository string `json:"Repository,omitempty"` - UseMachineCredentials bool `json:"UseMachineCredentials,omitempty"` - UseServiceAccountKey bool `json:"UseServiceAccountKey,omitempty"` - ServiceAccountJsonKey *core.SensitiveValue `json:"ServiceAccountJsonKey,omitempty"` - Project string `json:"Project,omitempty"` + AccessKey string `json:"AccessKey,omitempty"` + OidcAuthentication *OidcAuthentication `json:"OidcAuthentication,omitempty"` + APIVersion string `json:"ApiVersion,omitempty"` + DeletePackagesAssociatedWithReleases bool `json:"DeletePackagesAssociatedWithReleases"` + DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"` + DownloadAttempts int `json:"DownloadAttempts"` + DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"` + EnhancedMode bool `json:"EnhancedMode"` + FeedType FeedType `json:"FeedType" validate:"required,notblank"` + FeedURI string `json:"FeedUri,omitempty"` + IsBuiltInRepoSyncEnabled bool `json:"IsBuiltInRepoSyncEnabled"` + Name string `json:"Name" validate:"required,notblank"` + Password *core.SensitiveValue `json:"Password,omitempty"` + PackageAcquisitionLocationOptions []string `json:"PackageAcquisitionLocationOptions,omitempty"` + Region string `json:"Region,omitempty"` + RegistryPath string `json:"RegistryPath,omitempty"` + SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"` + SpaceID string `json:"SpaceId,omitempty"` + Username string `json:"Username,omitempty"` + LayoutRegex string `json:"LayoutRegex,omitempty"` + Repository string `json:"Repository,omitempty"` + UseMachineCredentials bool `json:"UseMachineCredentials,omitempty"` + UseServiceAccountKey bool `json:"UseServiceAccountKey,omitempty"` + ServiceAccountJsonKey *core.SensitiveValue `json:"ServiceAccountJsonKey,omitempty"` + Project string `json:"Project,omitempty"` resources.Resource } diff --git a/pkg/feeds/feed_service.go b/pkg/feeds/feed_service.go index b0df5707..faa1a987 100644 --- a/pkg/feeds/feed_service.go +++ b/pkg/feeds/feed_service.go @@ -1,6 +1,9 @@ package feeds import ( + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -9,8 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) // FeedService handles communication with feed-related methods of the Octopus diff --git a/pkg/feeds/feed_service_test.go b/pkg/feeds/feed_service_test.go index 84460391..06d75af9 100644 --- a/pkg/feeds/feed_service_test.go +++ b/pkg/feeds/feed_service_test.go @@ -3,12 +3,13 @@ package feeds import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createFeedService(t *testing.T) *FeedService { diff --git a/pkg/feeds/feed_utilities_test.go b/pkg/feeds/feed_utilities_test.go index dd993195..1c9f58f9 100644 --- a/pkg/feeds/feed_utilities_test.go +++ b/pkg/feeds/feed_utilities_test.go @@ -71,7 +71,6 @@ func TestECR(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -93,7 +92,6 @@ func TestECR(t *testing.T) { if *typedFeed.SecretKey.NewValue != secretKey { t.Fatalf("SecretKey does not match") } - } func TestBuiltIn(t *testing.T) { @@ -122,7 +120,6 @@ func TestBuiltIn(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -148,7 +145,6 @@ func TestBuiltIn(t *testing.T) { if !typedFeed.IsBuiltInRepoSyncEnabled { t.Fatalf("IsBuiltInRepoSyncEnabled does not match") } - } func TestDocker(t *testing.T) { @@ -177,7 +173,6 @@ func TestDocker(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -227,7 +222,6 @@ func TestGitHub(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -277,7 +271,6 @@ func TestHelm(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -319,7 +312,6 @@ func TestMaven(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -369,7 +361,6 @@ func TestNpm(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -407,7 +398,6 @@ func TestNpmToResource(t *testing.T) { feed.SetUsername("testuser") feedResource, err := ToFeedResource(&feed) - if err != nil { t.Fatalf("Error should not have been returned. %s", err) } @@ -463,7 +453,6 @@ func TestNuget(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -489,7 +478,6 @@ func TestNuget(t *testing.T) { if typedFeed.FeedURI != "http://example.com" { t.Fatalf("FeedURI does not match") } - } func TestOctopusProject(t *testing.T) { @@ -518,7 +506,6 @@ func TestOctopusProject(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -528,7 +515,6 @@ func TestOctopusProject(t *testing.T) { if typedFeed.Name != "MyFeed" { t.Fatalf("Name does not match") } - } func TestArtifactory(t *testing.T) { @@ -557,7 +543,6 @@ func TestArtifactory(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -579,7 +564,6 @@ func TestArtifactory(t *testing.T) { if typedFeed.FeedURI != "http://example.com" { t.Fatalf("FeedURI does not match") } - } func TestS3(t *testing.T) { @@ -614,7 +598,6 @@ func TestS3(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned") } @@ -664,7 +647,6 @@ func TestOCIRegistry(t *testing.T) { } feed, err := ToFeed(&feedResource) - if err != nil { t.Fatalf("Error should not have been returned. %s", err) } @@ -691,7 +673,6 @@ func TestOCIRegistryToResource(t *testing.T) { } feedResource, err := ToFeedResource(&feed) - if err != nil { t.Fatalf("Error should not have been returned. %s", err) } diff --git a/pkg/feeds/gcs_storage_feed.go b/pkg/feeds/gcs_storage_feed.go index 14924bcc..8085c5a4 100644 --- a/pkg/feeds/gcs_storage_feed.go +++ b/pkg/feeds/gcs_storage_feed.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) type GcsStorageFeed struct { diff --git a/pkg/feeds/github_feed.go b/pkg/feeds/github_feed.go index 14cb4205..5f553802 100644 --- a/pkg/feeds/github_feed.go +++ b/pkg/feeds/github_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // GitHubRepositoryFeed represents a GitHub repository feed. diff --git a/pkg/feeds/google_container_registry.go b/pkg/feeds/google_container_registry.go index 91f9d257..e070fffe 100644 --- a/pkg/feeds/google_container_registry.go +++ b/pkg/feeds/google_container_registry.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // GoogleContainerRegistry represents a Google Container Registry (GCR). @@ -31,7 +32,6 @@ func NewGoogleContainerRegistry(name string, username string, password *core.Sen } dockerContainerRegistry, err := NewDockerContainerRegistryWithFeedType(name, FeedTypeGoogleContainerRegistry) - if err != nil { return nil, err } diff --git a/pkg/feeds/helm_feed.go b/pkg/feeds/helm_feed.go index 734b39f1..bf14f538 100644 --- a/pkg/feeds/helm_feed.go +++ b/pkg/feeds/helm_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // HelmFeed represents a Helm feed. diff --git a/pkg/feeds/maven_feed.go b/pkg/feeds/maven_feed.go index 30cd6ddd..74621dd7 100644 --- a/pkg/feeds/maven_feed.go +++ b/pkg/feeds/maven_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // MavenFeed represents a Maven feed. diff --git a/pkg/feeds/npm_feed.go b/pkg/feeds/npm_feed.go index b73801bb..d68f6d51 100644 --- a/pkg/feeds/npm_feed.go +++ b/pkg/feeds/npm_feed.go @@ -1,18 +1,19 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // NpmFeed represents an NPM feed. type NpmFeed struct { - DownloadAttempts int `json:"DownloadAttempts"` - DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"` - FeedURI string `json:"FeedUri,omitempty"` - Username string `json:"Username,omitempty"` + DownloadAttempts int `json:"DownloadAttempts"` + DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"` + FeedURI string `json:"FeedUri,omitempty"` + Username string `json:"Username,omitempty"` Password *core.SensitiveValue `json:"Password,omitempty"` feed diff --git a/pkg/feeds/nuget_feed.go b/pkg/feeds/nuget_feed.go index 37589d21..9686d56a 100644 --- a/pkg/feeds/nuget_feed.go +++ b/pkg/feeds/nuget_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // NuGetFeed represents a NuGet feed. diff --git a/pkg/feeds/oci_registry_feed.go b/pkg/feeds/oci_registry_feed.go index 87236894..17ec17db 100644 --- a/pkg/feeds/oci_registry_feed.go +++ b/pkg/feeds/oci_registry_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // OCIRegistryFeed represents a feed of Open Container Initiative Registry. diff --git a/pkg/feeds/octopus_project_feed.go b/pkg/feeds/octopus_project_feed.go index df651602..6754312c 100644 --- a/pkg/feeds/octopus_project_feed.go +++ b/pkg/feeds/octopus_project_feed.go @@ -1,9 +1,10 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // OctopusProjectFeed represents an Octopus project feed. diff --git a/pkg/feeds/oidc_authentication_test.go b/pkg/feeds/oidc_authentication_test.go index e018cd2e..68187de6 100644 --- a/pkg/feeds/oidc_authentication_test.go +++ b/pkg/feeds/oidc_authentication_test.go @@ -9,13 +9,13 @@ import ( func TestOidcAuthentication_NewAzureOidcAuthentication(t *testing.T) { oidc := NewAzureOidcAuthentication("client-id", "tenant-id", "audience", []string{"subject1", "subject2"}) - + assert.Equal(t, OidcAuthenticationTypeAzure, oidc.Type) assert.Equal(t, "client-id", oidc.ClientId) assert.Equal(t, "tenant-id", oidc.TenantId) assert.Equal(t, "audience", oidc.Audience) assert.Equal(t, []string{"subject1", "subject2"}, oidc.SubjectKeys) - + azure, ok := oidc.GetAzure() assert.True(t, ok) assert.Equal(t, "client-id", azure.ClientId) @@ -26,13 +26,13 @@ func TestOidcAuthentication_NewAzureOidcAuthentication(t *testing.T) { func TestOidcAuthentication_NewAwsOidcAuthentication(t *testing.T) { oidc := NewAwsOidcAuthentication("3600", "audience", "role-arn", []string{"subject1", "subject2"}) - + assert.Equal(t, OidcAuthenticationTypeAWS, oidc.Type) assert.Equal(t, "3600", oidc.SessionDuration) assert.Equal(t, "audience", oidc.Audience) assert.Equal(t, "role-arn", oidc.RoleArn) assert.Equal(t, []string{"subject1", "subject2"}, oidc.SubjectKeys) - + aws, ok := oidc.GetAWS() assert.True(t, ok) assert.Equal(t, "3600", aws.SessionDuration) @@ -43,11 +43,11 @@ func TestOidcAuthentication_NewAwsOidcAuthentication(t *testing.T) { func TestOidcAuthentication_NewGoogleOidcAuthentication(t *testing.T) { oidc := NewGoogleOidcAuthentication("audience", []string{"subject1", "subject2"}) - + assert.Equal(t, OidcAuthenticationTypeGoogle, oidc.Type) assert.Equal(t, "audience", oidc.Audience) assert.Equal(t, []string{"subject1", "subject2"}, oidc.SubjectKeys) - + google, ok := oidc.GetGoogle() assert.True(t, ok) assert.Equal(t, "audience", google.Audience) @@ -56,61 +56,61 @@ func TestOidcAuthentication_NewGoogleOidcAuthentication(t *testing.T) { func TestOidcAuthentication_MarshalJSON_Azure(t *testing.T) { oidc := NewAzureOidcAuthentication("client-id", "tenant-id", "audience", []string{"subject1"}) - + data, err := json.Marshal(oidc) assert.NoError(t, err) - + // Verify the JSON structure is flattened var result map[string]interface{} err = json.Unmarshal(data, &result) assert.NoError(t, err) - + assert.Equal(t, "Azure", result["Type"]) assert.Equal(t, "client-id", result["ClientId"]) assert.Equal(t, "tenant-id", result["TenantId"]) assert.Equal(t, "audience", result["Audience"]) assert.Equal(t, []interface{}{"subject1"}, result["SubjectKeys"]) - + // Should not have nested Data field assert.Nil(t, result["Data"]) } func TestOidcAuthentication_MarshalJSON_AWS(t *testing.T) { oidc := NewAwsOidcAuthentication("3600", "audience", "role-arn", []string{"subject1"}) - + data, err := json.Marshal(oidc) assert.NoError(t, err) - + // Verify the JSON structure is flattened var result map[string]interface{} err = json.Unmarshal(data, &result) assert.NoError(t, err) - + assert.Equal(t, "AWS", result["Type"]) assert.Equal(t, "3600", result["SessionDuration"]) assert.Equal(t, "audience", result["Audience"]) assert.Equal(t, "role-arn", result["RoleArn"]) assert.Equal(t, []interface{}{"subject1"}, result["SubjectKeys"]) - + // Should not have nested Data field assert.Nil(t, result["Data"]) } func TestOidcAuthentication_MarshalJSON_Google(t *testing.T) { oidc := NewGoogleOidcAuthentication("audience", []string{"subject1"}) - + data, err := json.Marshal(oidc) assert.NoError(t, err) - + // Verify the JSON structure is flattened var result map[string]interface{} err = json.Unmarshal(data, &result) assert.NoError(t, err) - + assert.Equal(t, "Google", result["Type"]) assert.Equal(t, "audience", result["Audience"]) assert.Equal(t, []interface{}{"subject1"}, result["SubjectKeys"]) - + // Should not have nested Data field assert.Nil(t, result["Data"]) } @@ -118,16 +118,16 @@ func TestOidcAuthentication_MarshalJSON_Google(t *testing.T) { func TestOidcAuthentication_UnmarshalJSON_Azure(t *testing.T) { // Create Azure OIDC using constructor expectedOidc := NewAzureOidcAuthentication("client-id", "tenant-id", "audience", []string{"subject1", "subject2"}) - + // Marshal to JSON data, err := json.Marshal(expectedOidc) assert.NoError(t, err) - + // Unmarshal back var oidc OidcAuthentication err = json.Unmarshal(data, &oidc) assert.NoError(t, err) - + // Verify the unmarshaled data matches the original assert.Equal(t, expectedOidc.Type, oidc.Type) assert.Equal(t, expectedOidc.ClientId, oidc.ClientId) @@ -139,16 +139,16 @@ func TestOidcAuthentication_UnmarshalJSON_Azure(t *testing.T) { func TestOidcAuthentication_UnmarshalJSON_AWS(t *testing.T) { // Create AWS OIDC using constructor expectedOidc := NewAwsOidcAuthentication("3600", "audience", "role-arn", []string{"subject1", "subject2"}) - + // Marshal to JSON data, err := json.Marshal(expectedOidc) assert.NoError(t, err) - + // Unmarshal back var oidc OidcAuthentication err = json.Unmarshal(data, &oidc) assert.NoError(t, err) - + // Verify the unmarshaled data matches the original assert.Equal(t, expectedOidc.Type, oidc.Type) assert.Equal(t, expectedOidc.SessionDuration, oidc.SessionDuration) @@ -160,16 +160,16 @@ func TestOidcAuthentication_UnmarshalJSON_AWS(t *testing.T) { func TestOidcAuthentication_UnmarshalJSON_Google(t *testing.T) { // Create Google OIDC using constructor expectedOidc := NewGoogleOidcAuthentication("audience", []string{"subject1", "subject2"}) - + // Marshal to JSON data, err := json.Marshal(expectedOidc) assert.NoError(t, err) - + // Unmarshal back var oidc OidcAuthentication err = json.Unmarshal(data, &oidc) assert.NoError(t, err) - + // Verify the unmarshaled data matches the original assert.Equal(t, expectedOidc.Type, oidc.Type) assert.Equal(t, expectedOidc.Audience, oidc.Audience) @@ -178,12 +178,12 @@ func TestOidcAuthentication_UnmarshalJSON_Google(t *testing.T) { func TestOidcAuthentication_GetWrongType(t *testing.T) { oidc := NewAzureOidcAuthentication("client-id", "tenant-id", "audience", []string{"subject1"}) - + // Try to get AWS data from Azure OIDC aws, ok := oidc.GetAWS() assert.False(t, ok) assert.Nil(t, aws) - + // Try to get Google data from Azure OIDC google, ok := oidc.GetGoogle() assert.False(t, ok) @@ -235,4 +235,4 @@ func TestOidcAuthentication_UnmarshalJSON_OnlyAudienceAndSubjectKeys_IsGoogle(t assert.Equal(t, OidcAuthenticationTypeGoogle, oidc.Type) assert.Equal(t, "audience", oidc.Audience) assert.Equal(t, []string{"subject1"}, oidc.SubjectKeys) -} \ No newline at end of file +} diff --git a/pkg/feeds/pypi_feed.go b/pkg/feeds/pypi_feed.go index d8f579d9..ff6d0d3d 100644 --- a/pkg/feeds/pypi_feed.go +++ b/pkg/feeds/pypi_feed.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // PyPiFeed represents a PyPI feed. diff --git a/pkg/feeds/s3_bucket.go b/pkg/feeds/s3_bucket.go index 6ad4cf09..8545f296 100644 --- a/pkg/feeds/s3_bucket.go +++ b/pkg/feeds/s3_bucket.go @@ -1,10 +1,11 @@ package feeds import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // S3Feed represents an Amazon Web Services (AWS) S3 Bucket Feed diff --git a/pkg/githubconnections/settings_test.go b/pkg/githubconnections/settings_test.go index 29959175..370298fc 100644 --- a/pkg/githubconnections/settings_test.go +++ b/pkg/githubconnections/settings_test.go @@ -6,9 +6,10 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) func TestGetSettings(t *testing.T) { diff --git a/pkg/interruptions/interruption.go b/pkg/interruptions/interruption.go index 9061fb86..33add6fa 100644 --- a/pkg/interruptions/interruption.go +++ b/pkg/interruptions/interruption.go @@ -30,8 +30,10 @@ func NewInterruption() *Interruption { } } -const ManualInterventionApprove = "Proceed" -const ManualInterventionDecline = "Abort" +const ( + ManualInterventionApprove = "Proceed" + ManualInterventionDecline = "Abort" +) // Deprecated: use ManualInterventionApprove. const ManualInterverventionApprove = ManualInterventionApprove diff --git a/pkg/interruptions/interruption_service.go b/pkg/interruptions/interruption_service.go index 34667217..c45eb7bf 100644 --- a/pkg/interruptions/interruption_service.go +++ b/pkg/interruptions/interruption_service.go @@ -1,12 +1,13 @@ package interruptions import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" - "github.com/dghubble/sling" ) type InterruptionService struct { diff --git a/pkg/interruptions/interruption_service_test.go b/pkg/interruptions/interruption_service_test.go index 7d8fd5a6..8d8467ab 100644 --- a/pkg/interruptions/interruption_service_test.go +++ b/pkg/interruptions/interruption_service_test.go @@ -3,11 +3,12 @@ package interruptions import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func TestNewInterruptionService(t *testing.T) { diff --git a/pkg/invitations/invitation_service.go b/pkg/invitations/invitation_service.go index 460a4bce..db7b5d32 100644 --- a/pkg/invitations/invitation_service.go +++ b/pkg/invitations/invitation_service.go @@ -1,9 +1,10 @@ package invitations import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type InvitationService struct { diff --git a/pkg/issuetrackers/issue_tracker_service.go b/pkg/issuetrackers/issue_tracker_service.go index b535f150..a4f5ddfd 100644 --- a/pkg/issuetrackers/issue_tracker_service.go +++ b/pkg/issuetrackers/issue_tracker_service.go @@ -1,9 +1,10 @@ package issuetrackers import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type IssueTrackerService struct { diff --git a/pkg/jira/jira_integration_service.go b/pkg/jira/jira_integration_service.go index 4500f68a..3f6d0f9e 100644 --- a/pkg/jira/jira_integration_service.go +++ b/pkg/jira/jira_integration_service.go @@ -1,9 +1,10 @@ package jira import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type JiraIntegrationService struct { diff --git a/pkg/kubernetesmonitors/register_kubernetes_monitor_command.go b/pkg/kubernetesmonitors/register_kubernetes_monitor_command.go index 1cf34d16..e3e7c0a9 100644 --- a/pkg/kubernetesmonitors/register_kubernetes_monitor_command.go +++ b/pkg/kubernetesmonitors/register_kubernetes_monitor_command.go @@ -7,9 +7,9 @@ import ( // RegisterKubernetesMonitorCommand represents a command to register a Kubernetes monitor. type RegisterKubernetesMonitorCommand struct { - InstallationID *uuid.UUID `json:"InstallationId" validate:"required"` - MachineID string `json:"MachineId" validate:"required"` - SpaceID string `json:"SpaceId,omitempty"` + InstallationID *uuid.UUID `json:"InstallationId" validate:"required"` + MachineID string `json:"MachineId" validate:"required"` + SpaceID string `json:"SpaceId,omitempty"` PreserveAuthenticationToken *bool `json:"PreserveAuthenticationToken,omitempty"` } diff --git a/pkg/licenses/licenses_service.go b/pkg/licenses/licenses_service.go index 4ab827d4..3ad20e4b 100644 --- a/pkg/licenses/licenses_service.go +++ b/pkg/licenses/licenses_service.go @@ -1,9 +1,10 @@ package licenses import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type LicenseService struct { diff --git a/pkg/lifecycles/lifecycle.go b/pkg/lifecycles/lifecycle.go index 2a89e7be..61b297ef 100644 --- a/pkg/lifecycles/lifecycle.go +++ b/pkg/lifecycles/lifecycle.go @@ -3,9 +3,10 @@ package lifecycles import ( "strings" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Lifecycle struct { @@ -38,7 +39,6 @@ func NewLifecycle(name string) *Lifecycle { func (l *Lifecycle) Validate() error { validate := validator.New() err := validate.Struct(l) - if err != nil { return err } diff --git a/pkg/lifecycles/lifecycle_service.go b/pkg/lifecycles/lifecycle_service.go index 8fe0c549..71130c29 100644 --- a/pkg/lifecycles/lifecycle_service.go +++ b/pkg/lifecycles/lifecycle_service.go @@ -3,6 +3,8 @@ package lifecycles import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -11,7 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type LifecycleService struct { @@ -128,7 +129,6 @@ func (s *LifecycleService) GetByName(name string) (*Lifecycle, error) { } lifecycles, err := s.GetByPartialName(name) - if err != nil { return nil, err } @@ -172,7 +172,6 @@ func (s *LifecycleService) GetProjects(lifecycle *Lifecycle) ([]*projects.Projec } return *resp.(*[]*projects.Project), nil - } // Update modifies a lifecycle based on the one provided as input. diff --git a/pkg/lifecycles/lifecycle_service_test.go b/pkg/lifecycles/lifecycle_service_test.go index 5fc42dd3..5e7f5072 100644 --- a/pkg/lifecycles/lifecycle_service_test.go +++ b/pkg/lifecycles/lifecycle_service_test.go @@ -3,12 +3,13 @@ package lifecycles import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createLifecycleService(t *testing.T) *LifecycleService { diff --git a/pkg/lifecycles/lifecycle_test.go b/pkg/lifecycles/lifecycle_test.go index 509bf8d0..186d09f4 100644 --- a/pkg/lifecycles/lifecycle_test.go +++ b/pkg/lifecycles/lifecycle_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestLifecycleAsJSON(t *testing.T) { diff --git a/pkg/machinepolicies/machine_policy.go b/pkg/machinepolicies/machine_policy.go index 58c1fc71..3494df01 100644 --- a/pkg/machinepolicies/machine_policy.go +++ b/pkg/machinepolicies/machine_policy.go @@ -4,9 +4,10 @@ import ( "encoding/json" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type MachinePolicy struct { @@ -67,18 +68,18 @@ func (m *MachinePolicy) MarshalJSON() ([]byte, error) { SpaceID string `json:"SpaceId,omitempty"` resources.Resource }{ - ConnectionConnectTimeout: ToTimeSpan(m.ConnectionConnectTimeout), - ConnectionRetryCountLimit: m.ConnectionRetryCountLimit, - ConnectionRetrySleepInterval: ToTimeSpan(m.ConnectionRetrySleepInterval), - ConnectionRetryTimeLimit: ToTimeSpan(m.ConnectionRetryTimeLimit), - Description: m.Description, - IsDefault: m.IsDefault, - MachineCleanupPolicy: m.MachineCleanupPolicy, - MachineConnectivityPolicy: m.MachineConnectivityPolicy, - MachineHealthCheckPolicy: m.MachineHealthCheckPolicy, - MachineUpdatePolicy: m.MachineUpdatePolicy, - MachinePackageCacheRetentionPolicy: m.MachinePackageCacheRetentionPolicy, - Name: m.Name, + ConnectionConnectTimeout: ToTimeSpan(m.ConnectionConnectTimeout), + ConnectionRetryCountLimit: m.ConnectionRetryCountLimit, + ConnectionRetrySleepInterval: ToTimeSpan(m.ConnectionRetrySleepInterval), + ConnectionRetryTimeLimit: ToTimeSpan(m.ConnectionRetryTimeLimit), + Description: m.Description, + IsDefault: m.IsDefault, + MachineCleanupPolicy: m.MachineCleanupPolicy, + MachineConnectivityPolicy: m.MachineConnectivityPolicy, + MachineHealthCheckPolicy: m.MachineHealthCheckPolicy, + MachineUpdatePolicy: m.MachineUpdatePolicy, + MachinePackageCacheRetentionPolicy: m.MachinePackageCacheRetentionPolicy, + Name: m.Name, PollingRequestMaximumMessageProcessingTimeout: ToTimeSpan(m.PollingRequestMaximumMessageProcessingTimeout), PollingRequestQueueTimeout: ToTimeSpan(m.PollingRequestQueueTimeout), SpaceID: m.SpaceID, diff --git a/pkg/machines/aws_ecs_cluster_endpoint.go b/pkg/machines/aws_ecs_cluster_endpoint.go index a98a3cfd..8709a38e 100644 --- a/pkg/machines/aws_ecs_cluster_endpoint.go +++ b/pkg/machines/aws_ecs_cluster_endpoint.go @@ -38,5 +38,7 @@ func (e *AwsEcsClusterEndpoint) SetDefaultWorkerPoolID(defaultWorkerPoolID strin e.DefaultWorkerPoolID = defaultWorkerPoolID } -var _ IEndpoint = &AwsEcsClusterEndpoint{} -var _ IRunsOnAWorker = &AwsEcsClusterEndpoint{} +var ( + _ IEndpoint = &AwsEcsClusterEndpoint{} + _ IRunsOnAWorker = &AwsEcsClusterEndpoint{} +) diff --git a/pkg/machines/aws_ecs_cluster_endpoint_test.go b/pkg/machines/aws_ecs_cluster_endpoint_test.go index c29c9009..c82be07f 100644 --- a/pkg/machines/aws_ecs_cluster_endpoint_test.go +++ b/pkg/machines/aws_ecs_cluster_endpoint_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) // An Amazon ECS cluster target as the server returns it, taken verbatim from diff --git a/pkg/machines/azure_cloud_service_endpoint.go b/pkg/machines/azure_cloud_service_endpoint.go index 9aa7508a..a24e3870 100644 --- a/pkg/machines/azure_cloud_service_endpoint.go +++ b/pkg/machines/azure_cloud_service_endpoint.go @@ -41,5 +41,7 @@ func (a *AzureCloudServiceEndpoint) SetDefaultWorkerPoolID(defaultWorkerPoolID s a.DefaultWorkerPoolID = defaultWorkerPoolID } -var _ IEndpointWithAccount = &AzureCloudServiceEndpoint{} -var _ IRunsOnAWorker = &AzureCloudServiceEndpoint{} +var ( + _ IEndpointWithAccount = &AzureCloudServiceEndpoint{} + _ IRunsOnAWorker = &AzureCloudServiceEndpoint{} +) diff --git a/pkg/machines/azure_service_fabric_endpoint.go b/pkg/machines/azure_service_fabric_endpoint.go index 3e1ae79c..fc4d3fc4 100644 --- a/pkg/machines/azure_service_fabric_endpoint.go +++ b/pkg/machines/azure_service_fabric_endpoint.go @@ -1,8 +1,9 @@ package machines import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) type AzureServiceFabricEndpoint struct { diff --git a/pkg/machines/azure_web_app_endpoint.go b/pkg/machines/azure_web_app_endpoint.go index 6fbf440e..5c484a13 100644 --- a/pkg/machines/azure_web_app_endpoint.go +++ b/pkg/machines/azure_web_app_endpoint.go @@ -22,8 +22,10 @@ func NewAzureWebAppEndpoint() *AzureWebAppEndpoint { return azureWebAppEndpoint } -var _ resources.IResource = &AzureWebAppEndpoint{} -var _ IEndpoint = &AzureWebAppEndpoint{} +var ( + _ resources.IResource = &AzureWebAppEndpoint{} + _ IEndpoint = &AzureWebAppEndpoint{} +) // GetDefaultWorkerPoolID returns the default worker pool ID of this endpoint. func (e AzureWebAppEndpoint) GetDefaultWorkerPoolID() string { diff --git a/pkg/machines/deployment_target.go b/pkg/machines/deployment_target.go index f9da8800..586f6267 100644 --- a/pkg/machines/deployment_target.go +++ b/pkg/machines/deployment_target.go @@ -3,8 +3,9 @@ package machines import ( "encoding/json" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // TODO: research the JSON marshalling to include SpaceID diff --git a/pkg/machines/endpoint.go b/pkg/machines/endpoint.go index 70cd5274..4ef2bc96 100644 --- a/pkg/machines/endpoint.go +++ b/pkg/machines/endpoint.go @@ -1,8 +1,9 @@ package machines import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) // IEndpoint defines the interface for endpoints. diff --git a/pkg/machines/endpoint_resource.go b/pkg/machines/endpoint_resource.go index 77fd9ffc..1e54729b 100644 --- a/pkg/machines/endpoint_resource.go +++ b/pkg/machines/endpoint_resource.go @@ -3,10 +3,11 @@ package machines import ( "net/url" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type EndpointResource struct { diff --git a/pkg/machines/kubernetes_endpoint.go b/pkg/machines/kubernetes_endpoint.go index 444b6f99..fc7d6f4d 100644 --- a/pkg/machines/kubernetes_endpoint.go +++ b/pkg/machines/kubernetes_endpoint.go @@ -5,11 +5,12 @@ import ( "net/url" "strconv" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/go-playground/validator/v10" "golang.org/x/text/cases" "golang.org/x/text/language" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" ) type KubernetesEndpoint struct { @@ -216,6 +217,8 @@ func (k *KubernetesEndpoint) Validate() error { return validator.New().Struct(k) } -var _ IEndpoint = &KubernetesEndpoint{} -var _ IEndpointWithProxy = &KubernetesEndpoint{} -var _ IRunsOnAWorker = &KubernetesEndpoint{} +var ( + _ IEndpoint = &KubernetesEndpoint{} + _ IEndpointWithProxy = &KubernetesEndpoint{} + _ IRunsOnAWorker = &KubernetesEndpoint{} +) diff --git a/pkg/machines/kubernetes_endpoint_test.go b/pkg/machines/kubernetes_endpoint_test.go index db29296c..c11da49b 100644 --- a/pkg/machines/kubernetes_endpoint_test.go +++ b/pkg/machines/kubernetes_endpoint_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" ) func CreateTestKubernetesAwsEndpoint(t *testing.T) *KubernetesEndpoint { diff --git a/pkg/machines/kubernetes_tentacle_endpoint.go b/pkg/machines/kubernetes_tentacle_endpoint.go index f1399ce2..f67fb006 100644 --- a/pkg/machines/kubernetes_tentacle_endpoint.go +++ b/pkg/machines/kubernetes_tentacle_endpoint.go @@ -2,8 +2,9 @@ package machines import ( "encoding/json" - "github.com/go-playground/validator/v10" "net/url" + + "github.com/go-playground/validator/v10" ) type KubernetesTentacleEndpoint struct { diff --git a/pkg/machines/listening_tentacle_endpoint_test.go b/pkg/machines/listening_tentacle_endpoint_test.go index 70981e0d..a54e9ae1 100644 --- a/pkg/machines/listening_tentacle_endpoint_test.go +++ b/pkg/machines/listening_tentacle_endpoint_test.go @@ -37,7 +37,6 @@ func TestListeningTentacleEndpointMarshalJSON(t *testing.T) { actual := string(jsonEncoding) jsonassert.New(t).Assertf(actual, listeningTentacleEndpointAsJSON) - } func TestListeningTentacleEndpointUnmarshalJSON(t *testing.T) { diff --git a/pkg/machines/machine.go b/pkg/machines/machine.go index 7b8bbeba..e5258b72 100644 --- a/pkg/machines/machine.go +++ b/pkg/machines/machine.go @@ -3,8 +3,9 @@ package machines import ( "encoding/json" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) // machine represents a machine on which Octopus can orchestrate actions. May diff --git a/pkg/machines/machine_policy.go b/pkg/machines/machine_policy.go index c4ea1795..71e71ffc 100644 --- a/pkg/machines/machine_policy.go +++ b/pkg/machines/machine_policy.go @@ -4,9 +4,10 @@ import ( "encoding/json" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type MachinePolicy struct { @@ -67,18 +68,18 @@ func (m *MachinePolicy) MarshalJSON() ([]byte, error) { SpaceID string `json:"SpaceId,omitempty"` resources.Resource }{ - ConnectionConnectTimeout: ToTimeSpan(m.ConnectionConnectTimeout), - ConnectionRetryCountLimit: m.ConnectionRetryCountLimit, - ConnectionRetrySleepInterval: ToTimeSpan(m.ConnectionRetrySleepInterval), - ConnectionRetryTimeLimit: ToTimeSpan(m.ConnectionRetryTimeLimit), - Description: m.Description, - IsDefault: m.IsDefault, - MachineCleanupPolicy: m.MachineCleanupPolicy, - MachineConnectivityPolicy: m.MachineConnectivityPolicy, - MachineHealthCheckPolicy: m.MachineHealthCheckPolicy, - MachineUpdatePolicy: m.MachineUpdatePolicy, - MachinePackageCacheRetentionPolicy: m.MachinePackageCacheRetentionPolicy, - Name: m.Name, + ConnectionConnectTimeout: ToTimeSpan(m.ConnectionConnectTimeout), + ConnectionRetryCountLimit: m.ConnectionRetryCountLimit, + ConnectionRetrySleepInterval: ToTimeSpan(m.ConnectionRetrySleepInterval), + ConnectionRetryTimeLimit: ToTimeSpan(m.ConnectionRetryTimeLimit), + Description: m.Description, + IsDefault: m.IsDefault, + MachineCleanupPolicy: m.MachineCleanupPolicy, + MachineConnectivityPolicy: m.MachineConnectivityPolicy, + MachineHealthCheckPolicy: m.MachineHealthCheckPolicy, + MachineUpdatePolicy: m.MachineUpdatePolicy, + MachinePackageCacheRetentionPolicy: m.MachinePackageCacheRetentionPolicy, + Name: m.Name, PollingRequestMaximumMessageProcessingTimeout: ToTimeSpan(m.PollingRequestMaximumMessageProcessingTimeout), PollingRequestQueueTimeout: ToTimeSpan(m.PollingRequestQueueTimeout), SpaceID: m.SpaceID, diff --git a/pkg/machines/machine_policy_service.go b/pkg/machines/machine_policy_service.go index b48ccef6..68cccc5f 100644 --- a/pkg/machines/machine_policy_service.go +++ b/pkg/machines/machine_policy_service.go @@ -1,12 +1,13 @@ package machines import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type MachinePolicyService struct { diff --git a/pkg/machines/machine_policy_service_test.go b/pkg/machines/machine_policy_service_test.go index a0395132..c6b6fa04 100644 --- a/pkg/machines/machine_policy_service_test.go +++ b/pkg/machines/machine_policy_service_test.go @@ -3,12 +3,13 @@ package machines import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createMachinePolicyService(t *testing.T) *MachinePolicyService { diff --git a/pkg/machines/machine_role_service.go b/pkg/machines/machine_role_service.go index f2691b9d..4106dbed 100644 --- a/pkg/machines/machine_role_service.go +++ b/pkg/machines/machine_role_service.go @@ -1,10 +1,11 @@ package machines import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type MachineRoleService struct { diff --git a/pkg/machines/machine_service.go b/pkg/machines/machine_service.go index e2e2bdf5..46afabdf 100644 --- a/pkg/machines/machine_service.go +++ b/pkg/machines/machine_service.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -11,7 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type MachineService struct { diff --git a/pkg/machines/machine_service_test.go b/pkg/machines/machine_service_test.go index 06b93ea3..70963cfb 100644 --- a/pkg/machines/machine_service_test.go +++ b/pkg/machines/machine_service_test.go @@ -3,12 +3,13 @@ package machines import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createMachineService(t *testing.T) *MachineService { diff --git a/pkg/machines/ssh_endpoint.go b/pkg/machines/ssh_endpoint.go index eb547065..f9b93dae 100644 --- a/pkg/machines/ssh_endpoint.go +++ b/pkg/machines/ssh_endpoint.go @@ -5,8 +5,9 @@ import ( "net/url" "strconv" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type IEndpointWithFingerprint interface { @@ -154,8 +155,10 @@ func (s *SSHEndpoint) Validate() error { return validator.New().Struct(s) } -var _ IEndpoint = &SSHEndpoint{} -var _ IEndpointWithAccount = &SSHEndpoint{} -var _ IEndpointWithFingerprint = &SSHEndpoint{} -var _ IEndpointWithHostname = &SSHEndpoint{} -var _ IEndpointWithProxy = &SSHEndpoint{} +var ( + _ IEndpoint = &SSHEndpoint{} + _ IEndpointWithAccount = &SSHEndpoint{} + _ IEndpointWithFingerprint = &SSHEndpoint{} + _ IEndpointWithHostname = &SSHEndpoint{} + _ IEndpointWithProxy = &SSHEndpoint{} +) diff --git a/pkg/machines/worker.go b/pkg/machines/worker.go index 69273d2a..05ac3a32 100644 --- a/pkg/machines/worker.go +++ b/pkg/machines/worker.go @@ -3,8 +3,9 @@ package machines import ( "encoding/json" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type Worker struct { diff --git a/pkg/machines/worker_service.go b/pkg/machines/worker_service.go index 18db39e3..7c0d17fb 100644 --- a/pkg/machines/worker_service.go +++ b/pkg/machines/worker_service.go @@ -2,14 +2,16 @@ package machines import ( "fmt" + "strings" + + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" - "strings" ) type WorkerService struct { diff --git a/pkg/machines/worker_service_test.go b/pkg/machines/worker_service_test.go index 5a28500d..38cdf042 100644 --- a/pkg/machines/worker_service_test.go +++ b/pkg/machines/worker_service_test.go @@ -3,12 +3,13 @@ package machines import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createWorkerService(t *testing.T) *WorkerService { diff --git a/pkg/machines/worker_test.go b/pkg/machines/worker_test.go index 29ffed6f..095578fb 100644 --- a/pkg/machines/worker_test.go +++ b/pkg/machines/worker_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestWorkersNew(t *testing.T) { diff --git a/pkg/migrations/migration_service.go b/pkg/migrations/migration_service.go index 6ea7d124..17c4dc68 100644 --- a/pkg/migrations/migration_service.go +++ b/pkg/migrations/migration_service.go @@ -1,9 +1,10 @@ package migrations import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type MigrationService struct { diff --git a/pkg/newclient/httpsession.go b/pkg/newclient/httpsession.go index b1946e5b..b1e42819 100644 --- a/pkg/newclient/httpsession.go +++ b/pkg/newclient/httpsession.go @@ -4,11 +4,12 @@ import ( "bytes" "encoding/json" "errors" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "io" "net/http" "net/url" "strings" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) // HttpSession is a layer over http.Client, and provides the following additional functionality: @@ -124,8 +125,8 @@ func DoRequest[TResponse any](httpSession *HttpSession, method string, path stri // body will be assigned inside DoRawJsonRequest } - var responsePayload = new(TResponse) - var errorPayload = new(core.APIError) + responsePayload := new(TResponse) + errorPayload := new(core.APIError) _, err = httpSession.DoRawJsonRequest(req, body, responsePayload, errorPayload) if err != nil { return nil, err @@ -149,8 +150,8 @@ func DoDelete(httpSession *HttpSession, method string, path string) error { URL: pathUrl, } - var responsePayload = new(any) - var errorPayload = new(core.APIError) + responsePayload := new(any) + errorPayload := new(core.APIError) _, err = httpSession.DoRawJsonRequest(req, nil, responsePayload, errorPayload) if err != nil { return err diff --git a/pkg/observability/container_logs.go b/pkg/observability/container_logs.go index 9136e471..4c77152e 100644 --- a/pkg/observability/container_logs.go +++ b/pkg/observability/container_logs.go @@ -72,15 +72,15 @@ func (c *ContainerLogLineResource) Validate() error { // BeginContainerLogsSessionCommand represents a request to begin a container logs session // Command to request the Kubernetes monitor to start sending logs for the specified container type BeginContainerLogsSessionCommand struct { - SpaceID string `json:"spaceId" validate:"required"` - ProjectID string `json:"projectId" validate:"required"` - EnvironmentID string `json:"environmentId" validate:"required"` - TenantID *string `json:"tenantId,omitempty"` - MachineID string `json:"machineId" validate:"required"` + SpaceID string `json:"spaceId" validate:"required"` + ProjectID string `json:"projectId" validate:"required"` + EnvironmentID string `json:"environmentId" validate:"required"` + TenantID *string `json:"tenantId,omitempty"` + MachineID string `json:"machineId" validate:"required"` DesiredOrKubernetesMonitoredResourceID string `json:"desiredOrKubernetesMonitoredResourceId" validate:"required"` - PodName string `json:"podName" validate:"required"` - ContainerName string `json:"containerName" validate:"required"` - ShowPreviousContainer bool `json:"showPreviousContainer"` + PodName string `json:"podName" validate:"required"` + ContainerName string `json:"containerName" validate:"required"` + ShowPreviousContainer bool `json:"showPreviousContainer"` } // BeginContainerLogsSessionResponse represents the response from beginning a container logs session @@ -102,14 +102,14 @@ func NewBeginContainerLogsSessionCommand( showPreviousContainer bool, ) *BeginContainerLogsSessionCommand { return &BeginContainerLogsSessionCommand{ - SpaceID: spaceID, - ProjectID: projectID, - EnvironmentID: environmentID, - MachineID: machineID, + SpaceID: spaceID, + ProjectID: projectID, + EnvironmentID: environmentID, + MachineID: machineID, DesiredOrKubernetesMonitoredResourceID: desiredOrKubernetesMonitoredResourceID, - PodName: podName, - ContainerName: containerName, - ShowPreviousContainer: showPreviousContainer, + PodName: podName, + ContainerName: containerName, + ShowPreviousContainer: showPreviousContainer, } } @@ -129,4 +129,3 @@ func (c *BeginContainerLogsSessionCommand) Validate() error { func (r *BeginContainerLogsSessionResponse) Validate() error { return validator.New().Struct(r) } - diff --git a/pkg/observability/container_logs_service.go b/pkg/observability/container_logs_service.go index 7d30658a..58d4c36b 100644 --- a/pkg/observability/container_logs_service.go +++ b/pkg/observability/container_logs_service.go @@ -64,4 +64,4 @@ func BeginContainerLogsSessionWithClient(client newclient.Client, command *Begin } return resp, nil -} \ No newline at end of file +} diff --git a/pkg/observability/resource.go b/pkg/observability/resource.go index 062cd537..6cdee13e 100644 --- a/pkg/observability/resource.go +++ b/pkg/observability/resource.go @@ -143,7 +143,6 @@ func (p *PodManifestSummary) Validate() error { // UnmarshalJSON custom unmarshaling for KubernetesLiveStatusDetailedResource func (r *KubernetesLiveStatusDetailedResource) UnmarshalJSON(data []byte) error { - type manifestSummaryDiscriminator struct { Kind string `json:"Kind"` } diff --git a/pkg/observability/resource_events.go b/pkg/observability/resource_events.go index 62848f66..94122fd3 100644 --- a/pkg/observability/resource_events.go +++ b/pkg/observability/resource_events.go @@ -12,12 +12,12 @@ type ResourceEventsSessionId string // BeginResourceEventsSessionRequest represents a request to begin a resource events session // Request to start monitoring events for a specific Kubernetes resource type BeginResourceEventsSessionRequest struct { - SpaceID string `json:"spaceId" validate:"required"` - ProjectID string `json:"projectId" validate:"required"` - EnvironmentID string `json:"environmentId" validate:"required"` - TenantID *string `json:"tenantId,omitempty"` - MachineID string `json:"machineId" validate:"required"` - DesiredOrKubernetesMonitoredResourceID string `json:"desiredOrKubernetesMonitoredResourceId" validate:"required"` + SpaceID string `json:"spaceId" validate:"required"` + ProjectID string `json:"projectId" validate:"required"` + EnvironmentID string `json:"environmentId" validate:"required"` + TenantID *string `json:"tenantId,omitempty"` + MachineID string `json:"machineId" validate:"required"` + DesiredOrKubernetesMonitoredResourceID string `json:"desiredOrKubernetesMonitoredResourceId" validate:"required"` } // BeginResourceEventsSessionResponse represents the response for beginning a resource events session @@ -64,10 +64,10 @@ type MonitorErrorResource struct { // NewBeginResourceEventsSessionRequest creates a new BeginResourceEventsSessionRequest func NewBeginResourceEventsSessionRequest(spaceID, projectID, environmentID, machineID, desiredOrKubernetesMonitoredResourceID string) *BeginResourceEventsSessionRequest { return &BeginResourceEventsSessionRequest{ - SpaceID: spaceID, - ProjectID: projectID, - EnvironmentID: environmentID, - MachineID: machineID, + SpaceID: spaceID, + ProjectID: projectID, + EnvironmentID: environmentID, + MachineID: machineID, DesiredOrKubernetesMonitoredResourceID: desiredOrKubernetesMonitoredResourceID, } } diff --git a/pkg/observability/resource_events_test.go b/pkg/observability/resource_events_test.go index 949e8acd..6f49ff6b 100644 --- a/pkg/observability/resource_events_test.go +++ b/pkg/observability/resource_events_test.go @@ -10,10 +10,10 @@ import ( func TestBeginResourceEventsSessionRequest_Validate(t *testing.T) { // Test valid request validRequest := &BeginResourceEventsSessionRequest{ - SpaceID: "Spaces-1", - ProjectID: "Projects-1", - EnvironmentID: "Environments-1", - MachineID: "Machines-1", + SpaceID: "Spaces-1", + ProjectID: "Projects-1", + EnvironmentID: "Environments-1", + MachineID: "Machines-1", DesiredOrKubernetesMonitoredResourceID: "resource-123", } @@ -23,11 +23,11 @@ func TestBeginResourceEventsSessionRequest_Validate(t *testing.T) { // Test valid request with optional TenantID tenantID := "Tenants-1" validRequestWithTenant := &BeginResourceEventsSessionRequest{ - SpaceID: "Spaces-1", - ProjectID: "Projects-1", - EnvironmentID: "Environments-1", - TenantID: &tenantID, - MachineID: "Machines-1", + SpaceID: "Spaces-1", + ProjectID: "Projects-1", + EnvironmentID: "Environments-1", + TenantID: &tenantID, + MachineID: "Machines-1", DesiredOrKubernetesMonitoredResourceID: "resource-123", } @@ -42,9 +42,9 @@ func TestBeginResourceEventsSessionRequest_Validate(t *testing.T) { // Test invalid request (missing SpaceID) invalidRequestNoSpace := &BeginResourceEventsSessionRequest{ - ProjectID: "Projects-1", - EnvironmentID: "Environments-1", - MachineID: "Machines-1", + ProjectID: "Projects-1", + EnvironmentID: "Environments-1", + MachineID: "Machines-1", DesiredOrKubernetesMonitoredResourceID: "resource-123", } diff --git a/pkg/observability/resource_test.go b/pkg/observability/resource_test.go index f8fd8675..768cc35f 100644 --- a/pkg/observability/resource_test.go +++ b/pkg/observability/resource_test.go @@ -196,15 +196,15 @@ func TestKubernetesLiveStatusDetailedResource_UnmarshalJSON_Pod(t *testing.T) { // Verify ManifestSummary is properly parsed as PodManifestSummary assert.NotNil(t, resource.ManifestSummary) - + // Type assert to PodManifestSummary to access Containers podSummary, ok := resource.ManifestSummary.(*PodManifestSummary) assert.True(t, ok, "ManifestSummary should be of type *PodManifestSummary for Pod resources") assert.NotNil(t, podSummary) - + // Verify Containers field is properly parsed assert.Equal(t, []string{"test-nginx"}, podSummary.GetContainers()) - + // Verify basic ManifestSummary interface methods work assert.Contains(t, resource.ManifestSummary.GetLabels(), "Octopus.Action.Id") assert.Equal(t, "d7419a77-ff63-4072-a861-dd7ab4ec4229", resource.ManifestSummary.GetLabels()["Octopus.Action.Id"]) @@ -241,12 +241,12 @@ func TestKubernetesLiveStatusDetailedResource_UnmarshalJSON_NonPod(t *testing.T) // Verify ManifestSummary is parsed as base ManifestSummary (not PodManifestSummary) assert.NotNil(t, resource.ManifestSummary) - + // Type assert to make sure it's the base type, not PodManifestSummary manifestSummary, ok := resource.ManifestSummary.(*ManifestSummary) assert.True(t, ok, "ManifestSummary should be of type *ManifestSummary for non-Pod resources") assert.NotNil(t, manifestSummary) - + // Verify interface methods work assert.Equal(t, "test-app", resource.ManifestSummary.GetLabels()["app"]) assert.Equal(t, "1", resource.ManifestSummary.GetAnnotations()["deployment.kubernetes.io/revision"]) @@ -286,7 +286,7 @@ func TestGetResourceResponse_UnmarshalJSON_Pod(t *testing.T) { // Verify the resource is properly parsed assert.NotNil(t, response.Resource) assert.Equal(t, "Pod", response.Resource.Kind) - + // Verify ManifestSummary contains Containers for Pod podSummary, ok := response.Resource.ManifestSummary.(*PodManifestSummary) assert.True(t, ok, "ManifestSummary should be PodManifestSummary for Pod resources") diff --git a/pkg/octopusservernodes/octopus_server_nodes_service.go b/pkg/octopusservernodes/octopus_server_nodes_service.go index 0a6592cd..a82af7dc 100644 --- a/pkg/octopusservernodes/octopus_server_nodes_service.go +++ b/pkg/octopusservernodes/octopus_server_nodes_service.go @@ -1,9 +1,10 @@ package octopusservernodes import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type OctopusServerNodeService struct { diff --git a/pkg/packages/multipartstreaming_test.go b/pkg/packages/multipartstreaming_test.go index 6a42f72c..55666b99 100644 --- a/pkg/packages/multipartstreaming_test.go +++ b/pkg/packages/multipartstreaming_test.go @@ -1,12 +1,14 @@ package packages_test import ( - "github.com/MakeNowJust/heredoc/v2" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" - "github.com/stretchr/testify/assert" "io" "strings" "testing" + + "github.com/MakeNowJust/heredoc/v2" + "github.com/stretchr/testify/assert" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" ) func TestMultipartStreaming(t *testing.T) { diff --git a/pkg/packages/package_delta_upload.go b/pkg/packages/package_delta_upload.go index 0397442a..d3ffb082 100644 --- a/pkg/packages/package_delta_upload.go +++ b/pkg/packages/package_delta_upload.go @@ -5,15 +5,17 @@ import ( "bytes" "encoding/base64" "encoding/json" - "github.com/OctopusDeploy/go-octodiff/pkg/octodiff" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "io" "net/http" "os" "path/filepath" "time" + + "github.com/OctopusDeploy/go-octodiff/pkg/octodiff" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) type PackageSignatureResponse struct { @@ -27,7 +29,8 @@ func uploadDelta( fileName string, input io.ReadSeeker, inputLength int64, - overwriteMode OverwriteMode) (outResponse *PackageUploadResponseV2, outErr error) { + overwriteMode OverwriteMode, +) (outResponse *PackageUploadResponseV2, outErr error) { // theoretically very old servers might not support delta push, but the Go Client is new enough that // we don't need to worry about gracefully handling those and can just fail with an HTTP 404 if we happen to hit one of those @@ -154,7 +157,8 @@ func deltaFallbackUploadFullFile( deltaLength int64, requestSignatureDuration time.Duration, buildDeltaDuration time.Duration, - deltaBehaviour DeltaBehaviour) (*PackageUploadResponseV2, error) { + deltaBehaviour DeltaBehaviour, +) (*PackageUploadResponseV2, error) { // we can recover by pushing the full file // need to seek back to the start or the regular forward-read will fail _, err := input.Seek(0, io.SeekStart) @@ -215,8 +219,8 @@ func requestDeltaSignature(client newclient.Client, params map[string]any) (*Pac } defer newclient.CloseResponse(resp) - var responseBody = new(PackageSignatureResponse) - var responseError = new(core.APIError) + responseBody := new(PackageSignatureResponse) + responseError := new(core.APIError) bodyDecoder := json.NewDecoder(resp.Body) if resp.StatusCode >= 200 && resp.StatusCode <= 299 { err = bodyDecoder.Decode(responseBody) diff --git a/pkg/packages/package_metadata_service.go b/pkg/packages/package_metadata_service.go index 534ca4d5..0fe542a7 100644 --- a/pkg/packages/package_metadata_service.go +++ b/pkg/packages/package_metadata_service.go @@ -1,9 +1,10 @@ package packages import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type PackageMetadataService struct { diff --git a/pkg/packages/package_service.go b/pkg/packages/package_service.go index dec105b8..a1823f79 100644 --- a/pkg/packages/package_service.go +++ b/pkg/packages/package_service.go @@ -10,6 +10,8 @@ import ( "regexp" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -18,7 +20,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type PackageService struct { @@ -55,7 +56,6 @@ func (s *PackageService) GetAll() ([]*Package, error) { loadNextPage := true for loadNextPage { resp, err := api.ApiGet(s.GetClient(), new(resources.Resources[*Package]), path) - if err != nil { return packages, err } @@ -212,7 +212,6 @@ func UploadV2(client newclient.Client, spaceID string, fileName string, reader i // httpUploadFile creates a multipart POST to upload a file and sends it to the server for either a full package upload // or a delta upload. Both have the same response type so we deserialize that too func httpUploadPackageFile(client newclient.Client, url string, fileName string, reader io.Reader) (response *PackageUploadResponse, createdNewFile bool, err error) { - multipartWriter := NewMultipartFileStreamingReader(fileName, reader) req, err := http.NewRequest(http.MethodPost, url, multipartWriter) diff --git a/pkg/packages/package_service_test.go b/pkg/packages/package_service_test.go index 66d9fbdd..a793ba31 100644 --- a/pkg/packages/package_service_test.go +++ b/pkg/packages/package_service_test.go @@ -2,14 +2,15 @@ package packages import ( "errors" - "github.com/stretchr/testify/assert" "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createPackageService(t *testing.T) *PackageService { diff --git a/pkg/packages/package_upload_v2.go b/pkg/packages/package_upload_v2.go index 079221a9..aa371da3 100644 --- a/pkg/packages/package_upload_v2.go +++ b/pkg/packages/package_upload_v2.go @@ -9,8 +9,7 @@ const ( UploadMethodDelta = UploadMethod("Delta") ) -type UploadedPackageInfo interface { -} +type UploadedPackageInfo interface{} // ----- DeltaUploadedPackageInfo ----- diff --git a/pkg/permissions/permission_service.go b/pkg/permissions/permission_service.go index 8e885f43..f5dfdd9c 100644 --- a/pkg/permissions/permission_service.go +++ b/pkg/permissions/permission_service.go @@ -1,9 +1,10 @@ package permissions import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type PermissionService struct { diff --git a/pkg/platformhubaccounts/platform_hub_account.go b/pkg/platformhubaccounts/platform_hub_account.go index 52a17c75..0cc17fc1 100644 --- a/pkg/platformhubaccounts/platform_hub_account.go +++ b/pkg/platformhubaccounts/platform_hub_account.go @@ -1,10 +1,11 @@ package platformhubaccounts import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" + validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) // IPlatformHubAccount defines the interface for Platform Hub accounts. diff --git a/pkg/platformhubaccounts/platform_hub_account_resource.go b/pkg/platformhubaccounts/platform_hub_account_resource.go index 66e9eeda..9e7e5043 100644 --- a/pkg/platformhubaccounts/platform_hub_account_resource.go +++ b/pkg/platformhubaccounts/platform_hub_account_resource.go @@ -8,28 +8,28 @@ import ( // PlatformHubAccountResource represents details for all Platform Hub accounts. type PlatformHubAccountResource struct { - AccountType PlatformHubAccountType `json:"AccountType" validate:"required,oneof=AmazonWebServicesAccount AmazonWebServicesOidcAccount AzureOidc AzureServicePrincipal GoogleCloudAccount GenericOidcAccount UsernamePassword"` - Description string `json:"Description,omitempty"` - Name string `json:"Name" validate:"required,notall"` - AccessKey string `json:"AccessKey,omitempty"` - SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"` - JsonKey *core.SensitiveValue `json:"JsonKey,omitempty"` - ExecutionSubjectKeys []string `json:"ExecutionSubjectKeys,omitempty"` - Audience string `json:"Audience,omitempty"` - Username string `json:"Username,omitempty"` - Password *core.SensitiveValue `json:"Password,omitempty"` - SubscriptionNumber string `json:"SubscriptionNumber,omitempty"` - TenantID string `json:"TenantId,omitempty"` - ApplicationID string `json:"ClientId,omitempty"` - DeploymentSubjectKeys []string `json:"DeploymentSubjectKeys,omitempty"` - HealthCheckSubjectKeys []string `json:"HealthCheckSubjectKeys,omitempty"` - AccountTestSubjectKeys []string `json:"AccountTestSubjectKeys,omitempty"` - AzureEnvironment string `json:"AzureEnvironment,omitempty"` - AuthenticationEndpoint string `json:"ActiveDirectoryEndpointBaseUri,omitempty"` - ResourceManagementEndpoint string `json:"ResourceManagementEndpointBaseUri,omitempty"` - - RoleArn string `json:"RoleArn,omitempty"` - SessionDuration string `json:"SessionDuration,omitempty"` + AccountType PlatformHubAccountType `json:"AccountType" validate:"required,oneof=AmazonWebServicesAccount AmazonWebServicesOidcAccount AzureOidc AzureServicePrincipal GoogleCloudAccount GenericOidcAccount UsernamePassword"` + Description string `json:"Description,omitempty"` + Name string `json:"Name" validate:"required,notall"` + AccessKey string `json:"AccessKey,omitempty"` + SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"` + JsonKey *core.SensitiveValue `json:"JsonKey,omitempty"` + ExecutionSubjectKeys []string `json:"ExecutionSubjectKeys,omitempty"` + Audience string `json:"Audience,omitempty"` + Username string `json:"Username,omitempty"` + Password *core.SensitiveValue `json:"Password,omitempty"` + SubscriptionNumber string `json:"SubscriptionNumber,omitempty"` + TenantID string `json:"TenantId,omitempty"` + ApplicationID string `json:"ClientId,omitempty"` + DeploymentSubjectKeys []string `json:"DeploymentSubjectKeys,omitempty"` + HealthCheckSubjectKeys []string `json:"HealthCheckSubjectKeys,omitempty"` + AccountTestSubjectKeys []string `json:"AccountTestSubjectKeys,omitempty"` + AzureEnvironment string `json:"AzureEnvironment,omitempty"` + AuthenticationEndpoint string `json:"ActiveDirectoryEndpointBaseUri,omitempty"` + ResourceManagementEndpoint string `json:"ResourceManagementEndpointBaseUri,omitempty"` + + RoleArn string `json:"RoleArn,omitempty"` + SessionDuration string `json:"SessionDuration,omitempty"` resources.Resource } diff --git a/pkg/platformhubaccounts/platform_hub_account_resource_test.go b/pkg/platformhubaccounts/platform_hub_account_resource_test.go index fab1bb70..7f877453 100644 --- a/pkg/platformhubaccounts/platform_hub_account_resource_test.go +++ b/pkg/platformhubaccounts/platform_hub_account_resource_test.go @@ -3,9 +3,10 @@ package platformhubaccounts import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestToPlatformHubAccount(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_account_service.go b/pkg/platformhubaccounts/platform_hub_account_service.go index c5f5613b..1324e284 100644 --- a/pkg/platformhubaccounts/platform_hub_account_service.go +++ b/pkg/platformhubaccounts/platform_hub_account_service.go @@ -31,7 +31,7 @@ func Add(client newclient.Client, platformHubAccount IPlatformHubAccount) (IPlat return nil, internal.CreateRequiredParameterIsEmptyOrNilError("platformHubAccountID") } - //create only returns the id of the new resource, so we need to get the full object + // create only returns the id of the new resource, so we need to get the full object return GetByID(client, res.ID) } @@ -84,7 +84,7 @@ func Update(client newclient.Client, platformHubAccount IPlatformHubAccount) (IP return nil, err } - //modify doesn't return the updated object, so we return the input object after a successful update + // modify doesn't return the updated object, so we return the input object after a successful update return platformHubAccount, nil } diff --git a/pkg/platformhubaccounts/platform_hub_aws_account.go b/pkg/platformhubaccounts/platform_hub_aws_account.go index d0942725..75e92f02 100644 --- a/pkg/platformhubaccounts/platform_hub_aws_account.go +++ b/pkg/platformhubaccounts/platform_hub_aws_account.go @@ -1,12 +1,13 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubAwsAccount represents a Platform Hub AWS account. diff --git a/pkg/platformhubaccounts/platform_hub_aws_account_test.go b/pkg/platformhubaccounts/platform_hub_aws_account_test.go index bcd13131..facf8858 100644 --- a/pkg/platformhubaccounts/platform_hub_aws_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_aws_account_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestPlatformHubAwsAccountNew(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_aws_oidc_account.go b/pkg/platformhubaccounts/platform_hub_aws_oidc_account.go index 77f7d42d..d4219174 100644 --- a/pkg/platformhubaccounts/platform_hub_aws_oidc_account.go +++ b/pkg/platformhubaccounts/platform_hub_aws_oidc_account.go @@ -1,11 +1,12 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubAwsOIDCAccount represents a Platform Hub AWS OIDC account. diff --git a/pkg/platformhubaccounts/platform_hub_aws_oidc_account_test.go b/pkg/platformhubaccounts/platform_hub_aws_oidc_account_test.go index 2e27ef3a..84a95871 100644 --- a/pkg/platformhubaccounts/platform_hub_aws_oidc_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_aws_oidc_account_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestPlatformHubAwsOIDCAccount(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_azure_oidc_account.go b/pkg/platformhubaccounts/platform_hub_azure_oidc_account.go index 58585ee6..c555ed70 100644 --- a/pkg/platformhubaccounts/platform_hub_azure_oidc_account.go +++ b/pkg/platformhubaccounts/platform_hub_azure_oidc_account.go @@ -1,11 +1,12 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubAzureOidcAccount represents a Platform Hub Azure OpenID Connect account. diff --git a/pkg/platformhubaccounts/platform_hub_azure_oidc_account_test.go b/pkg/platformhubaccounts/platform_hub_azure_oidc_account_test.go index 626fe19b..8ea1f708 100644 --- a/pkg/platformhubaccounts/platform_hub_azure_oidc_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_azure_oidc_account_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestPlatformHubAzureOidcAccountNew(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_azure_service_principal_account.go b/pkg/platformhubaccounts/platform_hub_azure_service_principal_account.go index d31bd3c2..1a3d9ffc 100644 --- a/pkg/platformhubaccounts/platform_hub_azure_service_principal_account.go +++ b/pkg/platformhubaccounts/platform_hub_azure_service_principal_account.go @@ -1,23 +1,24 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubAzureServicePrincipalAccount represents a Platform Hub Azure Service Principal account. type PlatformHubAzureServicePrincipalAccount struct { - SubscriptionID string `json:"SubscriptionNumber" validate:"required"` - TenantID string `json:"TenantId" validate:"required"` - ApplicationID string `json:"ClientId" validate:"required"` - Password *core.SensitiveValue `json:"Password" validate:"required"` - AzureEnvironment string `json:"AzureEnvironment,omitempty"` - AuthenticationEndpoint string `json:"ActiveDirectoryEndpointBaseUri,omitempty"` - ResourceManagementEndpoint string `json:"ResourceManagementEndpointBaseUri,omitempty"` + SubscriptionID string `json:"SubscriptionNumber" validate:"required"` + TenantID string `json:"TenantId" validate:"required"` + ApplicationID string `json:"ClientId" validate:"required"` + Password *core.SensitiveValue `json:"Password" validate:"required"` + AzureEnvironment string `json:"AzureEnvironment,omitempty"` + AuthenticationEndpoint string `json:"ActiveDirectoryEndpointBaseUri,omitempty"` + ResourceManagementEndpoint string `json:"ResourceManagementEndpointBaseUri,omitempty"` platformHubAccount } diff --git a/pkg/platformhubaccounts/platform_hub_azure_service_principal_account_test.go b/pkg/platformhubaccounts/platform_hub_azure_service_principal_account_test.go index 1ad4c48e..90cea412 100644 --- a/pkg/platformhubaccounts/platform_hub_azure_service_principal_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_azure_service_principal_account_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestPlatformHubAzureServicePrincipalAccountNew(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_gcp_account.go b/pkg/platformhubaccounts/platform_hub_gcp_account.go index 4759eef1..002c7404 100644 --- a/pkg/platformhubaccounts/platform_hub_gcp_account.go +++ b/pkg/platformhubaccounts/platform_hub_gcp_account.go @@ -1,12 +1,13 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubGcpAccount represents a Platform Hub GCP account. diff --git a/pkg/platformhubaccounts/platform_hub_gcp_account_test.go b/pkg/platformhubaccounts/platform_hub_gcp_account_test.go index 4efee288..c49cb6e2 100644 --- a/pkg/platformhubaccounts/platform_hub_gcp_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_gcp_account_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestPlatformHubGcpAccountNew(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_generic_oidc_account.go b/pkg/platformhubaccounts/platform_hub_generic_oidc_account.go index b567fe9c..61660b8f 100644 --- a/pkg/platformhubaccounts/platform_hub_generic_oidc_account.go +++ b/pkg/platformhubaccounts/platform_hub_generic_oidc_account.go @@ -1,11 +1,12 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubGenericOidcAccount represents a Platform Hub Generic OIDC account. diff --git a/pkg/platformhubaccounts/platform_hub_generic_oidc_account_test.go b/pkg/platformhubaccounts/platform_hub_generic_oidc_account_test.go index 0ec3352d..bf7745b8 100644 --- a/pkg/platformhubaccounts/platform_hub_generic_oidc_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_generic_oidc_account_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" ) func TestPlatformHubGenericOidcAccountNew(t *testing.T) { diff --git a/pkg/platformhubaccounts/platform_hub_username_password_account.go b/pkg/platformhubaccounts/platform_hub_username_password_account.go index c898479c..d3ca4331 100644 --- a/pkg/platformhubaccounts/platform_hub_username_password_account.go +++ b/pkg/platformhubaccounts/platform_hub_username_password_account.go @@ -1,12 +1,13 @@ package platformhubaccounts import ( + "github.com/go-playground/validator/v10" + "github.com/go-playground/validator/v10/non-standard/validators" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" validation "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" - "github.com/go-playground/validator/v10" - "github.com/go-playground/validator/v10/non-standard/validators" ) // PlatformHubUsernamePasswordAccount represents a Platform Hub Username-Password account. diff --git a/pkg/platformhubaccounts/platform_hub_username_password_account_test.go b/pkg/platformhubaccounts/platform_hub_username_password_account_test.go index 51289929..f6761581 100644 --- a/pkg/platformhubaccounts/platform_hub_username_password_account_test.go +++ b/pkg/platformhubaccounts/platform_hub_username_password_account_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestPlatformHubUsernamePasswordAccountNew(t *testing.T) { diff --git a/pkg/platformhubgitcredential/platform_hub_git_credential.go b/pkg/platformhubgitcredential/platform_hub_git_credential.go index f35dfc45..e5c07501 100644 --- a/pkg/platformhubgitcredential/platform_hub_git_credential.go +++ b/pkg/platformhubgitcredential/platform_hub_git_credential.go @@ -2,6 +2,7 @@ package platformhubgitcredential import ( "encoding/json" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) diff --git a/pkg/platformhubgithubconnections/service_test.go b/pkg/platformhubgithubconnections/service_test.go index 64c71c65..fac7174d 100644 --- a/pkg/platformhubgithubconnections/service_test.go +++ b/pkg/platformhubgithubconnections/service_test.go @@ -6,10 +6,11 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/githubconnections" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/githubconnections" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) // newTestClient returns a client pointed at a server that records the requested URI and diff --git a/pkg/platformhubpolicies/service_test.go b/pkg/platformhubpolicies/service_test.go index 178bcefa..69fe9112 100644 --- a/pkg/platformhubpolicies/service_test.go +++ b/pkg/platformhubpolicies/service_test.go @@ -5,13 +5,14 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" ) func TestPolicy_BuildAddCommand_Valid(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) expectedPolicy := newPolicyBuilder(). WithName("ValidPolicyName"). @@ -33,7 +34,7 @@ func TestPolicy_BuildAddCommand_Valid(t *testing.T) { } func TestPolicy_BuildAddCommand_Invalid(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) invalidPolicy := newPolicyBuilder().WithName("InvalidPolicyName").WithConditionsRego("").BuildDraft() @@ -43,7 +44,7 @@ func TestPolicy_BuildAddCommand_Invalid(t *testing.T) { } func TestPolicy_BuildUpdateCommand_Valid(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) expectedPolicy := newPolicyBuilder().WithName("Valid Policy"). WithGitRef("refs/heads/main"). @@ -65,7 +66,7 @@ func TestPolicy_BuildUpdateCommand_Valid(t *testing.T) { } func TestPolicy_BuildUpdateCommand_Invalid(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) invalidPolicy := newPolicyBuilder().WithName("Invalid Action").WithViolationAction("").Build() _, _, invalidCommandError := buildUpdateCommand(client, invalidPolicy, "commit invalid command") @@ -74,7 +75,7 @@ func TestPolicy_BuildUpdateCommand_Invalid(t *testing.T) { } func TestPolicy_BuildPublishCommand(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) gitRef := "refs/heads/main" slug := "my_policy" @@ -115,7 +116,7 @@ func TestPolicy_BuildDeactivateCommand(t *testing.T) { } func assertModifyVersionStatusCommand(t *testing.T, version publishedPolicyVersion, activated bool) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) // Act command, path, commandError := buildModifyVersionStatusCommand(client, &version, activated) @@ -132,7 +133,7 @@ func assertModifyVersionStatusCommand(t *testing.T, version publishedPolicyVersi } func TestPolicy_BuildGetVersionsPath_All(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) // All parameters query := PublishedPoliciesQuery{ @@ -148,7 +149,7 @@ func TestPolicy_BuildGetVersionsPath_All(t *testing.T) { } func TestPolicy_BuildGetVersionsPath_OnlySlug(t *testing.T) { - var client = newclient.NewClient(&newclient.HttpSession{}) + client := newclient.NewClient(&newclient.HttpSession{}) query := PublishedPoliciesQuery{ Slug: "my_policy", diff --git a/pkg/platformhubversioncontrolsettings/resource_test.go b/pkg/platformhubversioncontrolsettings/resource_test.go index 2987ba75..c86dd3ec 100644 --- a/pkg/platformhubversioncontrolsettings/resource_test.go +++ b/pkg/platformhubversioncontrolsettings/resource_test.go @@ -4,9 +4,10 @@ import ( "encoding/json" "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" - "github.com/stretchr/testify/require" ) func TestResource_UnmarshalJSON_Anonymous(t *testing.T) { diff --git a/pkg/projectbranches/project_branches_service.go b/pkg/projectbranches/project_branches_service.go index 109a7a61..07d2ac00 100644 --- a/pkg/projectbranches/project_branches_service.go +++ b/pkg/projectbranches/project_branches_service.go @@ -1,6 +1,11 @@ package projectbranches import ( + "net/http" + + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" @@ -8,9 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" - "net/http" ) type ProjectBranchesService struct { diff --git a/pkg/projectgroups/project_group_service.go b/pkg/projectgroups/project_group_service.go index 77f7d2c2..1e9d98f3 100644 --- a/pkg/projectgroups/project_group_service.go +++ b/pkg/projectgroups/project_group_service.go @@ -3,6 +3,8 @@ package projectgroups import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -12,7 +14,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) // ProjectGroupService handles communication with ProjectGroup-related methods of the Octopus API. @@ -131,7 +132,6 @@ func (s *ProjectGroupService) GetByName(name string) (*ProjectGroup, error) { } projectGroups, err := s.GetByPartialName(name) - if err != nil { return nil, err } diff --git a/pkg/projectgroups/project_group_service_test.go b/pkg/projectgroups/project_group_service_test.go index 24e92351..bfc27891 100644 --- a/pkg/projectgroups/project_group_service_test.go +++ b/pkg/projectgroups/project_group_service_test.go @@ -3,12 +3,13 @@ package projectgroups import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createProjectGroupService(t *testing.T) *ProjectGroupService { @@ -45,7 +46,6 @@ func DeleteTestProjectGroup(t *testing.T, service *ProjectGroupService, projectG require.NotNil(t, service) return service.DeleteByID(projectGroup.GetID()) - } func TestNewProjectGroupService(t *testing.T) { diff --git a/pkg/projects/git_persistence_settings.go b/pkg/projects/git_persistence_settings.go index 47e1eb93..c688295f 100644 --- a/pkg/projects/git_persistence_settings.go +++ b/pkg/projects/git_persistence_settings.go @@ -4,9 +4,10 @@ import ( "encoding/json" "net/url" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/go-playground/validator/v10" "golang.org/x/exp/slices" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" ) type GitPersistenceSettings interface { @@ -57,7 +58,8 @@ func NewGitPersistenceSettings( credentials credentials.GitCredential, defaultBranch string, protectedBranchNamePatterns []string, - url *url.URL) GitPersistenceSettings { + url *url.URL, +) GitPersistenceSettings { return &gitPersistenceSettings{ basePath: basePath, credential: credentials, diff --git a/pkg/projects/git_persistence_settings_test.go b/pkg/projects/git_persistence_settings_test.go index 87fe4672..72dbed87 100644 --- a/pkg/projects/git_persistence_settings_test.go +++ b/pkg/projects/git_persistence_settings_test.go @@ -6,12 +6,13 @@ import ( "net/url" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestGitPersistenceSettingsNew(t *testing.T) { diff --git a/pkg/projects/jira_service_management_extension_settings.go b/pkg/projects/jira_service_management_extension_settings.go index 99ea7758..b323bce6 100644 --- a/pkg/projects/jira_service_management_extension_settings.go +++ b/pkg/projects/jira_service_management_extension_settings.go @@ -100,6 +100,8 @@ func (j *JiraServiceManagementExtensionSettings) UnmarshalJSON(b []byte) error { return nil } -var _ extensions.ExtensionSettings = &JiraServiceManagementExtensionSettings{} -var _ extensions.ChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} -var _ extensions.ConnectedChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} +var ( + _ extensions.ExtensionSettings = &JiraServiceManagementExtensionSettings{} + _ extensions.ChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} + _ extensions.ConnectedChangeControlExtensionSettings = &JiraServiceManagementExtensionSettings{} +) diff --git a/pkg/projects/jira_service_management_extension_settings_test.go b/pkg/projects/jira_service_management_extension_settings_test.go index dc39042f..fa0f221b 100644 --- a/pkg/projects/jira_service_management_extension_settings_test.go +++ b/pkg/projects/jira_service_management_extension_settings_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestNewJiraServiceManagementExtensionSettings(t *testing.T) { diff --git a/pkg/projects/persistence_settings_types.go b/pkg/projects/persistence_settings_types.go index 600e4609..24ec9db6 100644 --- a/pkg/projects/persistence_settings_types.go +++ b/pkg/projects/persistence_settings_types.go @@ -3,6 +3,6 @@ package projects type PersistenceSettingsType string const ( - PersistenceSettingsTypeDatabase = PersistenceSettingsType("Database") + PersistenceSettingsTypeDatabase = PersistenceSettingsType("Database") PersistenceSettingsTypeVersionControlled = PersistenceSettingsType("VersionControlled") ) diff --git a/pkg/projects/project.go b/pkg/projects/project.go index 5964a01a..a477ddab 100644 --- a/pkg/projects/project.go +++ b/pkg/projects/project.go @@ -3,12 +3,13 @@ package projects import ( "encoding/json" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Project struct { diff --git a/pkg/projects/project_service.go b/pkg/projects/project_service.go index 4f683294..30339084 100644 --- a/pkg/projects/project_service.go +++ b/pkg/projects/project_service.go @@ -6,19 +6,19 @@ import ( "net/url" "strings" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) type ProjectService struct { @@ -242,7 +242,6 @@ func (s *ProjectService) GetChannels(project *Project) ([]*channels.Channel, err } channelsUrl, err := url.Parse(project.Links[constants.LinkChannels]) - if err != nil { return projectChannels, err } @@ -252,7 +251,6 @@ func (s *ProjectService) GetChannels(project *Project) ([]*channels.Channel, err for loadNextPage { resp, err := api.ApiGet(s.GetClient(), new(resources.Resources[*channels.Channel]), path) - if err != nil { return projectChannels, err } @@ -293,7 +291,6 @@ func (s *ProjectService) GetReleases(project *Project) ([]*releases.Release, err } releasesUrl, err := url.Parse(project.Links[constants.LinkReleases]) - if err != nil { return nil, err } @@ -379,7 +376,6 @@ func (s *ProjectService) GetProgression(project *Project) (*Progression, error) } url, err := url.Parse(project.Links[constants.LinkProgression]) - if err != nil { return nil, err } diff --git a/pkg/projects/project_service_git_refs.go b/pkg/projects/project_service_git_refs.go index eef9cf67..88492f69 100644 --- a/pkg/projects/project_service_git_refs.go +++ b/pkg/projects/project_service_git_refs.go @@ -2,13 +2,15 @@ package projects import ( "fmt" + + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type GitRefType string diff --git a/pkg/projects/project_service_git_refs_test.go b/pkg/projects/project_service_git_refs_test.go index fbec9771..b023d9c5 100644 --- a/pkg/projects/project_service_git_refs_test.go +++ b/pkg/projects/project_service_git_refs_test.go @@ -1,11 +1,13 @@ package projects_test import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" testutil "github.com/OctopusDeploy/go-octopusdeploy/v2/test" - "github.com/stretchr/testify/assert" - "testing" ) // Ideally we would have an integration test talking to the octopus server, however setting up VCS projects diff --git a/pkg/projects/project_service_test.go b/pkg/projects/project_service_test.go index c55aa186..286e217a 100644 --- a/pkg/projects/project_service_test.go +++ b/pkg/projects/project_service_test.go @@ -3,12 +3,13 @@ package projects_test import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func createProjectService(t *testing.T) *projects.ProjectService { diff --git a/pkg/projects/project_test.go b/pkg/projects/project_test.go index ec5dc5bf..8b26d383 100644 --- a/pkg/projects/project_test.go +++ b/pkg/projects/project_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestProjectExtensionSettingsAsJSON(t *testing.T) { diff --git a/pkg/projects/servicenow_extension_settings.go b/pkg/projects/servicenow_extension_settings.go index 0afeb0df..e76a3193 100644 --- a/pkg/projects/servicenow_extension_settings.go +++ b/pkg/projects/servicenow_extension_settings.go @@ -111,6 +111,8 @@ func (s *ServiceNowExtensionSettings) UnmarshalJSON(b []byte) error { return nil } -var _ extensions.ExtensionSettings = &ServiceNowExtensionSettings{} -var _ extensions.ChangeControlExtensionSettings = &ServiceNowExtensionSettings{} -var _ extensions.ConnectedChangeControlExtensionSettings = &ServiceNowExtensionSettings{} +var ( + _ extensions.ExtensionSettings = &ServiceNowExtensionSettings{} + _ extensions.ChangeControlExtensionSettings = &ServiceNowExtensionSettings{} + _ extensions.ConnectedChangeControlExtensionSettings = &ServiceNowExtensionSettings{} +) diff --git a/pkg/projects/servicenow_extension_settings_test.go b/pkg/projects/servicenow_extension_settings_test.go index 9d4d0d27..6e26dca5 100644 --- a/pkg/projects/servicenow_extension_settings_test.go +++ b/pkg/projects/servicenow_extension_settings_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/extensions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestNewServiceNowExtensionSettings(t *testing.T) { diff --git a/pkg/projectvariables/project_variables_service.go b/pkg/projectvariables/project_variables_service.go index 50ecc1c1..3a43dc68 100644 --- a/pkg/projectvariables/project_variables_service.go +++ b/pkg/projectvariables/project_variables_service.go @@ -1,13 +1,14 @@ package projectvariables import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type ProjectVariableService struct { diff --git a/pkg/proxies/proxy_service.go b/pkg/proxies/proxy_service.go index 0ea40aaf..c7f856cf 100644 --- a/pkg/proxies/proxy_service.go +++ b/pkg/proxies/proxy_service.go @@ -1,13 +1,14 @@ package proxies import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ProxyService struct { diff --git a/pkg/releases/release.go b/pkg/releases/release.go index 423472d5..a6f62590 100644 --- a/pkg/releases/release.go +++ b/pkg/releases/release.go @@ -4,7 +4,6 @@ import ( "time" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) diff --git a/pkg/releases/release_service.go b/pkg/releases/release_service.go index 2e3dd017..c2fd7e2a 100644 --- a/pkg/releases/release_service.go +++ b/pkg/releases/release_service.go @@ -3,6 +3,9 @@ package releases import ( "fmt" + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" @@ -12,8 +15,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) type ReleaseService struct { @@ -128,7 +129,6 @@ func GetMissingPackages(client newclient.Client, release *Release) ([]MissingPac "spaceId": spaceID, "releaseId": release.ID, }) - if err != nil { return nil, err } @@ -156,7 +156,6 @@ func GetReleaseDeploymentTemplate(client newclient.Client, spaceID string, relea "spaceId": spaceID, "releaseId": releaseID, }) - if err != nil { return nil, err } diff --git a/pkg/releases/release_service_test.go b/pkg/releases/release_service_test.go index 5e15c8f8..76ffe285 100644 --- a/pkg/releases/release_service_test.go +++ b/pkg/releases/release_service_test.go @@ -3,9 +3,10 @@ package releases import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" - "github.com/stretchr/testify/assert" ) func TestReleaseUpdateSnapshotVariablesValidation(t *testing.T) { diff --git a/pkg/reporting/reporting_service.go b/pkg/reporting/reporting_service.go index 21e4b310..ad90355d 100644 --- a/pkg/reporting/reporting_service.go +++ b/pkg/reporting/reporting_service.go @@ -1,9 +1,10 @@ package reporting import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type ReportingService struct { diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go index 07bb1ff4..253d616f 100644 --- a/pkg/resources/resources.go +++ b/pkg/resources/resources.go @@ -1,8 +1,9 @@ package resources import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/dghubble/sling" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" ) type IResources[T any] interface { diff --git a/pkg/runbooks/queries_test.go b/pkg/runbooks/queries_test.go index 5e65e30e..90c027df 100644 --- a/pkg/runbooks/queries_test.go +++ b/pkg/runbooks/queries_test.go @@ -4,8 +4,9 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) // TestRunbooksQueryExpandsIntoTemplate covers the path Get relies on: RunbooksQuery is diff --git a/pkg/runbooks/run_runbook_v1.go b/pkg/runbooks/run_runbook_v1.go index 2f0b0622..be062e2b 100644 --- a/pkg/runbooks/run_runbook_v1.go +++ b/pkg/runbooks/run_runbook_v1.go @@ -2,6 +2,7 @@ package runbooks import ( "encoding/json" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" diff --git a/pkg/runbooks/runbook.go b/pkg/runbooks/runbook.go index 5d81644b..236535f6 100644 --- a/pkg/runbooks/runbook.go +++ b/pkg/runbooks/runbook.go @@ -1,9 +1,10 @@ package runbooks import ( + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Runbook struct { diff --git a/pkg/runbooks/runbook_process_service.go b/pkg/runbooks/runbook_process_service.go index f603ab32..0610c788 100644 --- a/pkg/runbooks/runbook_process_service.go +++ b/pkg/runbooks/runbook_process_service.go @@ -1,11 +1,12 @@ package runbooks import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type RunbookProcessService struct { diff --git a/pkg/runbooks/runbook_process_service_test.go b/pkg/runbooks/runbook_process_service_test.go index 8c0679da..cd8c4e96 100644 --- a/pkg/runbooks/runbook_process_service_test.go +++ b/pkg/runbooks/runbook_process_service_test.go @@ -3,9 +3,10 @@ package runbooks import ( "testing" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) func createRunbookProcessService(t *testing.T) *RunbookProcessService { diff --git a/pkg/runbooks/runbook_run_service.go b/pkg/runbooks/runbook_run_service.go index 9d028ecf..d03b5112 100644 --- a/pkg/runbooks/runbook_run_service.go +++ b/pkg/runbooks/runbook_run_service.go @@ -1,9 +1,10 @@ package runbooks import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type RunbookRunService struct { diff --git a/pkg/runbooks/runbook_service.go b/pkg/runbooks/runbook_service.go index bccdd699..37554421 100644 --- a/pkg/runbooks/runbook_service.go +++ b/pkg/runbooks/runbook_service.go @@ -3,6 +3,8 @@ package runbooks import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" @@ -11,7 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type RunbookService struct { diff --git a/pkg/runbooks/runbook_service_test.go b/pkg/runbooks/runbook_service_test.go index c5597ab5..21262839 100644 --- a/pkg/runbooks/runbook_service_test.go +++ b/pkg/runbooks/runbook_service_test.go @@ -4,14 +4,15 @@ import ( "encoding/json" "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createRunbookService(t *testing.T) *RunbookService { diff --git a/pkg/runbooks/runbook_snapshot.go b/pkg/runbooks/runbook_snapshot.go index 189be5a0..def2e6ce 100644 --- a/pkg/runbooks/runbook_snapshot.go +++ b/pkg/runbooks/runbook_snapshot.go @@ -1,13 +1,14 @@ package runbooks import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/gitdependencies" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) // RunbookSnapshot represents a runbook snapshot. diff --git a/pkg/runbooks/runbook_snapshot_service.go b/pkg/runbooks/runbook_snapshot_service.go index 3d74bca5..b5915350 100644 --- a/pkg/runbooks/runbook_snapshot_service.go +++ b/pkg/runbooks/runbook_snapshot_service.go @@ -3,6 +3,8 @@ package runbooks import ( "fmt" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -10,7 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type RunbookSnapshotService struct { diff --git a/pkg/runbooks/runbook_snapshot_service_test.go b/pkg/runbooks/runbook_snapshot_service_test.go index 58010b4c..45170873 100644 --- a/pkg/runbooks/runbook_snapshot_service_test.go +++ b/pkg/runbooks/runbook_snapshot_service_test.go @@ -3,12 +3,13 @@ package runbooks import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createRunbookSnapshotService(t *testing.T) *RunbookSnapshotService { diff --git a/pkg/scheduler/scheduler_service.go b/pkg/scheduler/scheduler_service.go index c527749e..26b69926 100644 --- a/pkg/scheduler/scheduler_service.go +++ b/pkg/scheduler/scheduler_service.go @@ -1,9 +1,10 @@ package scheduler import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type SchedulerService struct { diff --git a/pkg/serverstatus/logs_query_test.go b/pkg/serverstatus/logs_query_test.go index de823d7b..5c613091 100644 --- a/pkg/serverstatus/logs_query_test.go +++ b/pkg/serverstatus/logs_query_test.go @@ -3,8 +3,9 @@ package serverstatus import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) func TestLogsQueryExpandsIntoTheRecentLogsTemplate(t *testing.T) { diff --git a/pkg/serverstatus/server_status_service.go b/pkg/serverstatus/server_status_service.go index 13729daf..fc75eb54 100644 --- a/pkg/serverstatus/server_status_service.go +++ b/pkg/serverstatus/server_status_service.go @@ -7,13 +7,14 @@ import ( "net/http" "net/url" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type ServerStatusService struct { diff --git a/pkg/services/api/api.go b/pkg/services/api/api.go index 856369b8..6a05f905 100644 --- a/pkg/services/api/api.go +++ b/pkg/services/api/api.go @@ -8,14 +8,17 @@ import ( "runtime/debug" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/dghubble/sling" ) -var version = "development" -var UserAgentString = GetUserAgentString("") +var ( + version = "development" + UserAgentString = GetUserAgentString("") +) // Generic OctopusDeploy API Get Function. func ApiGet(sling *sling.Sling, inputStruct interface{}, path string) (interface{}, error) { diff --git a/pkg/services/api/automation_environment_provider.go b/pkg/services/api/automation_environment_provider.go index ed5338a3..02273718 100644 --- a/pkg/services/api/automation_environment_provider.go +++ b/pkg/services/api/automation_environment_provider.go @@ -44,7 +44,7 @@ var knownEnvironments = map[string][]string{ } func GetAutomationEnvironment(e Environment) string { - var environment = "NoneOrUnknown" + environment := "NoneOrUnknown" for key, variables := range knownEnvironments { for _, v := range variables { if e.Getenv(v) != "" { diff --git a/pkg/services/api/automation_environment_provider_test.go b/pkg/services/api/automation_environment_provider_test.go index 99fa95bb..ba283b46 100644 --- a/pkg/services/api/automation_environment_provider_test.go +++ b/pkg/services/api/automation_environment_provider_test.go @@ -1,9 +1,11 @@ package api_test import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" ) func TestGetAutomationEnvironment_None(t *testing.T) { diff --git a/pkg/services/api/environment.go b/pkg/services/api/environment.go index 101b690a..4fe5ca2b 100644 --- a/pkg/services/api/environment.go +++ b/pkg/services/api/environment.go @@ -6,8 +6,7 @@ type Environment interface { Getenv(key string) string } -type OsEnvironment struct { -} +type OsEnvironment struct{} type MockEnvironment struct { values map[string]string diff --git a/pkg/services/new_service_tests.go b/pkg/services/new_service_tests.go index 228f1c7f..4bda1312 100644 --- a/pkg/services/new_service_tests.go +++ b/pkg/services/new_service_tests.go @@ -3,8 +3,9 @@ package services import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" ) func NewServiceTests(t *testing.T, service IService, uriTemplate string, ServiceName string) { diff --git a/pkg/services/service.go b/pkg/services/service.go index 4a220886..6bd9cf9c 100644 --- a/pkg/services/service.go +++ b/pkg/services/service.go @@ -9,13 +9,14 @@ import ( "net/url" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) // IService defines the contract for all services that communicate with the @@ -281,7 +282,6 @@ func ApiAdd(sling *sling.Sling, inputStruct interface{}, resource interface{}, p octopusDeployError := new(core.APIError) resp, err := request.Receive(resource, &octopusDeployError) - if err != nil { return nil, err } diff --git a/pkg/spaces/space.go b/pkg/spaces/space.go index 4fe520ff..ba62b9c5 100644 --- a/pkg/spaces/space.go +++ b/pkg/spaces/space.go @@ -1,8 +1,9 @@ package spaces import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type Space struct { diff --git a/pkg/spaces/space_service.go b/pkg/spaces/space_service.go index 3d18895e..a1bbbbe3 100644 --- a/pkg/spaces/space_service.go +++ b/pkg/spaces/space_service.go @@ -3,6 +3,8 @@ package spaces import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -10,7 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type SpaceService struct { diff --git a/pkg/spaces/space_service_test.go b/pkg/spaces/space_service_test.go index 89ec0faf..bc76d1ca 100644 --- a/pkg/spaces/space_service_test.go +++ b/pkg/spaces/space_service_test.go @@ -3,11 +3,12 @@ package spaces import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createSpaceService(t *testing.T) *SpaceService { diff --git a/pkg/subscriptions/subscription.go b/pkg/subscriptions/subscription.go index 6ac294c7..df50c4bc 100644 --- a/pkg/subscriptions/subscription.go +++ b/pkg/subscriptions/subscription.go @@ -3,9 +3,10 @@ package subscriptions import ( "time" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) // TeamsChannelSubscriptionTarget is one Microsoft Teams destination a subscription notifies. diff --git a/pkg/subscriptions/subscription_service.go b/pkg/subscriptions/subscription_service.go index 3be504a6..f5d9ef5f 100644 --- a/pkg/subscriptions/subscription_service.go +++ b/pkg/subscriptions/subscription_service.go @@ -1,12 +1,13 @@ package subscriptions import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type SubscriptionService struct { diff --git a/pkg/subscriptions/subscription_test.go b/pkg/subscriptions/subscription_test.go index d504637c..a957e70b 100644 --- a/pkg/subscriptions/subscription_test.go +++ b/pkg/subscriptions/subscription_test.go @@ -4,9 +4,10 @@ import ( "encoding/json" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/subscriptions" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/subscriptions" ) func TestNewSubscriptionSlackDefaults(t *testing.T) { diff --git a/pkg/tagsets/tag_set_service.go b/pkg/tagsets/tag_set_service.go index ed0e2e98..4b7eb518 100644 --- a/pkg/tagsets/tag_set_service.go +++ b/pkg/tagsets/tag_set_service.go @@ -3,13 +3,14 @@ package tagsets import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type TagSetService struct { @@ -115,7 +116,6 @@ func (s *TagSetService) GetByName(name string) (*TagSet, error) { } collection, err := s.GetAll() - if err != nil { return nil, err } diff --git a/pkg/tagsets/tag_set_service_test.go b/pkg/tagsets/tag_set_service_test.go index 320c683a..0cbbaaf9 100644 --- a/pkg/tagsets/tag_set_service_test.go +++ b/pkg/tagsets/tag_set_service_test.go @@ -3,11 +3,12 @@ package tagsets import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func TestNewTagSetService(t *testing.T) { diff --git a/pkg/tasks/task_service.go b/pkg/tasks/task_service.go index 28f8d7cc..e377977d 100644 --- a/pkg/tasks/task_service.go +++ b/pkg/tasks/task_service.go @@ -1,13 +1,14 @@ package tasks import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type TaskService struct { diff --git a/pkg/teammembership/team_membership_service.go b/pkg/teammembership/team_membership_service.go index d00ed2fe..4cd5f1fd 100644 --- a/pkg/teammembership/team_membership_service.go +++ b/pkg/teammembership/team_membership_service.go @@ -1,9 +1,10 @@ package teammembership import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type TeamMembershipService struct { diff --git a/pkg/teams/team.go b/pkg/teams/team.go index 80af5768..126cc647 100644 --- a/pkg/teams/team.go +++ b/pkg/teams/team.go @@ -1,9 +1,10 @@ package teams import ( + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type Team struct { diff --git a/pkg/teams/team_service.go b/pkg/teams/team_service.go index 54e033ba..ca575cd9 100644 --- a/pkg/teams/team_service.go +++ b/pkg/teams/team_service.go @@ -1,6 +1,8 @@ package teams import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -10,7 +12,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type TeamService struct { diff --git a/pkg/teams/team_service_test.go b/pkg/teams/team_service_test.go index 96051165..dbe82c88 100644 --- a/pkg/teams/team_service_test.go +++ b/pkg/teams/team_service_test.go @@ -3,11 +3,12 @@ package teams import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createTeamService(t *testing.T) *TeamService { diff --git a/pkg/tenants/tenant.go b/pkg/tenants/tenant.go index c13c737e..0fa10dcf 100644 --- a/pkg/tenants/tenant.go +++ b/pkg/tenants/tenant.go @@ -1,8 +1,9 @@ package tenants import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type Tenant struct { diff --git a/pkg/tenants/tenant_service.go b/pkg/tenants/tenant_service.go index a1b6fef9..ae1fd97e 100644 --- a/pkg/tenants/tenant_service.go +++ b/pkg/tenants/tenant_service.go @@ -3,6 +3,8 @@ package tenants import ( "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -12,7 +14,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type TenantService struct { @@ -321,8 +322,10 @@ func GetAll(client newclient.Client, spaceID string) ([]*Tenant, error) { return newclient.GetAll[Tenant](client, template, spaceID) } -const tenantProjectVariableTemplate = "/api/{spaceId}/tenants/{id}/projectvariables?IncludeMissingVariables={includeMissingVariables}" -const tenantCommonVariableTemplate = "/api/{spaceId}/tenants/{id}/commonvariables?IncludeMissingVariables={includeMissingVariables}" +const ( + tenantProjectVariableTemplate = "/api/{spaceId}/tenants/{id}/projectvariables?IncludeMissingVariables={includeMissingVariables}" + tenantCommonVariableTemplate = "/api/{spaceId}/tenants/{id}/commonvariables?IncludeMissingVariables={includeMissingVariables}" +) // GetProjectVariables returns all tenant project variables. If an error occurs, it returns nil. func GetProjectVariables(client newclient.Client, query variables.GetTenantProjectVariablesQuery) (*variables.GetTenantProjectVariablesResponse, error) { diff --git a/pkg/tenants/tenant_service_test.go b/pkg/tenants/tenant_service_test.go index bde94b0b..e397227d 100644 --- a/pkg/tenants/tenant_service_test.go +++ b/pkg/tenants/tenant_service_test.go @@ -3,11 +3,12 @@ package tenants import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func TestNewTenantService(t *testing.T) { diff --git a/pkg/triggers/project_trigger.go b/pkg/triggers/project_trigger.go index 0ab65183..d7fab7e9 100644 --- a/pkg/triggers/project_trigger.go +++ b/pkg/triggers/project_trigger.go @@ -3,11 +3,12 @@ package triggers import ( "encoding/json" + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/filters" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type ProjectTrigger struct { diff --git a/pkg/triggers/project_trigger_service.go b/pkg/triggers/project_trigger_service.go index a1c57c54..53be6b85 100644 --- a/pkg/triggers/project_trigger_service.go +++ b/pkg/triggers/project_trigger_service.go @@ -2,13 +2,14 @@ package triggers import ( "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" + + "github.com/dghubble/sling" "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ProjectTriggerService struct { @@ -33,7 +34,6 @@ func (s *ProjectTriggerService) GetByID(id string) (*ProjectTrigger, error) { } path, err := services.GetByIDPath(s, id) - if err != nil { return nil, err } @@ -50,7 +50,6 @@ func (s *ProjectTriggerService) GetByProjectID(id string) ([]*ProjectTrigger, er var triggersByProject []*ProjectTrigger triggers, err := s.GetAll() - if err != nil { return nil, err } diff --git a/pkg/triggers/project_trigger_service_test.go b/pkg/triggers/project_trigger_service_test.go index 60cd5d9a..7ad90737 100644 --- a/pkg/triggers/project_trigger_service_test.go +++ b/pkg/triggers/project_trigger_service_test.go @@ -3,11 +3,12 @@ package triggers import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func TestNewProjectTriggerService(t *testing.T) { diff --git a/pkg/triggers/project_trigger_test.go b/pkg/triggers/project_trigger_test.go index 87b06587..af8fd6eb 100644 --- a/pkg/triggers/project_trigger_test.go +++ b/pkg/triggers/project_trigger_test.go @@ -7,13 +7,14 @@ import ( "time" "github.com/MakeNowJust/heredoc/v2" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/filters" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/triggers" - "github.com/stretchr/testify/assert" ) func TestTriggerJsonSerialization(t *testing.T) { @@ -42,7 +43,7 @@ func TestTriggerJsonSerialization(t *testing.T) { t.Run("deserialize scheduled filter with standard go timeformat", func(t *testing.T) { data := []byte(`{"Action":{"ShouldRedeployWhenMachineHasBeenDeployedTo":true,"ActionType":"AutoDeploy"},"Filter":{"MonthlyScheduleType":"DayOfMonth","DayNumberOfMonth":"1","StartTime":"2021-12-14T09:00:00Z","Timezone":"Asia/Kuala_Lumpur","FilterType":"DaysPerMonthSchedule"},"Name":"triggerName","ProjectId":"Projects-123"}`) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -70,7 +71,7 @@ func TestTriggerJsonSerialization(t *testing.T) { t.Run("deserialize scheduled filter with an unzoned ISO format with milliseconds", func(t *testing.T) { // 2022.3 server returns this data := []byte(`{"Action":{"ShouldRedeployWhenMachineHasBeenDeployedTo":true,"ActionType":"AutoDeploy"},"Filter":{"MonthlyScheduleType":"DayOfMonth","DayNumberOfMonth":"1","StartTime":"2021-12-14T09:00:00.000","Timezone":"Asia/Kuala_Lumpur","FilterType":"DaysPerMonthSchedule"},"Name":"triggerName","ProjectId":"Projects-123"}`) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -137,7 +138,7 @@ func TestTriggerJsonSerialization(t *testing.T) { "Project": "/api/Spaces-1/projects/Projects-314" } }`)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -212,7 +213,7 @@ func TestTriggerJsonSerialization(t *testing.T) { } } `)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -288,7 +289,7 @@ func TestTriggerJsonSerialization(t *testing.T) { } } `)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -395,7 +396,7 @@ func TestTriggerJsonSerialization(t *testing.T) { } } `)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -455,7 +456,7 @@ func TestTriggerJsonSerialization(t *testing.T) { "Links": {} } `)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) @@ -506,7 +507,7 @@ func TestTriggerJsonSerialization(t *testing.T) { } } `)) - var output = new(triggers.ProjectTrigger) + output := new(triggers.ProjectTrigger) err := json.NewDecoder(bytes.NewReader(data)).Decode(output) assert.Nil(t, err) diff --git a/pkg/triggers/scheduled_project_triggers_service.go b/pkg/triggers/scheduled_project_triggers_service.go index ffe69f61..99f8c746 100644 --- a/pkg/triggers/scheduled_project_triggers_service.go +++ b/pkg/triggers/scheduled_project_triggers_service.go @@ -1,9 +1,10 @@ package triggers import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type ScheduledProjectTriggerService struct { diff --git a/pkg/useronboarding/user_onboarding_service.go b/pkg/useronboarding/user_onboarding_service.go index 00202d81..e102d823 100644 --- a/pkg/useronboarding/user_onboarding_service.go +++ b/pkg/useronboarding/user_onboarding_service.go @@ -1,9 +1,10 @@ package useronboarding import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type UserOnboardingService struct { diff --git a/pkg/userroles/scoped_user_role.go b/pkg/userroles/scoped_user_role.go index 1ff86701..55d8ffef 100644 --- a/pkg/userroles/scoped_user_role.go +++ b/pkg/userroles/scoped_user_role.go @@ -1,8 +1,9 @@ package userroles import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type ScopedUserRole struct { diff --git a/pkg/userroles/scoped_user_role_service.go b/pkg/userroles/scoped_user_role_service.go index 580566e4..a0339258 100644 --- a/pkg/userroles/scoped_user_role_service.go +++ b/pkg/userroles/scoped_user_role_service.go @@ -1,12 +1,13 @@ package userroles import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ScopedUserRoleService struct { diff --git a/pkg/userroles/scoped_user_role_service_test.go b/pkg/userroles/scoped_user_role_service_test.go index 80fd9a48..6347bf30 100644 --- a/pkg/userroles/scoped_user_role_service_test.go +++ b/pkg/userroles/scoped_user_role_service_test.go @@ -3,12 +3,13 @@ package userroles import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createScopedUserRoleService(t *testing.T) *ScopedUserRoleService { diff --git a/pkg/userroles/user_role_service.go b/pkg/userroles/user_role_service.go index 32077730..98ec0372 100644 --- a/pkg/userroles/user_role_service.go +++ b/pkg/userroles/user_role_service.go @@ -1,6 +1,8 @@ package userroles import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -8,7 +10,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type UserRoleService struct { diff --git a/pkg/users/api_key_service.go b/pkg/users/api_key_service.go index ee5365a3..8a6b3b68 100644 --- a/pkg/users/api_key_service.go +++ b/pkg/users/api_key_service.go @@ -3,12 +3,13 @@ package users import ( "fmt" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) // ApiKeyService handles communication with API key-related methods of the Octopus API. diff --git a/pkg/users/api_key_service_test.go b/pkg/users/api_key_service_test.go index c4d3cfb4..39c7c32f 100644 --- a/pkg/users/api_key_service_test.go +++ b/pkg/users/api_key_service_test.go @@ -3,11 +3,12 @@ package users import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" ) func TestNewAPIKeyService(t *testing.T) { diff --git a/pkg/users/user_service.go b/pkg/users/user_service.go index 8dc3c666..058ff405 100644 --- a/pkg/users/user_service.go +++ b/pkg/users/user_service.go @@ -1,6 +1,9 @@ package users import ( + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/newclient" @@ -10,8 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) type UserService struct { @@ -43,8 +44,8 @@ func NewUserService( signInPath string, signOutPath string, userAuthenticationPath string, - userIdentityMetadataPath string) *UserService { - + userIdentityMetadataPath string, +) *UserService { return &UserService{ apiKeysPath: apiKeysPath, authenticateOctopusIDPath: authenticateOctopusIDPath, diff --git a/pkg/users/user_service_test.go b/pkg/users/user_service_test.go index 3acb2407..bc56d92f 100644 --- a/pkg/users/user_service_test.go +++ b/pkg/users/user_service_test.go @@ -3,11 +3,12 @@ package users import ( "testing" + "github.com/dghubble/sling" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" - "github.com/stretchr/testify/require" ) func createUserService(t *testing.T) *UserService { @@ -56,7 +57,8 @@ func TestUserService(t *testing.T) { userAuthenticationPath string userIdentityMetadataPath string }{ - {"NilClient", + { + "NilClient", ServiceFunction, nil, uriTemplate, @@ -68,8 +70,10 @@ func TestUserService(t *testing.T) { signInPath, signOutPath, userAuthenticationPath, - userIdentityMetadataPath}, - {"EmptyURITemplate", + userIdentityMetadataPath, + }, + { + "EmptyURITemplate", ServiceFunction, client, "", @@ -81,8 +85,10 @@ func TestUserService(t *testing.T) { signInPath, signOutPath, userAuthenticationPath, - userIdentityMetadataPath}, - {"URITemplateWithWhitespace", + userIdentityMetadataPath, + }, + { + "URITemplateWithWhitespace", ServiceFunction, client, " ", @@ -94,7 +100,8 @@ func TestUserService(t *testing.T) { signInPath, signOutPath, userAuthenticationPath, - userIdentityMetadataPath}, + userIdentityMetadataPath, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { diff --git a/pkg/variables/library_variable_set.go b/pkg/variables/library_variable_set.go index f418c593..2523adaf 100644 --- a/pkg/variables/library_variable_set.go +++ b/pkg/variables/library_variable_set.go @@ -1,9 +1,10 @@ package variables import ( + "github.com/go-playground/validator/v10" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" - "github.com/go-playground/validator/v10" ) type LibraryVariableSet struct { diff --git a/pkg/variables/library_variable_set_service.go b/pkg/variables/library_variable_set_service.go index 462a7990..75ecf433 100644 --- a/pkg/variables/library_variable_set_service.go +++ b/pkg/variables/library_variable_set_service.go @@ -1,12 +1,13 @@ package variables import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type LibraryVariableSetService struct { diff --git a/pkg/variables/library_variable_set_service_test.go b/pkg/variables/library_variable_set_service_test.go index fc9b5717..7e656529 100644 --- a/pkg/variables/library_variable_set_service_test.go +++ b/pkg/variables/library_variable_set_service_test.go @@ -3,12 +3,13 @@ package variables import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createLibraryVariableSetService(t *testing.T) *LibraryVariableSetService { diff --git a/pkg/variables/script_module.go b/pkg/variables/script_module.go index 57b60ef4..236cc6cb 100644 --- a/pkg/variables/script_module.go +++ b/pkg/variables/script_module.go @@ -3,8 +3,9 @@ package variables import ( "encoding/json" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type ScriptModule struct { diff --git a/pkg/variables/script_module_service.go b/pkg/variables/script_module_service.go index b795e556..a8b95b3b 100644 --- a/pkg/variables/script_module_service.go +++ b/pkg/variables/script_module_service.go @@ -5,12 +5,13 @@ import ( "math" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type ScriptModuleService struct { diff --git a/pkg/variables/script_module_service_test.go b/pkg/variables/script_module_service_test.go index d64e56c9..c6e6be43 100644 --- a/pkg/variables/script_module_service_test.go +++ b/pkg/variables/script_module_service_test.go @@ -3,12 +3,13 @@ package variables import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createScriptModuleService(t *testing.T) *ScriptModuleService { diff --git a/pkg/variables/tenant_variable_service.go b/pkg/variables/tenant_variable_service.go index 7259f913..f3ee4b06 100644 --- a/pkg/variables/tenant_variable_service.go +++ b/pkg/variables/tenant_variable_service.go @@ -1,10 +1,11 @@ package variables import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" - "github.com/dghubble/sling" ) type TenantVariableService struct { diff --git a/pkg/variables/variable_service.go b/pkg/variables/variable_service.go index 080a1850..c0ccfeb2 100644 --- a/pkg/variables/variable_service.go +++ b/pkg/variables/variable_service.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -11,7 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" ) type errInvalidVariableServiceParameter struct { diff --git a/pkg/variables/variable_service_test.go b/pkg/variables/variable_service_test.go index 03d7640b..1e161d5b 100644 --- a/pkg/variables/variable_service_test.go +++ b/pkg/variables/variable_service_test.go @@ -3,10 +3,11 @@ package variables import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func TestNewVariableService(t *testing.T) { diff --git a/pkg/workerpools/worker_pool.go b/pkg/workerpools/worker_pool.go index 67ec3bda..50eff909 100644 --- a/pkg/workerpools/worker_pool.go +++ b/pkg/workerpools/worker_pool.go @@ -1,9 +1,10 @@ package workerpools import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) // IWorkerPool defines the interface for worker pools. @@ -135,5 +136,7 @@ func (w *workerPool) Validate() error { return v.Struct(w) } -var _ resources.IHasName = &workerPool{} -var _ IWorkerPool = &workerPool{} +var ( + _ resources.IHasName = &workerPool{} + _ IWorkerPool = &workerPool{} +) diff --git a/pkg/workerpools/worker_pool_resource.go b/pkg/workerpools/worker_pool_resource.go index 8d9e3104..81280533 100644 --- a/pkg/workerpools/worker_pool_resource.go +++ b/pkg/workerpools/worker_pool_resource.go @@ -1,9 +1,10 @@ package workerpools import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10/non-standard/validators" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) type WorkerPoolResource struct { diff --git a/pkg/workerpools/worker_pool_service.go b/pkg/workerpools/worker_pool_service.go index b1c7ca95..b67f4f28 100644 --- a/pkg/workerpools/worker_pool_service.go +++ b/pkg/workerpools/worker_pool_service.go @@ -4,6 +4,9 @@ import ( "fmt" "strings" + "github.com/dghubble/sling" + "github.com/google/go-querystring/query" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -13,8 +16,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api" "github.com/OctopusDeploy/go-octopusdeploy/v2/uritemplates" - "github.com/dghubble/sling" - "github.com/google/go-querystring/query" ) type WorkerPoolService struct { diff --git a/pkg/workerpools/worker_pool_service_test.go b/pkg/workerpools/worker_pool_service_test.go index 2eb95f53..22faba53 100644 --- a/pkg/workerpools/worker_pool_service_test.go +++ b/pkg/workerpools/worker_pool_service_test.go @@ -3,12 +3,13 @@ package workerpools import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" "github.com/dghubble/sling" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) func createWorkerPoolService(t *testing.T) *WorkerPoolService { diff --git a/pkg/workerpools/worker_pool_utilities.go b/pkg/workerpools/worker_pool_utilities.go index 436a6d14..b0a8b356 100644 --- a/pkg/workerpools/worker_pool_utilities.go +++ b/pkg/workerpools/worker_pool_utilities.go @@ -23,17 +23,17 @@ func ToWorkerPool(workerPoolResource *WorkerPoolResource) (IWorkerPool, error) { workerPool = NewStaticWorkerPool(workerPoolResource.GetName()) } - workerPool.SetCanAddWorkers((workerPoolResource.GetCanAddWorkers())) - workerPool.SetDescription((workerPoolResource.GetDescription())) + workerPool.SetCanAddWorkers(workerPoolResource.GetCanAddWorkers()) + workerPool.SetDescription(workerPoolResource.GetDescription()) workerPool.SetID(workerPoolResource.GetID()) - workerPool.SetIsDefault((workerPoolResource.GetIsDefault())) + workerPool.SetIsDefault(workerPoolResource.GetIsDefault()) workerPool.SetLinks(workerPoolResource.GetLinks()) workerPool.SetModifiedBy(workerPoolResource.GetModifiedBy()) workerPool.SetModifiedOn(workerPoolResource.GetModifiedOn()) - workerPool.SetName((workerPoolResource.GetName())) - workerPool.SetSpaceID((workerPoolResource.GetSpaceID())) - workerPool.SetSortOrder((workerPoolResource.GetSortOrder())) - workerPool.SetWorkerPoolType((workerPoolResource.GetWorkerPoolType())) + workerPool.SetName(workerPoolResource.GetName()) + workerPool.SetSpaceID(workerPoolResource.GetSpaceID()) + workerPool.SetSortOrder(workerPoolResource.GetSortOrder()) + workerPool.SetWorkerPoolType(workerPoolResource.GetWorkerPoolType()) return workerPool, nil } @@ -65,17 +65,17 @@ func ToWorkerPoolResource(workerPool IWorkerPool) (*WorkerPoolResource, error) { // nothing to copy } - workerPoolResource.SetCanAddWorkers((workerPool.GetCanAddWorkers())) - workerPoolResource.SetDescription((workerPool.GetDescription())) + workerPoolResource.SetCanAddWorkers(workerPool.GetCanAddWorkers()) + workerPoolResource.SetDescription(workerPool.GetDescription()) workerPoolResource.SetID(workerPool.GetID()) - workerPoolResource.SetIsDefault((workerPool.GetIsDefault())) + workerPoolResource.SetIsDefault(workerPool.GetIsDefault()) workerPoolResource.SetLinks(workerPool.GetLinks()) workerPoolResource.SetModifiedBy(workerPool.GetModifiedBy()) workerPoolResource.SetModifiedOn(workerPool.GetModifiedOn()) - workerPoolResource.SetName((workerPool.GetName())) - workerPoolResource.SetSpaceID((workerPool.GetSpaceID())) - workerPoolResource.SetSortOrder((workerPool.GetSortOrder())) - workerPoolResource.SetWorkerPoolType((workerPool.GetWorkerPoolType())) + workerPoolResource.SetName(workerPool.GetName()) + workerPoolResource.SetSpaceID(workerPool.GetSpaceID()) + workerPoolResource.SetSortOrder(workerPool.GetSortOrder()) + workerPoolResource.SetWorkerPoolType(workerPool.GetWorkerPoolType()) return workerPoolResource, nil } diff --git a/pkg/workertoolslatestimages/worker_tools_latest_images_service.go b/pkg/workertoolslatestimages/worker_tools_latest_images_service.go index 52e78711..9f848bb8 100644 --- a/pkg/workertoolslatestimages/worker_tools_latest_images_service.go +++ b/pkg/workertoolslatestimages/worker_tools_latest_images_service.go @@ -1,9 +1,10 @@ package workertoolslatestimages import ( + "github.com/dghubble/sling" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" - "github.com/dghubble/sling" ) type WorkerToolsLatestImageService struct { diff --git a/test/e2e/account_service_test.go b/test/e2e/account_service_test.go index 15e721ef..634228f2 100644 --- a/test/e2e/account_service_test.go +++ b/test/e2e/account_service_test.go @@ -3,13 +3,14 @@ package e2e import ( "testing" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/google/uuid" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestAmazonWebServicesAccount(t *testing.T, client *client.Client) accounts.IAccount { diff --git a/test/e2e/action_template_service_test.go b/test/e2e/action_template_service_test.go index e0160361..a2868fba 100644 --- a/test/e2e/action_template_service_test.go +++ b/test/e2e/action_template_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func createActionTemplate(t *testing.T) *actiontemplates.ActionTemplate { diff --git a/test/e2e/api_keys_test.go b/test/e2e/api_keys_test.go index f3cc15ba..2dddd461 100644 --- a/test/e2e/api_keys_test.go +++ b/test/e2e/api_keys_test.go @@ -4,11 +4,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateSimpleTestUser(t *testing.T, client *client.Client) *users.User { diff --git a/test/e2e/artifact_service_test.go b/test/e2e/artifact_service_test.go index ab4e76a6..1f54e8a2 100644 --- a/test/e2e/artifact_service_test.go +++ b/test/e2e/artifact_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/artifacts" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestArtifact(t *testing.T, client *client.Client) *artifacts.Artifact { @@ -42,7 +43,6 @@ func DeleteTestArtifact(t *testing.T, client *client.Client, artifact *artifacts deletedArtifact, err := client.Artifacts.GetByID(artifact.GetID()) assert.Error(t, err) assert.Nil(t, deletedArtifact) - } func AssertEqualArtifacts(t *testing.T, expected *artifacts.Artifact, actual *artifacts.Artifact) { diff --git a/test/e2e/build_information_test.go b/test/e2e/build_information_test.go index 72df7456..1ccf93ff 100644 --- a/test/e2e/build_information_test.go +++ b/test/e2e/build_information_test.go @@ -4,13 +4,14 @@ import ( "strings" "testing" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/buildinformation" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" - "github.com/google/uuid" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestSpaceWithCurrentUserAsSpaceManager(t *testing.T, client *client.Client) *spaces.Space { diff --git a/test/e2e/certificate_service_test.go b/test/e2e/certificate_service_test.go index 9563ad80..82f661d8 100644 --- a/test/e2e/certificate_service_test.go +++ b/test/e2e/certificate_service_test.go @@ -6,12 +6,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/certificates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type testCertificate struct { diff --git a/test/e2e/channel_service_test.go b/test/e2e/channel_service_test.go index 553b27de..0c331001 100644 --- a/test/e2e/channel_service_test.go +++ b/test/e2e/channel_service_test.go @@ -4,6 +4,9 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" @@ -11,8 +14,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/parentenvironments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualChannels(t *testing.T, expected *channels.Channel, actual *channels.Channel) { diff --git a/test/e2e/community_action_template_service_test.go b/test/e2e/community_action_template_service_test.go index 51ef2264..6d048b37 100644 --- a/test/e2e/community_action_template_service_test.go +++ b/test/e2e/community_action_template_service_test.go @@ -3,10 +3,11 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" ) func IsEqualCommunityActionTemplates(t *testing.T, expected *actions.CommunityActionTemplate, actual *actions.CommunityActionTemplate) { diff --git a/test/e2e/dashboard_service_test.go b/test/e2e/dashboard_service_test.go index 7fda7ef7..a7dfc7d5 100644 --- a/test/e2e/dashboard_service_test.go +++ b/test/e2e/dashboard_service_test.go @@ -7,8 +7,9 @@ import ( "net/url" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/dashboard" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/dashboard" ) // These tests read whatever the target instance happens to hold rather than diff --git a/test/e2e/deployment_freeze_service_test.go b/test/e2e/deployment_freeze_service_test.go index 264172cf..695728cf 100644 --- a/test/e2e/deployment_freeze_service_test.go +++ b/test/e2e/deployment_freeze_service_test.go @@ -1,16 +1,18 @@ package e2e import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deploymentfreezes" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "testing" - "time" ) type testResources struct { diff --git a/test/e2e/deployment_process_test.go b/test/e2e/deployment_process_test.go index 8a1f34f2..7204e308 100644 --- a/test/e2e/deployment_process_test.go +++ b/test/e2e/deployment_process_test.go @@ -3,13 +3,14 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestDeploymentProcess(t *testing.T, client *client.Client, project *projects.Project) *deployments.DeploymentProcess { diff --git a/test/e2e/environment_service_test.go b/test/e2e/environment_service_test.go index 9764e3b2..bee51a26 100644 --- a/test/e2e/environment_service_test.go +++ b/test/e2e/environment_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestEnvironment(t *testing.T, client *client.Client) *environments.Environment { diff --git a/test/e2e/ephemeral_environment_service_test.go b/test/e2e/ephemeral_environment_service_test.go index 5bf3351b..d44f537a 100644 --- a/test/e2e/ephemeral_environment_service_test.go +++ b/test/e2e/ephemeral_environment_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/ephemeralenvironments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/stretchr/testify/require" ) func TestEnvironmentServiceCreateEphemeralEnvironment(t *testing.T) { diff --git a/test/e2e/event_service_test.go b/test/e2e/event_service_test.go index 713894df..06830eaf 100644 --- a/test/e2e/event_service_test.go +++ b/test/e2e/event_service_test.go @@ -3,9 +3,10 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/events" ) func TestEventsService(t *testing.T) { diff --git a/test/e2e/feed_service_test.go b/test/e2e/feed_service_test.go index 98575dca..ee1c56fe 100644 --- a/test/e2e/feed_service_test.go +++ b/test/e2e/feed_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualFeeds(t *testing.T, expected feeds.IFeed, actual feeds.IFeed) { @@ -136,7 +137,6 @@ func CreateTestS3Feed(t *testing.T, client *client.Client) feeds.IFeed { require.NoError(t, err) return resource - } func DeleteTestFeed(t *testing.T, client *client.Client, feed feeds.IFeed) { @@ -272,7 +272,6 @@ func TestFeedServiceCRUD(t *testing.T) { actual, err = client.Feeds.Update(expected) require.NoError(t, err) AssertEqualFeeds(t, expected, actual) - } // TODO: fix test diff --git a/test/e2e/git_credential_service_test.go b/test/e2e/git_credential_service_test.go index 13b437fe..7f48e8d9 100644 --- a/test/e2e/git_credential_service_test.go +++ b/test/e2e/git_credential_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestGitCredentialResource(t *testing.T, client *client.Client) *credentials.Resource { diff --git a/test/e2e/kubernetes_monitor_test.go b/test/e2e/kubernetes_monitor_test.go index ac0631b6..246acfe7 100644 --- a/test/e2e/kubernetes_monitor_test.go +++ b/test/e2e/kubernetes_monitor_test.go @@ -4,13 +4,14 @@ import ( "strings" "testing" + "github.com/google/uuid" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/kubernetesmonitors" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" - "github.com/google/uuid" - "github.com/stretchr/testify/require" ) func TestRegisterMonitor(t *testing.T) { @@ -57,7 +58,6 @@ func TestRegisterMonitor(t *testing.T) { _, err = kubernetesmonitors.GetByID(client, client.GetSpaceID(), res.Resource.ID) require.Error(t, err) require.Contains(t, err.Error(), "not found") - } func CreateTestKubernetesDeploymentTarget_NewClient( diff --git a/test/e2e/library_variables_test.go b/test/e2e/library_variables_test.go index 45c096c9..99225ba4 100644 --- a/test/e2e/library_variables_test.go +++ b/test/e2e/library_variables_test.go @@ -1,15 +1,16 @@ package e2e import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateLibraryVariableSet(t *testing.T, client *client.Client) *variables.LibraryVariableSet { diff --git a/test/e2e/lifecycle_service_test.go b/test/e2e/lifecycle_service_test.go index 73682ea8..be598f80 100644 --- a/test/e2e/lifecycle_service_test.go +++ b/test/e2e/lifecycle_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/lifecycles" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualLifecycles(t *testing.T, expected *lifecycles.Lifecycle, actual *lifecycles.Lifecycle) { diff --git a/test/e2e/machine_service_test.go b/test/e2e/machine_service_test.go index 02b5fe8f..d7f80084 100644 --- a/test/e2e/machine_service_test.go +++ b/test/e2e/machine_service_test.go @@ -6,13 +6,14 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestDeploymentTarget(t *testing.T, client *client.Client, environment *environments.Environment) *machines.DeploymentTarget { diff --git a/test/e2e/package_service_test.go b/test/e2e/package_service_test.go index 10f948fb..1545f254 100644 --- a/test/e2e/package_service_test.go +++ b/test/e2e/package_service_test.go @@ -3,15 +3,17 @@ package e2e import ( "archive/zip" "bytes" - cryptoRand "crypto/rand" "fmt" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + cryptoRand "crypto/rand" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/packages" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) // UploadRandomTestPackage uses the V1 Upload method in go-octopusdeploy. It does not support delta compression @@ -21,7 +23,7 @@ func UploadRandomTestPackage(t *testing.T, client *client.Client) (*packages.Pac } require.NotNil(t, client) - var fileName = fmt.Sprintf("%s.1.0.0.zip", internal.GetRandomString(8)) + fileName := fmt.Sprintf("%s.1.0.0.zip", internal.GetRandomString(8)) // octopus expects packages to be zip files, best we make a zip zipFileBytes := createZip(t, zippedFile{ @@ -115,7 +117,7 @@ func TestPackageServiceUploadDelta_NotEfficient(t *testing.T) { require.NotNil(t, octopus) pkgName := "delta_" + internal.GetRandomString(8) - var fileName = fmt.Sprintf("%s.1.0.0.zip", pkgName) + fileName := fmt.Sprintf("%s.1.0.0.zip", pkgName) zipFileBytes1 := createZip(t, zippedFile{ name: "content.txt", @@ -136,7 +138,7 @@ func TestPackageServiceUploadDelta_NotEfficient(t *testing.T) { assert.Equal(t, packages.DeltaBehaviourNoPreviousFile, initialResponse.UploadInfo.DeltaBehaviour) - var fileName2 = fmt.Sprintf("%s.2.0.0.zip", pkgName) + fileName2 := fmt.Sprintf("%s.2.0.0.zip", pkgName) // because the zip files are tiny here, the delta ends up larger than the zip so should produce the "not efficient" // outcome. We need bigger files for Delta to work @@ -175,7 +177,7 @@ func TestPackageServiceUploadDelta_UploadedDelta(t *testing.T) { require.NotNil(t, octopus) pkgName := "delta_" + internal.GetRandomString(8) - var fileName = fmt.Sprintf("%s.1.0.0.zip", pkgName) + fileName := fmt.Sprintf("%s.1.0.0.zip", pkgName) // we need a bigger file to make the delta worthwhile. Random so it shouldn't compress too much randomContent1 := make([]byte, 512*1024) @@ -201,7 +203,7 @@ func TestPackageServiceUploadDelta_UploadedDelta(t *testing.T) { assert.Equal(t, packages.DeltaBehaviourNoPreviousFile, initialResponse.UploadInfo.DeltaBehaviour) - var fileName2 = fmt.Sprintf("%s.2.0.0.zip", pkgName) + fileName2 := fmt.Sprintf("%s.2.0.0.zip", pkgName) randomContent2 := make([]byte, 512*1024) _, err = cryptoRand.Read(randomContent2) diff --git a/test/e2e/parent_environment_service_test.go b/test/e2e/parent_environment_service_test.go index 946086d1..1f6ec44d 100644 --- a/test/e2e/parent_environment_service_test.go +++ b/test/e2e/parent_environment_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/parentenvironments" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateParentEnvironment(t *testing.T, client *client.Client) *parentenvironments.ParentEnvironment { diff --git a/test/e2e/project_group_service_test.go b/test/e2e/project_group_service_test.go index 992c06f3..ace0c806 100644 --- a/test/e2e/project_group_service_test.go +++ b/test/e2e/project_group_service_test.go @@ -4,11 +4,12 @@ import ( // "fmt" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualProjectGroups(t *testing.T, expected *projectgroups.ProjectGroup, actual *projectgroups.ProjectGroup) { diff --git a/test/e2e/project_service_test.go b/test/e2e/project_service_test.go index 49cf8884..9eed5bf3 100644 --- a/test/e2e/project_service_test.go +++ b/test/e2e/project_service_test.go @@ -4,6 +4,9 @@ import ( "net/url" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -12,8 +15,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualProjects(t *testing.T, expected *projects.Project, actual *projects.Project) { diff --git a/test/e2e/project_test.go b/test/e2e/project_test.go index 4958cdab..9f29fdd0 100644 --- a/test/e2e/project_test.go +++ b/test/e2e/project_test.go @@ -3,9 +3,10 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actiontemplates" ) func CreateActionTemplateParameter() actiontemplates.ActionTemplateParameter { diff --git a/test/e2e/project_trigger_test.go b/test/e2e/project_trigger_test.go index b3f84145..7e94e794 100644 --- a/test/e2e/project_trigger_test.go +++ b/test/e2e/project_trigger_test.go @@ -4,6 +4,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/actions" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" @@ -11,8 +14,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/filters" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/triggers" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualProjectTriggers(t *testing.T, expected *triggers.ProjectTrigger, actual *triggers.ProjectTrigger) { diff --git a/test/e2e/rate_limiting_policy_service_test.go b/test/e2e/rate_limiting_policy_service_test.go index a5caeb95..f5ec13f9 100644 --- a/test/e2e/rate_limiting_policy_service_test.go +++ b/test/e2e/rate_limiting_policy_service_test.go @@ -3,10 +3,11 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/ratelimitingpolicies" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/ratelimitingpolicies" ) func TestListRateLimitingPolicies(t *testing.T) { diff --git a/test/e2e/release_service_test.go b/test/e2e/release_service_test.go index 06f9cb24..1a563ad1 100644 --- a/test/e2e/release_service_test.go +++ b/test/e2e/release_service_test.go @@ -5,6 +5,9 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" @@ -13,8 +16,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualReleases(t *testing.T, expected *releases.Release, actual *releases.Release) { @@ -196,12 +197,10 @@ func TestReleaseServiceGetByID(t *testing.T) { assert.NoError(t, err) AssertEqualReleases(t, release, releaseToCompare) } - } func TestReleaseServiceSnapshotVariablesByName(t *testing.T) { - - //Arrange + // Arrange octopusClient := getOctopusClient() require.NotNil(t, octopusClient) @@ -265,8 +264,7 @@ func TestReleaseServiceSnapshotVariablesByName(t *testing.T) { } func TestReleaseServiceSnapshotVariablesByNameConcurrency(t *testing.T) { - - //Arrange + // Arrange octopusClient := getOctopusClient() require.NotNil(t, octopusClient) diff --git a/test/e2e/root_test.go b/test/e2e/root_test.go index 1f22a8bc..679e684c 100644 --- a/test/e2e/root_test.go +++ b/test/e2e/root_test.go @@ -1,11 +1,12 @@ package e2e import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "testing" "github.com/google/uuid" "github.com/stretchr/testify/assert" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" ) func TestGetRoot(t *testing.T) { diff --git a/test/e2e/runbook_service_test.go b/test/e2e/runbook_service_test.go index 55812e62..807b17ba 100644 --- a/test/e2e/runbook_service_test.go +++ b/test/e2e/runbook_service_test.go @@ -3,14 +3,15 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/lifecycles" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbooks" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualRunbooks(t *testing.T, expected *runbooks.Runbook, actual *runbooks.Runbook) { diff --git a/test/e2e/runbook_snapshot_service_test.go b/test/e2e/runbook_snapshot_service_test.go index 4316b750..fe20fe5b 100644 --- a/test/e2e/runbook_snapshot_service_test.go +++ b/test/e2e/runbook_snapshot_service_test.go @@ -5,6 +5,9 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/configuration" @@ -14,14 +17,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbooks" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualRunbookSnapshots( t *testing.T, expected *runbooks.RunbookSnapshot, - actual *runbooks.RunbookSnapshot) { + actual *runbooks.RunbookSnapshot, +) { // equality cannot be determined through a direct comparison (below) // because APIs like GetByPartialName do not include the fields, // LastModifiedBy and LastModifiedOn @@ -48,8 +50,8 @@ func CreateTestRunbookSnapshot( lifecycle *lifecycles.Lifecycle, projectGroup *projectgroups.ProjectGroup, project *projects.Project, - runbook *runbooks.Runbook) *runbooks.RunbookSnapshot { - + runbook *runbooks.Runbook, +) *runbooks.RunbookSnapshot { require.NotNil(t, lifecycle) require.NotNil(t, projectGroup) require.NotNil(t, project) @@ -130,8 +132,7 @@ func TestRunbookSnapshotServiceAddGetDelete(t *testing.T) { } func TestRunbookSnapshotServiceSnapshotVariablesByName(t *testing.T) { - - //Arrange + // Arrange octopusClient := getOctopusClient() require.NotNil(t, octopusClient) @@ -195,8 +196,7 @@ func TestRunbookSnapshotServiceSnapshotVariablesByName(t *testing.T) { } func TestRunbookSnapshotServiceSnapshotVariablesByNameConcurrency(t *testing.T) { - - //Arrange + // Arrange octopusClient := getOctopusClient() require.NotNil(t, octopusClient) diff --git a/test/e2e/script_module_service_test.go b/test/e2e/script_module_service_test.go index d4609705..086f67c7 100644 --- a/test/e2e/script_module_service_test.go +++ b/test/e2e/script_module_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/scriptmodules" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestScriptModuleAddGetAndDelete_NewClient(t *testing.T) { diff --git a/test/e2e/server_status_service_test.go b/test/e2e/server_status_service_test.go index 30381883..0588b865 100644 --- a/test/e2e/server_status_service_test.go +++ b/test/e2e/server_status_service_test.go @@ -6,8 +6,9 @@ import ( "io" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/serverstatus" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/serverstatus" ) func TestServerStatusServiceGet(t *testing.T) { diff --git a/test/e2e/space_default_retention_policy_service_test.go b/test/e2e/space_default_retention_policy_service_test.go index dcc5d62a..95865113 100644 --- a/test/e2e/space_default_retention_policy_service_test.go +++ b/test/e2e/space_default_retention_policy_service_test.go @@ -3,9 +3,10 @@ package e2e import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/retention" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" - "github.com/stretchr/testify/require" ) func TestReadLifecycleReleaseRetentionDefaultPolicy(t *testing.T) { diff --git a/test/e2e/space_service_test.go b/test/e2e/space_service_test.go index 98ad9925..58d18bea 100644 --- a/test/e2e/space_service_test.go +++ b/test/e2e/space_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestSpace(t *testing.T, client *client.Client) *spaces.Space { diff --git a/test/e2e/tag_service_test.go b/test/e2e/tag_service_test.go index ed3a843b..24a20782 100644 --- a/test/e2e/tag_service_test.go +++ b/test/e2e/tag_service_test.go @@ -3,10 +3,11 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets" ) func CreateTestTag(t *testing.T) *tagsets.Tag { diff --git a/test/e2e/tagset_service_test.go b/test/e2e/tagset_service_test.go index b762ee69..68181fbb 100644 --- a/test/e2e/tagset_service_test.go +++ b/test/e2e/tagset_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestTagSet(t *testing.T, client *client.Client) *tagsets.TagSet { diff --git a/test/e2e/task_service_test.go b/test/e2e/task_service_test.go index 83b9553f..2c837d49 100644 --- a/test/e2e/task_service_test.go +++ b/test/e2e/task_service_test.go @@ -3,10 +3,11 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tasks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tasks" ) func AssertEqualTasks(t *testing.T, expected *tasks.Task, actual tasks.Task) { diff --git a/test/e2e/team_service_test.go b/test/e2e/team_service_test.go index 586b00e3..eae14c03 100644 --- a/test/e2e/team_service_test.go +++ b/test/e2e/team_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/teams" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestTeam(t *testing.T, client *client.Client) *teams.Team { diff --git a/test/e2e/tenant_service_test.go b/test/e2e/tenant_service_test.go index 04f6af1c..d32f3414 100644 --- a/test/e2e/tenant_service_test.go +++ b/test/e2e/tenant_service_test.go @@ -3,6 +3,9 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" @@ -10,8 +13,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualTenants(t *testing.T, expected *tenants.Tenant, actual *tenants.Tenant) { diff --git a/test/e2e/tenant_variables_service_test.go b/test/e2e/tenant_variables_service_test.go index dbaa5157..53915260 100644 --- a/test/e2e/tenant_variables_service_test.go +++ b/test/e2e/tenant_variables_service_test.go @@ -3,8 +3,9 @@ package e2e import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" ) func TestTenantVariablesServiceGetAll(t *testing.T) { diff --git a/test/e2e/user_role_service_test.go b/test/e2e/user_role_service_test.go index ff64fbdd..21f61b3e 100644 --- a/test/e2e/user_role_service_test.go +++ b/test/e2e/user_role_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestUserRole(t *testing.T, client *client.Client) *userroles.UserRole { diff --git a/test/e2e/user_service_test.go b/test/e2e/user_service_test.go index 491dee5d..1ebb338b 100644 --- a/test/e2e/user_service_test.go +++ b/test/e2e/user_service_test.go @@ -3,12 +3,13 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func CreateTestUser(t *testing.T, client *client.Client) *users.User { diff --git a/test/e2e/variable_service_test.go b/test/e2e/variable_service_test.go index ae3b1493..6f258c79 100644 --- a/test/e2e/variable_service_test.go +++ b/test/e2e/variable_service_test.go @@ -4,11 +4,12 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func getTestVariable(name string) *variables.Variable { diff --git a/test/e2e/worker_pool_service_test.go b/test/e2e/worker_pool_service_test.go index f9b20e6b..c443f8a4 100644 --- a/test/e2e/worker_pool_service_test.go +++ b/test/e2e/worker_pool_service_test.go @@ -3,11 +3,12 @@ package e2e import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func AssertEqualWorkerPools(t *testing.T, expected workerpools.IWorkerPool, actual workerpools.IWorkerPool) { @@ -54,7 +55,6 @@ func CreateTestStaticWorkerPool(t *testing.T, client *client.Client) workerpools } func DeleteTestWorkerPool(t *testing.T, client *client.Client, workerPoolId string) { - if client == nil { client = getOctopusClient() } @@ -247,7 +247,6 @@ func CreateTestStaticWorkerPool_NewClient(t *testing.T, client *client.Client) w } func DeleteTestWorkerPool_NewClient(t *testing.T, client *client.Client, workerPool workerpools.IWorkerPool) { - if client == nil { client = getOctopusClient() } diff --git a/test/e2e/worker_service_test.go b/test/e2e/worker_service_test.go index 5ac46225..86bfa173 100644 --- a/test/e2e/worker_service_test.go +++ b/test/e2e/worker_service_test.go @@ -1,16 +1,17 @@ package e2e import ( - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workers" "net/url" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workers" ) func CreateTestWorker(t *testing.T, client *client.Client, workerPool workerpools.IWorkerPool) (*machines.Worker, error) { diff --git a/test/resources/anonymous_git_credential_test.go b/test/resources/anonymous_git_credential_test.go index 9336b540..c1376a0d 100644 --- a/test/resources/anonymous_git_credential_test.go +++ b/test/resources/anonymous_git_credential_test.go @@ -4,9 +4,10 @@ import ( "encoding/json" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" ) func TestAnonymousGitCredentialNew(t *testing.T) { diff --git a/test/resources/build_information_test.go b/test/resources/build_information_test.go index 2186a9ec..9d4d03ed 100644 --- a/test/resources/build_information_test.go +++ b/test/resources/build_information_test.go @@ -5,9 +5,10 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/buildinformation" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/buildinformation" ) func TestBuildInformationCommand(t *testing.T) { diff --git a/test/resources/certificate_test.go b/test/resources/certificate_test.go index ab07f550..75ccdc48 100644 --- a/test/resources/certificate_test.go +++ b/test/resources/certificate_test.go @@ -3,10 +3,11 @@ package resources import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/certificates" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" - "github.com/stretchr/testify/require" ) func TestEmptyCertificateResource(t *testing.T) { diff --git a/test/resources/channel_test.go b/test/resources/channel_test.go index 27839d19..08a2ba13 100644 --- a/test/resources/channel_test.go +++ b/test/resources/channel_test.go @@ -3,10 +3,11 @@ package resources import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" ) func TestEmptyChannel(t *testing.T) { diff --git a/test/resources/deployment_action_test.go b/test/resources/deployment_action_test.go index 9655054e..ee5a3407 100644 --- a/test/resources/deployment_action_test.go +++ b/test/resources/deployment_action_test.go @@ -3,8 +3,9 @@ package resources import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestDeploymentActionProperties(t *testing.T) { diff --git a/test/resources/deployment_target_test.go b/test/resources/deployment_target_test.go index 14c8023e..9aed8b3e 100644 --- a/test/resources/deployment_target_test.go +++ b/test/resources/deployment_target_test.go @@ -5,8 +5,9 @@ import ( "log" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" ) func TestDeploymentTargetMarshalJSON(t *testing.T) { diff --git a/test/resources/display_settings_test.go b/test/resources/display_settings_test.go index 6db6f9c9..044d23e9 100644 --- a/test/resources/display_settings_test.go +++ b/test/resources/display_settings_test.go @@ -3,12 +3,13 @@ package resources import ( "encoding/json" "fmt" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources" ) func TestDisplaySettings(t *testing.T) { diff --git a/test/resources/feed_utilities_test.go b/test/resources/feed_utilities_test.go index 3712e165..7402bad0 100644 --- a/test/resources/feed_utilities_test.go +++ b/test/resources/feed_utilities_test.go @@ -3,9 +3,10 @@ package resources import ( "testing" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" - "github.com/stretchr/testify/require" ) func TestToFeed(t *testing.T) { diff --git a/test/resources/machine_health_check_policy_test.go b/test/resources/machine_health_check_policy_test.go index bc830035..f3f959a2 100644 --- a/test/resources/machine_health_check_policy_test.go +++ b/test/resources/machine_health_check_policy_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" ) func TestMachineHealthCheckPolicyMarshalJSON(t *testing.T) { @@ -31,7 +32,6 @@ func TestMachineHealthCheckPolicyMarshalJSON(t *testing.T) { actual := string(jsonEncoding) jsonassert.New(t).Assertf(actual, machineHealthCheckPolicyAsJSON) - } func TestMachineHealthCheckPolicyUnmarshalJSON(t *testing.T) { diff --git a/test/resources/not_all_validator_test.go b/test/resources/not_all_validator_test.go index ce36c387..33909c2b 100644 --- a/test/resources/not_all_validator_test.go +++ b/test/resources/not_all_validator_test.go @@ -3,9 +3,10 @@ package resources import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" "github.com/go-playground/validator/v10" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/validation" ) type NotAllTestStruct struct { diff --git a/test/resources/project_test.go b/test/resources/project_test.go index aa0b2e44..12f1838d 100644 --- a/test/resources/project_test.go +++ b/test/resources/project_test.go @@ -6,12 +6,13 @@ import ( "net/url" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestProjectNew(t *testing.T) { diff --git a/test/resources/property_value_test.go b/test/resources/property_value_test.go index 40bc219e..a0ca3a1d 100644 --- a/test/resources/property_value_test.go +++ b/test/resources/property_value_test.go @@ -4,9 +4,10 @@ import ( "encoding/json" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestPropertyValueBehaviour(t *testing.T) { diff --git a/test/resources/sensitive_value_test.go b/test/resources/sensitive_value_test.go index e412c387..5ec14e10 100644 --- a/test/resources/sensitive_value_test.go +++ b/test/resources/sensitive_value_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/kinbiko/jsonassert" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" ) func TestSensitiveValueBehaviour(t *testing.T) { diff --git a/test/resources/task_test.go b/test/resources/task_test.go index 3ffe1a6f..566d4876 100644 --- a/test/resources/task_test.go +++ b/test/resources/task_test.go @@ -3,8 +3,9 @@ package resources import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tasks" "github.com/stretchr/testify/require" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tasks" ) func TestNewTask(t *testing.T) { diff --git a/test/resources/username_password_git_credential_test.go b/test/resources/username_password_git_credential_test.go index 71c3338e..15b182d2 100644 --- a/test/resources/username_password_git_credential_test.go +++ b/test/resources/username_password_git_credential_test.go @@ -5,11 +5,12 @@ import ( "fmt" "testing" + "github.com/kinbiko/jsonassert" + "github.com/stretchr/testify/require" + "github.com/OctopusDeploy/go-octopusdeploy/v2/internal" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials" - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" ) func TestUsernamePasswordGitCredentialNew(t *testing.T) { diff --git a/test/resources/variable_scope_test.go b/test/resources/variable_scope_test.go index 86a5ed16..64b48093 100644 --- a/test/resources/variable_scope_test.go +++ b/test/resources/variable_scope_test.go @@ -3,8 +3,9 @@ package resources import ( "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/stretchr/testify/assert" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" ) func TestVariableScope(t *testing.T) { diff --git a/test/testutil.go b/test/testutil.go index f4eda2a6..30461649 100644 --- a/test/testutil.go +++ b/test/testutil.go @@ -4,13 +4,14 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/dghubble/sling" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "strings" "sync/atomic" "testing" + + "github.com/dghubble/sling" + "github.com/stretchr/testify/assert" ) func GoBegin[TResult any](action func() TResult) chan TResult { diff --git a/uritemplates/uritemplates.go b/uritemplates/uritemplates.go index 890806bb..403f2a0b 100644 --- a/uritemplates/uritemplates.go +++ b/uritemplates/uritemplates.go @@ -16,7 +16,6 @@ // values["repo"] = "uritemplates" // expanded, _ := template.Expand(values) // fmt.Printf(expanded) -// package uritemplates import ( @@ -232,9 +231,9 @@ func (self *templatePart) expand(buf *bytes.Buffer, values map[string]interface{ buf.WriteString(self.raw) return nil } - var zeroLen = buf.Len() + zeroLen := buf.Len() buf.WriteString(self.first) - var firstLen = buf.Len() + firstLen := buf.Len() for _, term := range self.terms { value, exists := values[term.name] if !exists { @@ -330,7 +329,7 @@ func (self *templatePart) expandMap(buf *bytes.Buffer, t templateTerm, m map[str if !t.explode { self.expandName(buf, t.name, len(m) == 0) } - var firstLen = buf.Len() + firstLen := buf.Len() for k, value := range m { if firstLen != buf.Len() { if t.explode { From 47d44dd6602cb598eb87225bd28b7baa493775fd Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:25:51 +1000 Subject: [PATCH 3/4] fix: resolve golangci-lint issues Co-Authored-By: Claude Opus 5.5 --- internal/json.go | 2 +- pkg/client/root_service_test.go | 2 +- pkg/credentials/resource.go | 2 +- pkg/environments/environment.go | 2 +- pkg/lifecycles/lifecycle_service_test.go | 2 +- pkg/machines/kubernetes_endpoint.go | 2 +- pkg/machines/machine.go | 2 +- pkg/newclient/update_request.go | 2 +- pkg/packages/multipartstreaming.go | 2 +- pkg/platformhubversioncontrolsettings/resource.go | 2 +- pkg/projects/git_persistence_settings.go | 2 +- pkg/projects/project.go | 4 ++-- pkg/projects/project_service.go | 4 ++-- pkg/runbooks/runbook_process_service_test.go | 6 ------ pkg/scriptmodules/script_module_service.go | 8 ++++---- pkg/variables/library_variable_set_service_test.go | 2 +- pkg/variables/script_module_service_test.go | 2 +- pkg/workerpools/worker_pool_service.go | 4 ++-- test/e2e/action_template_service_test.go | 2 +- test/e2e/script_module_service_test.go | 2 +- test/e2e/tenant_service_test.go | 4 ++-- test/e2e/worker_pool_service_test.go | 4 ++-- test/testutil.go | 6 +++--- uritemplates/uritemplates.go | 4 ++-- 24 files changed, 34 insertions(+), 40 deletions(-) diff --git a/internal/json.go b/internal/json.go index 6e5ee5bc..71db5546 100644 --- a/internal/json.go +++ b/internal/json.go @@ -10,6 +10,6 @@ func PrettyJSON(data interface{}) string { encoder := json.NewEncoder(buffer) encoder.SetIndent("", "\t") - encoder.Encode(data) + _ = encoder.Encode(data) return buffer.String() } diff --git a/pkg/client/root_service_test.go b/pkg/client/root_service_test.go index 77d98a60..d7fe0e1f 100644 --- a/pkg/client/root_service_test.go +++ b/pkg/client/root_service_test.go @@ -17,7 +17,7 @@ func createRootService(t *testing.T) *RootService { } func BenchmarkRootServiceGet(b *testing.B) { - NewRootService(nil, constants.TestURIRoot).Get() + _, _ = NewRootService(nil, constants.TestURIRoot).Get() } func TestRootServiceGet(t *testing.T) { diff --git a/pkg/credentials/resource.go b/pkg/credentials/resource.go index 14eef6f3..b56a6e4c 100644 --- a/pkg/credentials/resource.go +++ b/pkg/credentials/resource.go @@ -87,7 +87,7 @@ func (r *Resource) UnmarshalJSON(b []byte) error { if credentialsProperties["Type"] != nil { t := credentialsProperties["Type"] - json.Unmarshal(*t, &gitCredentialType) + _ = json.Unmarshal(*t, &gitCredentialType) } } diff --git a/pkg/environments/environment.go b/pkg/environments/environment.go index bfe7e8fd..33318d37 100644 --- a/pkg/environments/environment.go +++ b/pkg/environments/environment.go @@ -95,7 +95,7 @@ func (e *Environment) UnmarshalJSON(data []byte) error { if extensionSettingsItem["ExtensionId"] != nil { var extensionID extensions.ExtensionID - json.Unmarshal(*extensionSettingsItem["ExtensionId"], &extensionID) + _ = json.Unmarshal(*extensionSettingsItem["ExtensionId"], &extensionID) switch extensionID { case extensions.JiraExtensionID: diff --git a/pkg/lifecycles/lifecycle_service_test.go b/pkg/lifecycles/lifecycle_service_test.go index 5e7f5072..7f36524a 100644 --- a/pkg/lifecycles/lifecycle_service_test.go +++ b/pkg/lifecycles/lifecycle_service_test.go @@ -141,7 +141,7 @@ func TestLifecycleServiceAdd(t *testing.T) { resource, err = service.Add(resource) assert.NoError(t, err) assert.NotNil(t, resource) - defer service.DeleteByID(resource.GetID()) + defer func() { _ = service.DeleteByID(resource.GetID()) }() } func TestLifecycleServiceGetWithEmptyID(t *testing.T) { diff --git a/pkg/machines/kubernetes_endpoint.go b/pkg/machines/kubernetes_endpoint.go index fc7d6f4d..6293695b 100644 --- a/pkg/machines/kubernetes_endpoint.go +++ b/pkg/machines/kubernetes_endpoint.go @@ -165,7 +165,7 @@ func (k *KubernetesEndpoint) UnmarshalJSON(data []byte) error { if authenticationProperties["AuthenticationType"] != nil { at := authenticationProperties["AuthenticationType"] - json.Unmarshal(*at, &authenticationType) + _ = json.Unmarshal(*at, &authenticationType) } } diff --git a/pkg/machines/machine.go b/pkg/machines/machine.go index e5258b72..b6140a1f 100644 --- a/pkg/machines/machine.go +++ b/pkg/machines/machine.go @@ -141,7 +141,7 @@ func (m *machine) UnmarshalJSON(b []byte) error { if endpointProperties["CommunicationStyle"] != nil { cs := endpointProperties["CommunicationStyle"] - json.Unmarshal(*cs, &communicationStyle) + _ = json.Unmarshal(*cs, &communicationStyle) } } diff --git a/pkg/newclient/update_request.go b/pkg/newclient/update_request.go index f873c28e..921e0bf0 100644 --- a/pkg/newclient/update_request.go +++ b/pkg/newclient/update_request.go @@ -80,7 +80,7 @@ func indexFields(t reflect.Type) fieldIndex { // addFields follows encoding/json's flattening: descend into anonymous fields, // outer names shadow embedded ones. func addFields(t reflect.Type, idx fieldIndex) { - if t.Kind() == reflect.Ptr { + if t.Kind() == reflect.Pointer { t = t.Elem() } if t.Kind() != reflect.Struct { diff --git a/pkg/packages/multipartstreaming.go b/pkg/packages/multipartstreaming.go index b4548129..a63b640a 100644 --- a/pkg/packages/multipartstreaming.go +++ b/pkg/packages/multipartstreaming.go @@ -32,7 +32,7 @@ func NewMultipartFileStreamingReader(fileName string, fileReader io.Reader) *Mul // internally we generate multipart header/boundary data, and write it, combined with the file contents. func (m *MultipartFileStreamingReader) Read(p []byte) (int, error) { pWriter := byteSliceWriter{Buf: p} // it's called pWriter because it writes to p - var err error = nil + var err error // spillover from previous packet if m.spill != nil { diff --git a/pkg/platformhubversioncontrolsettings/resource.go b/pkg/platformhubversioncontrolsettings/resource.go index 058ae83f..b4722e39 100644 --- a/pkg/platformhubversioncontrolsettings/resource.go +++ b/pkg/platformhubversioncontrolsettings/resource.go @@ -61,7 +61,7 @@ func (r *Resource) UnmarshalJSON(b []byte) error { if credentialsProperties["Type"] != nil { t := credentialsProperties["Type"] - json.Unmarshal(*t, &credentialType) + _ = json.Unmarshal(*t, &credentialType) } } diff --git a/pkg/projects/git_persistence_settings.go b/pkg/projects/git_persistence_settings.go index c688295f..450fe630 100644 --- a/pkg/projects/git_persistence_settings.go +++ b/pkg/projects/git_persistence_settings.go @@ -227,7 +227,7 @@ func (p *gitPersistenceSettings) UnmarshalJSON(b []byte) error { if credentialsProperties["Type"] != nil { t := credentialsProperties["Type"] - json.Unmarshal(*t, &gitCredentialType) + _ = json.Unmarshal(*t, &gitCredentialType) } } diff --git a/pkg/projects/project.go b/pkg/projects/project.go index a477ddab..cd5bcf5f 100644 --- a/pkg/projects/project.go +++ b/pkg/projects/project.go @@ -177,7 +177,7 @@ func (p *Project) UnmarshalJSON(data []byte) error { if extensionSettingsItem["ExtensionId"] != nil { var extensionID extensions.ExtensionID - json.Unmarshal(*extensionSettingsItem["ExtensionId"], &extensionID) + _ = json.Unmarshal(*extensionSettingsItem["ExtensionId"], &extensionID) switch extensionID { case extensions.JiraServiceManagementExtensionID: @@ -214,7 +214,7 @@ func (p *Project) UnmarshalJSON(data []byte) error { if persistenceSettingsProperties["Type"] != nil { pst := persistenceSettingsProperties["Type"] - json.Unmarshal(*pst, &persistenceSettingsType) + _ = json.Unmarshal(*pst, &persistenceSettingsType) } } diff --git a/pkg/projects/project_service.go b/pkg/projects/project_service.go index 30339084..4c406d37 100644 --- a/pkg/projects/project_service.go +++ b/pkg/projects/project_service.go @@ -460,7 +460,7 @@ func GetByID(client newclient.Client, spaceID string, id string) (*Project, erro return nil, err } - expandedUri, err := client.URITemplateCache().Expand(projectsTemplate, map[string]any{ + expandedUri, _ := client.URITemplateCache().Expand(projectsTemplate, map[string]any{ "spaceId": spaceID, "id": id, }) @@ -500,7 +500,7 @@ func ConvertToVCS(client newclient.Client, project *Project, commitMessage strin convertToVcs := NewConvertToVcs(commitMessage, initialCommitBranch, gitPersistenceSettings) - expandedUri, err := client.URITemplateCache().Expand(convertToVcsTemplate, map[string]any{ + expandedUri, _ := client.URITemplateCache().Expand(convertToVcsTemplate, map[string]any{ "spaceId": spaceID, "id": project.ID, }) diff --git a/pkg/runbooks/runbook_process_service_test.go b/pkg/runbooks/runbook_process_service_test.go index cd8c4e96..d54bf603 100644 --- a/pkg/runbooks/runbook_process_service_test.go +++ b/pkg/runbooks/runbook_process_service_test.go @@ -9,12 +9,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services" ) -func createRunbookProcessService(t *testing.T) *RunbookProcessService { - service := NewRunbookProcessService(nil, constants.TestURIRunbookProcesses) - services.NewServiceTests(t, service, constants.TestURIRunbookProcesses, constants.ServiceRunbookProcessService) - return service -} - func TestRunbookProcessServiceNew(t *testing.T) { ServiceFunction := NewRunbookProcessService client := &sling.Sling{} diff --git a/pkg/scriptmodules/script_module_service.go b/pkg/scriptmodules/script_module_service.go index 1b549f7e..8d3be2ac 100644 --- a/pkg/scriptmodules/script_module_service.go +++ b/pkg/scriptmodules/script_module_service.go @@ -30,7 +30,7 @@ func Add(client newclient.Client, scriptModule *variables.ScriptModule) (*variab return nil, err } - scriptModuleResponse, err := newclient.Post[variables.ScriptModule](client.HttpSession(), expandedUri, scriptModule) + scriptModuleResponse, _ := newclient.Post[variables.ScriptModule](client.HttpSession(), expandedUri, scriptModule) // update associated variable set; add script body and syntax variablesPath, err := client.URITemplateCache().Expand(uritemplates.Variables, map[string]any{ @@ -113,7 +113,7 @@ func GetByID(client newclient.Client, spaceID string, id string) (*variables.Scr return nil, err } - expandedUri, err := client.URITemplateCache().Expand(uritemplates.LibraryVariableSets, map[string]any{ + expandedUri, _ := client.URITemplateCache().Expand(uritemplates.LibraryVariableSets, map[string]any{ "spaceId": spaceID, "id": id, "contentType": contentType, @@ -183,7 +183,7 @@ func Update(client newclient.Client, scriptModule *variables.ScriptModule) (*var } } - updatedVariableSet, err := newclient.Put[variables.VariableSet](client.HttpSession(), variablesPath, variableSet) + updatedVariableSet, _ := newclient.Put[variables.VariableSet](client.HttpSession(), variablesPath, variableSet) for _, variable := range updatedVariableSet.Variables { if strings.HasPrefix(variable.Name, "Octopus.Script.Module[") { @@ -217,7 +217,7 @@ func DeleteByID(client newclient.Client, spaceID string, id string) error { func populateScriptModuleSyntaxAndBody(client newclient.Client, spaceID string, scriptModuleResponse *variables.ScriptModule) error { // get associated variable set - variablesPath, err := client.URITemplateCache().Expand(uritemplates.Variables, map[string]any{ + variablesPath, _ := client.URITemplateCache().Expand(uritemplates.Variables, map[string]any{ "spaceId": spaceID, "id": scriptModuleResponse.VariableSetID, }) diff --git a/pkg/variables/library_variable_set_service_test.go b/pkg/variables/library_variable_set_service_test.go index 7e656529..59d6e6b6 100644 --- a/pkg/variables/library_variable_set_service_test.go +++ b/pkg/variables/library_variable_set_service_test.go @@ -288,5 +288,5 @@ func TestLibraryVariableSetServiceUpdate(t *testing.T) { expected := CreateTestLibraryVariableSet(t, service) actual := UpdateLibraryVariableSet(t, service, expected) IsEqualLibraryVariableSets(t, expected, actual) - defer DeleteTestLibraryVariableSet(t, service, expected) + defer func() { _ = DeleteTestLibraryVariableSet(t, service, expected) }() } diff --git a/pkg/variables/script_module_service_test.go b/pkg/variables/script_module_service_test.go index c6e6be43..10a54ecb 100644 --- a/pkg/variables/script_module_service_test.go +++ b/pkg/variables/script_module_service_test.go @@ -295,7 +295,7 @@ func TestScriptModuleServiceUpdate(t *testing.T) { require.Nil(t, resource) expected := CreateTestScriptModule(t, service) - defer DeleteTestScriptModule(t, service, expected) + defer func() { _ = DeleteTestScriptModule(t, service, expected) }() expected.ScriptBody = "function Say-Hello()\r\n{\r\n Write-Output \"Hello, World!\"\r\n}\r\n" actual := UpdateScriptModule(t, service, expected) diff --git a/pkg/workerpools/worker_pool_service.go b/pkg/workerpools/worker_pool_service.go index b67f4f28..01dcaf88 100644 --- a/pkg/workerpools/worker_pool_service.go +++ b/pkg/workerpools/worker_pool_service.go @@ -126,7 +126,7 @@ func (s *WorkerPoolService) GetByName(name string) ([]IWorkerPool, error) { return []IWorkerPool{}, err } - response, err := services.GetPagedResponse[WorkerPoolResource](s, path) + response, _ := services.GetPagedResponse[WorkerPoolResource](s, path) return ToWorkerPoolArray(response), nil } @@ -155,7 +155,7 @@ func (s *WorkerPoolService) GetByIdentifier(identifier string) (IWorkerPool, err } // this is a workaround as the api does not support querying via the worker pool slug - allWorkerPools, err := s.GetAll() + allWorkerPools, _ := s.GetAll() for _, pool := range allWorkerPools { if strings.EqualFold(identifier, pool.Slug) { workerPool, err := s.GetByID(pool.ID) diff --git a/test/e2e/action_template_service_test.go b/test/e2e/action_template_service_test.go index a2868fba..cc5c26e4 100644 --- a/test/e2e/action_template_service_test.go +++ b/test/e2e/action_template_service_test.go @@ -64,7 +64,7 @@ func TestActionTemplateServiceAdd(t *testing.T) { resource, err = actiontemplates.Add(client, resource) require.NoError(t, err) require.NotNil(t, resource) - defer client.ActionTemplates.DeleteByID(resource.GetID()) + defer func() { _ = client.ActionTemplates.DeleteByID(resource.GetID()) }() } func TestActionTemplateServiceGetCategories(t *testing.T) { diff --git a/test/e2e/script_module_service_test.go b/test/e2e/script_module_service_test.go index 086f67c7..55587b49 100644 --- a/test/e2e/script_module_service_test.go +++ b/test/e2e/script_module_service_test.go @@ -52,7 +52,7 @@ func TestScriptModuleAddGetAndDelete_NewClient(t *testing.T) { IsEqualScriptModules(t, resource, resourceToCompare) } - DeleteTestScriptModule(t, client, space.GetID(), createdScriptModule) + _ = DeleteTestScriptModule(t, client, space.GetID(), createdScriptModule) } func IsEqualScriptModules(t *testing.T, expected *variables.ScriptModule, actual *variables.ScriptModule) { diff --git a/test/e2e/tenant_service_test.go b/test/e2e/tenant_service_test.go index d32f3414..d95e105a 100644 --- a/test/e2e/tenant_service_test.go +++ b/test/e2e/tenant_service_test.go @@ -139,7 +139,7 @@ func TestTenantAddGetAndDelete(t *testing.T) { require.NoError(t, err) require.NotNil(t, tenantVariables) - tenantVariables, err = client.Tenants.GetVariables(tenant) + tenantVariables, _ = client.Tenants.GetVariables(tenant) require.Equal(t, propertyValue.Value, tenantVariables.ProjectVariables[project.GetID()].Variables[environment.GetID()][project.Templates[0].GetID()].Value) tenantVariables, err = client.Tenants.GetVariables(tenant) @@ -308,7 +308,7 @@ func TestTenantAddGetAndDelete_NewClient(t *testing.T) { require.NoError(t, err) require.NotNil(t, tenantVariables) - tenantVariables, err = client.Tenants.GetVariables(tenant) + tenantVariables, _ = client.Tenants.GetVariables(tenant) require.Equal(t, propertyValue.Value, tenantVariables.ProjectVariables[project.GetID()].Variables[environment.GetID()][project.Templates[0].GetID()].Value) tenantVariables, err = client.Tenants.GetVariables(tenant) diff --git a/test/e2e/worker_pool_service_test.go b/test/e2e/worker_pool_service_test.go index c443f8a4..e01a6335 100644 --- a/test/e2e/worker_pool_service_test.go +++ b/test/e2e/worker_pool_service_test.go @@ -115,7 +115,7 @@ func TestWorkerPoolServiceGet(t *testing.T) { require.NoError(t, err) require.NotNil(t, namedWorkerPools) - wp, err := client.WorkerPools.GetByID(workerPool.ID) + wp, _ := client.WorkerPools.GetByID(workerPool.ID) AssertEqualWorkerPools(t, wp, namedWorkerPools.Items[0]) query = workerpools.WorkerPoolsQuery{ @@ -125,7 +125,7 @@ func TestWorkerPoolServiceGet(t *testing.T) { namedWorkerPools, err = client.WorkerPools.Get(query) require.NoError(t, err) require.NotNil(t, namedWorkerPools) - wp, err = client.WorkerPools.GetByID(workerPool.ID) + wp, _ = client.WorkerPools.GetByID(workerPool.ID) AssertEqualWorkerPools(t, wp, namedWorkerPools.Items[0]) } } diff --git a/test/testutil.go b/test/testutil.go index 30461649..8c0cfa46 100644 --- a/test/testutil.go +++ b/test/testutil.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" "sync/atomic" @@ -140,7 +140,7 @@ type RequestWrapper struct { func (r *RequestWrapper) RespondWithText(body string) { r.Server.Respond(&http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(strings.NewReader(body)), + Body: io.NopCloser(strings.NewReader(body)), ContentLength: int64(len(body)), }, nil) } @@ -158,7 +158,7 @@ func (r *RequestWrapper) RespondWith(responseObject any) { // appropriate status code r.Server.Respond(&http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewReader(body)), + Body: io.NopCloser(bytes.NewReader(body)), ContentLength: int64(len(body)), }, nil) } diff --git a/uritemplates/uritemplates.go b/uritemplates/uritemplates.go index 403f2a0b..b504534e 100644 --- a/uritemplates/uritemplates.go +++ b/uritemplates/uritemplates.go @@ -360,7 +360,7 @@ func (self *templatePart) expandMap(buf *bytes.Buffer, t templateTerm, m map[str func Struct2map(v interface{}) (map[string]interface{}, bool) { value := reflect.ValueOf(v) switch value.Type().Kind() { - case reflect.Ptr: + case reflect.Pointer: return Struct2map(value.Elem().Interface()) case reflect.Struct: m := make(map[string]interface{}) @@ -416,7 +416,7 @@ func isEmptyValue(v reflect.Value) bool { return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 - case reflect.Interface, reflect.Ptr: + case reflect.Interface, reflect.Pointer: return v.IsNil() } From 5220b9bda3022801843f1f8be3f73c829be37b82 Mon Sep 17 00:00:00 2001 From: Eoin Motherway <25342760+YuKitsune@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:15:43 +1000 Subject: [PATCH 4/4] Update README.md Co-authored-by: Alastair Pitts --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47a0f4a7..3f5b6ced 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ The pull request workflow runs golangci-lint, and your pull request must pass it See the [golangci-lint website](https://golangci-lint.run) for the install instructions. -To format the code, and then find lint issues, run these commands in the cli root folder: +To format the code, and then find lint issues, run these commands in the root folder: ```shell golangci-lint fmt ./...