-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 🏗️ adding service connection sdk for easier integration of service connection commands #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Evolve acceptance helpers by migrating internal/test/acc_helpers.go → internal/test/helpers.go and acc_helpers_test.go → helpers_test.go. This keeps history via rename when Git detects it. The new helpers are focused, composable, and avoid monolithic test context coupling. Also removes the old acc_helpers files as part of migration.
Moves polling loop from internal/test/poll.go to internal/util/poll.go (+ tests to util/poll_test.go) for broader reuse across packages. Removes internal/test/poll.go and its tests. This pairs delete and add to assist Git in detecting renames and keeps history better connected.
Adds an internal string builder utility to standardize string accumulation across commands and tests. This improves performance and clarity in code paths that build multi-line or formatted strings.
Adds internal/cmd/serviceendpoint/shared/create_common.go to standardize create flags across service endpoint types. Includes --wait, --timeout, --validate-schema, --validate-connection, --grant-permission-to-all-pipelines, and standard JSON output. Options are stored in context to coordinate between typed commands and shared runners.
Tests for internal/cmd/serviceendpoint/shared/create_common.go ensuring flags are registered, parsed correctly, marked required, and defaults are honored. Covers flag parsing and required validation.
Introduces internal/cmd/serviceendpoint/shared/update_common.go to consolidate update flags and validation for service endpoints across types. Mirrors create_common.go but for update orchestration.
Complements update_common.go with tests verifying flag registration, parsing, required checks, and behavior across update flows.
Adds internal/cmd/serviceendpoint/shared/runner_create.go to orchestrate common create flows like endpoint construction, schema validation, connection testing, pipeline permissions, wait readiness, and JSON/pl table output. Used by typed commands to reduce duplication.
Introduces internal/cmd/serviceendpoint/shared/runner_update.go to centralize update orchestration across service endpoint types, enabling shared handling for patching, validation, connection testing, pipeline permissions, and output.
Adds internal/cmd/serviceendpoint/shared/type_registry.go to register typed configuration handlers (e.g., azurerm, github) and look them up dynamically from CLI args. This decouples command logic from type-specific details and eases onboarding new endpoint kinds.
Introduces internal/cmd/serviceendpoint/shared/type_validate.go using Azure DevOps endpoint metadata to validate authentication schemes and input parameters for service endpoints. Optional via --validate-schema flag.
Adds internal/cmd/serviceendpoint/shared/test_connection.go to call Azure DevOps TestConnection and report ready/failed status with standardized timing and output. Used by create/update runners when requested.
Provides tests for internal/cmd/serviceendpoint/shared/test_connection.go to exercise connection polling and state reporting.
Introduces internal/cmd/serviceendpoint/shared/wait_ready.go which polls service endpoint status until ready or failed, with configurable timeout. Used by shared runners to provide reliable wait semantics.
Adds tests for internal/cmd/serviceendpoint/shared/wait_ready.go to validate waiting behavior, timeout handling, and retries.
Adds README in internal/cmd/serviceendpoint to capture architecture overview, how types are registered, how the shared framework works, and guidance for adding new endpoint types and commands.
Overhauls internal/cmd/serviceendpoint/create/github/create.go to adopt the shared service endpoint framework. Introduces githubConfigurer implementing the configurer interface, delegates orchestration to shared.RunCreate, and removes direct client logic. Reduces code duplication and aligns with type registry pattern.
Updates internal/cmd/serviceendpoint/create/github/create_acc_test.go to import new polling and helpers shape; adjusts assertions to align with updated behavior and new type registration flow.
Adapts internal/cmd/serviceendpoint/create/github/create_test.go to the configurer-based approach, ensuring unit coverage for flag parsing and credential handling via the new structure.
Restructures internal/cmd/serviceendpoint/create/azurerm/create.go to implement azurermConfigurer and delegate to shared.RunCreate. Simplifies command surface, reuses standard flags and runners, and ensures consistent behavior for schema validation, testing, waiting, and output across types.
Adjusts internal/cmd/serviceendpoint/create/azurerm/create_acc_test.go to align with shared runner flow and new test helpers. Updates imports and mocks accordingly.
…ll utility Updates internal/cmd/security/permission/delete/delete_acc_test.go to use internal/util/poll instead of internal/test. Sets a flag indicating this is an acceptance test to gate execution. Minor adjustments to error wrapping and assertion style.
…l utility Migrates internal/cmd/security/permission/reset/reset_acc_test.go from internal/test to internal/util/poll. Adds AcceptanceTest: true and aligns assertions and types with refactored helpers.
…ll utility Updates internal/cmd/security/permission/update/update_acc_test.go to rely on internal/util/poll and updated acceptance helpers. Adds AcceptanceTest gating and modernizes test assertions.
…factored internals Updates internal/cmd/serviceendpoint/delete/delete_acc_test.go to be consistent with new internal/test helpers and internal/util/poll usage. Ensures delete behavior remains correct after framework changes.
Add --timeout, --validate-connection, --validate-schema, and --wait flags to AzureRM and GitHub service endpoint creation commands. Also add --description and --grant-permission-to-all-pipelines flags to GitHub endpoint creation for better control over service connection configuration.
- Add section on getting started with `AcceptanceTest` flag - Clarify timeout behavior and add disable option (-1) - Update environment variables table (remove ORG_URL, clarify others) - Add minimal test scaffold example with all required fields - Update step-by-step instructions to use new poll utility - Document new file writing helpers with temp directory usage - Improve examples and clarify when to use acceptance tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.