Skip to content

Fix small issues preventing sunlight-secretmanager from working#12

Merged
mcpherrinm merged 7 commits into
mainfrom
mattm-fixups
Aug 11, 2025
Merged

Fix small issues preventing sunlight-secretmanager from working#12
mcpherrinm merged 7 commits into
mainfrom
mattm-fixups

Conversation

@mcpherrinm
Copy link
Copy Markdown
Contributor

@mcpherrinm mcpherrinm commented Aug 8, 2025

This fixes a few bugs in sunlight-secretsmanager found when trying to use it:

The "Name" value in config was deprecated and isn't in our current Sunlight configs - use shortname for logging instead

Trying to get a secret with no current version returns an error, which must be handled.

The code incorrectly used CreateSecret, but the secret already exists - we need to put content instead.

Drop the exhaustruct linter.

The AWS SDK makes extensive use of zero value fields in structs, so this linter
isn't a good match for this program.
@mcpherrinm mcpherrinm changed the title WIP - Fixups found when running Fix small issues preventing sunlight-secretmanager from working Aug 8, 2025
@mcpherrinm mcpherrinm requested a review from Copilot August 8, 2025 23:56
Copy link
Copy Markdown
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 fixes several bugs in the sunlight-secretmanager tool to make it functional. The changes address configuration field deprecation, error handling for missing secrets, and correct API usage for updating existing secrets.

  • Replace deprecated Name field with ShortName in configuration and logging
  • Add proper error handling for secrets that don't exist (ResourceNotFoundException)
  • Switch from CreateSecret to PutSecretValue API for updating existing secrets

Reviewed Changes

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

Show a summary per file
File Description
cmd/sunlight-secretmanager/main.go Updates logging to use ShortName instead of deprecated Name field
cmd/sunlight-secretmanager/config.go Changes configuration structure to use ShortName field
cmd/sunlight-secretmanager/config_test.go Updates test data to match new ShortName field
cmd/sunlight-secretmanager/seed.go Adds error handling for missing secrets and switches to PutSecretValue API
cmd/sunlight-secretmanager/seed_test.go Updates mock implementation to use PutSecretValue instead of CreateSecret
.golangci.yaml Disables exhaustruct linter to allow partial struct initialization

Comment thread cmd/sunlight-secretmanager/seed.go Outdated
Comment thread cmd/sunlight-secretmanager/seed.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mcpherrinm mcpherrinm requested a review from aarongable August 9, 2025 00:02
Copy link
Copy Markdown
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

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

LGTM. My primary worry is that PutSecretValue is not idempotent -- it's happy to create a new version of a secret even when one already exists. It's unclear to me how best to protect against this. But afaict this problem exists with CreateSecret too, so it's not a new issue.

@mcpherrinm mcpherrinm merged commit 6144f76 into main Aug 11, 2025
1 check passed
@mcpherrinm mcpherrinm deleted the mattm-fixups branch August 11, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants