Skip to content

Rework sample directory for 2.0 APIs#125

Merged
Kralizek merged 5 commits into
masterfrom
copilot/rework-sample-directory-2-0-apis
May 8, 2026
Merged

Rework sample directory for 2.0 APIs#125
Kralizek merged 5 commits into
masterfrom
copilot/rework-sample-directory-2-0-apis

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

Reworks the sample directory for the 2.0 API surface by replacing numbered samples with descriptive, use-case-oriented PascalCase folders.

Summary

Renamed samples

Old New Use case
Sample1 ListSecrets Discover and load secrets by listing them.
Sample2 ConfigureAwsOptions Configure AWS SDK options such as region/profile.
Sample3 UseCustomSecretsManagerClient Pass a caller-created IAmazonSecretsManager.
Sample4 ManySecrets Load a fixed set of known secrets.
Sample5 CustomizeConfigurationKeys Use context-based KeyGenerator for advanced key customization.
Sample6 ResolveDuplicateKeys Demonstrate DuplicateKeyHandling.
Sample7 BootstrapLogging Enable logging while configuration is being built.
Sample8 SingleSecret Load exactly one known secret with least-privilege permissions.
SampleWeb ReloadSecretsInAspNetCore ASP.NET Core integration with periodic reload.

Added samples

  • MapConfigurationKeys
    • demonstrates common SecretKeyMappingOptions scenarios;
    • shows PrefixJsonKeysWithSecretName = false for loading JSON directly as app configuration;
    • shows TargetSection for projecting JSON into a specific section;
    • shows SecretNamePathSeparator = null for verbatim secret-name compatibility.
  • ComposeConfigurationSources
    • demonstrates layering multiple configuration providers/calls;
    • uses standard .NET configuration precedence;
    • explicitly distinguishes provider ordering from DuplicateKeyHandling inside a single provider call.

Updated sample content

  • SingleSecret now focuses on the least-privilege single-secret path and documents required/omitted IAM permissions.
  • ManySecrets now shows loading a fixed set of known secrets and makes the default batch behavior explicit.
  • ListSecrets now shows discovery/listing with a server-side ListSecretsFilters example and explains why JSON keys stay namespaced by default.
  • CustomizeConfigurationKeys no longer shows the obsolete context.DefaultKey.Replace("/", ":") pattern. It now demonstrates a real advanced KeyGenerator scenario, where scalar secrets are routed under a dedicated section and JSON-derived keys keep context.DefaultKey.
  • ResolveDuplicateKeys now uses AddSecretsManagerKnownSecrets with a fixed input set, which makes duplicate-key behavior easier to reason about than discovery.
  • BootstrapLogging and ReloadSecretsInAspNetCore were renamed and kept focused on their operational scenarios.
  • UseCustomSecretsManagerClient now disposes the sample-created AmazonSecretsManagerClient with using var.

Documentation and project structure

  • samples/README.md was rewritten to group samples by intent:
    • choosing what to load;
    • configuring AWS client creation;
    • mapping and composing configuration keys;
    • operational scenarios.
  • Tutorial-style key-mapping prose was removed from samples/README.md; the sample index now stays focused on navigation.
  • SecretsManager.slnx was updated to include all 11 renamed/new sample projects.

Code quality cleanup

  • Removed unused configuration local variables from samples where the built configuration is not consumed.
  • Addressed the disposable AmazonSecretsManagerClient warning in UseCustomSecretsManagerClient.
  • Addressed the SonarCloud issues reported on the new sample files.

How it was tested

  • All sample projects build cleanly against the 2.0 library.
  • dotnet build --no-incremental -warnaserror passes with zero warnings.
  • dotnet format --verify-no-changes passes.
  • Full test suite passes unchanged.
  • CI is green.

Checklist

  • Samples renamed from numbered folders to descriptive PascalCase use-case names
  • New MapConfigurationKeys sample added
  • New ComposeConfigurationSources sample added
  • samples/README.md updated and grouped by intent
  • Sample projects updated in SecretsManager.slnx
  • SonarCloud issues addressed
  • CI is green
  • Build passes with --warnaserror

Copilot AI linked an issue May 8, 2026 that may be closed by this pull request
- Rename Sample1–Sample8 and SampleWeb to descriptive PascalCase names
- Update all Program.cs files with improved comments and 2.0 API usage
- Remove obsolete KeyGenerator = key.Replace("/",":") pattern
- Add MapConfigurationKeys sample (SecretKeyMappingOptions demo)
- Add ComposeConfigurationSources sample (multi-provider layering)
- Update SecretsManager.slnx with new project paths
- Rewrite samples/README.md organized by intent

Agent-Logs-Url: https://github.com/Kralizek/AWSSecretsManagerConfigurationExtensions/sessions/dd269f12-8809-4073-a457-4329d2e37fb7

Co-authored-by: Kralizek <2458439+Kralizek@users.noreply.github.com>
Copilot AI changed the title [WIP] Rework sample directory for 2.0 APIs Rework sample directory for 2.0 APIs May 8, 2026
Copilot AI requested a review from Kralizek May 8, 2026 11:49
Comment thread samples/README.md Outdated
Copilot AI requested a review from Kralizek May 8, 2026 11:56
@Kralizek
Copy link
Copy Markdown
Owner

Kralizek commented May 8, 2026

@copilot solve the sonarcloud issues

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 8, 2026

@copilot solve the sonarcloud issues

Fixed in 0cbb3e8. All 13 issues were in the new sample files:

  • 10 unused local variables: var configuration = builder.Build() where the result was never read — changed to just builder.Build()
  • 3 more unused variables in MapConfigurationKeys (configuration1, configuration2, configuration3) — same fix
  • 1 undisposed IDisposable: AmazonSecretsManagerClient in UseCustomSecretsManagerClient changed to using var client

Build still passes with zero warnings.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • sonarcloud.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

@Kralizek Kralizek marked this pull request as ready for review May 8, 2026 13:20
@Kralizek Kralizek merged commit 9f5fe63 into master May 8, 2026
2 checks passed
@Kralizek Kralizek deleted the copilot/rework-sample-directory-2-0-apis branch May 8, 2026 13:21
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.

Rework sample directory for 2.0 APIs

2 participants