Skip to content

Commit fd104d3

Browse files
committed
refactor: centralize authorized_keys content generation to simplify future extensions
1 parent fcdaf6a commit fd104d3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

internal/config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ func LoadConfig[T any](cmd *cobra.Command, defaults map[string]any, additional_c
161161
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
162162

163163
// cli
164-
// TODO maybe needs to trigger additional parsing beferohand (most likely nots)
164+
// TODO: consider whether flag/env parsing should run earlier for special
165+
// cases (e.g., test harnesses or explicit pre-processing). Current flow
166+
// binds CLI flags here and then unmarshals into the config object.
165167
if err := viper.BindPFlags(cmd.Flags()); err != nil {
166168
return c, err
167169
}

internal/uiadapters/store.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,18 @@ func (s *storeAdapter) GenerateAuthorizedKeysContent(ctx context.Context, accoun
168168
if err != nil {
169169
return "", err
170170
}
171-
// TODO: Consider centralizing BuildAuthorizedKeysContent variants
172-
// (e.g., adding signing headers) behind a stable facade if further
173-
// customization is required by different UI surfaces.
171+
// Centralize call via a single unexported helper to make it easier to
172+
// extend or variant-implement the authorized_keys generation in one
173+
// place without duplicating call sites. This is a mechanical consolidation
174+
// only and does not change behavior.
175+
return s.buildAuthorizedKeysContent(sk, gks, aks)
176+
}
177+
178+
// buildAuthorizedKeysContent centralizes the call to `keys.BuildAuthorizedKeysContent`.
179+
// Keep this unexported wrapper to provide a single place to add future
180+
// variants (headers, signing metadata) without changing the higher-level
181+
// control flow in `GenerateAuthorizedKeysContent`.
182+
func (s *storeAdapter) buildAuthorizedKeysContent(sk *model.SystemKey, gks, aks []model.PublicKey) (string, error) {
174183
return keys.BuildAuthorizedKeysContent(sk, gks, aks)
175184
}
176185

0 commit comments

Comments
 (0)