Skip to content

feat(k8s): upserting secrets#67

Merged
Jacobbrewer1 merged 3 commits intomainfrom
feat/upsertable-secrets
May 1, 2025
Merged

feat(k8s): upserting secrets#67
Jacobbrewer1 merged 3 commits intomainfrom
feat/upsertable-secrets

Conversation

@Jacobbrewer1
Copy link
Owner

Describe your changes

This pull request enhances the UpsertResource functionality in the k8s/resource.go file by adding support for Kubernetes Secret resources, alongside the existing support for ConfigMap. It also introduces comprehensive test cases for Secret resources, refactors the test structure for better parallelism, and includes a minor improvement to reset resource versions during resource creation.

Core functionality updates:

  • Added support for corev1.Secret in the UpsertResource function, enabling the upsert operation for Secret resources. (k8s/resource.go, k8s/resource.goR50-R51)
  • Reset the resource version to an empty string during creation to avoid conflicts. (k8s/resource.go, k8s/resource.goR65)

Testing enhancements:

  • Refactored tests to use t.Run for subtests, enabling parallel execution and improving test organization. (k8s/resource_test.go, [1] [2] [3]
  • Added test cases for Secret resources to cover create, update, get error, create error, and update error scenarios. (k8s/resource_test.go, [1] [2] [3] [4] [5]

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot May 1, 2025 09:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the upsert functionality to support Kubernetes Secret resources alongside ConfigMaps, and enhances tests by refactoring them to use parallel subtests.

  • Added Secret support in UpsertResource
  • Reset resource version during creation
  • Refactored tests with parallel subtests and added Secret-specific test cases

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
k8s/resource.go Adds a case for Secrets in UpsertResource and resets resource version for creation
k8s/resource_test.go Refactors tests for parallel subtests and adds Secret resource test scenarios
Comments suppressed due to low confidence (2)

k8s/resource.go:50

  • [nitpick] For consistency with the ConfigMap case, consider using resource.GetNamespace() instead of v.Namespace when calling Secrets(v.Namespace).
case *corev1.Secret:

k8s/resource_test.go:22

  • [nitpick] Standardize subtest naming conventions across tests (e.g., use 'ConfigMap' and 'Secret' consistently) for improved clarity.
t.Run("configmap", func(t *testing.T) {

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot May 1, 2025 09:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Kubernetes upsert functionality by adding support for Secret resources alongside ConfigMap and updates the test suite for improved parallel execution and additional error-case coverage.

  • Enhanced UpsertResource to support Secrets and reset the resource version during creation.
  • Added comprehensive test cases for Secret resources covering create, update, and error scenarios.
  • Refactored tests structure using subtests with t.Parallel for better organization.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
k8s/resource.go Added Secret support to UpsertResource and reset resource version.
k8s/resource_test.go Updated tests to include Secret scenarios and refactored for parallelism.
Comments suppressed due to low confidence (1)

k8s/resource_test.go:129

  • [nitpick] For consistency with the other subtest names (e.g., "secret"), consider using lowercase ("configmap") for the subtest name.
t.Run("ConfigMap", func(t *testing.T) {

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot May 1, 2025 09:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the UpsertResource functionality to add support for Kubernetes Secret resources alongside existing ConfigMap support. It also refactors the test structure to use subtests with parallel execution and adds comprehensive Secret-specific test cases.

  • Added case handling for corev1.Secret and reset resource version during creation.
  • Refactored tests to group ConfigMap and Secret scenarios and to run in parallel.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
k8s/resource.go Added support for Secret resources and reset resource version on create.
k8s/resource_test.go Refactored tests to use t.Run with parallel subtests and added Secret test cases.
Comments suppressed due to low confidence (1)

k8s/resource.go:65

  • Consider adding a test case to verify that the resource version is reset (i.e., becomes an empty string) upon creation for both ConfigMap and Secret resources. This extra assertion would help ensure that the intended behavior for conflict avoidance is maintained.
obj.SetResourceVersion("") // Reset resource version for creation

@Jacobbrewer1 Jacobbrewer1 marked this pull request as ready for review May 1, 2025 09:19
@Jacobbrewer1 Jacobbrewer1 merged commit 95fa8ff into main May 1, 2025
8 checks passed
@Jacobbrewer1 Jacobbrewer1 deleted the feat/upsertable-secrets branch May 1, 2025 09:19
@github-actions
Copy link

github-actions bot commented Jun 1, 2025

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants