this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: adjust for loading multiple identities

Alex Ottr b53c17c9 019a53a0

+45 -24
+13 -13
cmd/nox/main.go
··· 16 16 17 17 var configPath string 18 18 var statePath string 19 - var identityPath string 19 + var identityPaths []string 20 20 var appName string 21 21 var dryRun bool 22 22 var force bool ··· 41 41 Usage: "path to state file", 42 42 Destination: &statePath, 43 43 }, 44 - &cli.StringFlag{ 44 + &cli.StringSliceFlag{ 45 45 Name: "identity", 46 46 Usage: "path to age identity file", 47 - Destination: &identityPath, 47 + Destination: &identityPaths, 48 48 }, 49 49 &cli.BoolFlag{ 50 50 Name: "verbose", ··· 127 127 }, 128 128 Action: func(ctx context.Context, cmd *cli.Command) error { 129 129 rtx, err := config.BuildRuntimeContext(config.RuntimeOptions{ 130 - ConfigPath: configPath, 131 - StatePath: statePath, 132 - IdentityPath: identityPath, 133 - DryRun: dryRun, 134 - Force: force, 135 - AppName: appName, 136 - Verbose: verbose, 130 + ConfigPath: configPath, 131 + StatePath: statePath, 132 + IdentityPaths: identityPaths, 133 + DryRun: dryRun, 134 + Force: force, 135 + AppName: appName, 136 + Verbose: verbose, 137 137 }) 138 138 if err != nil { 139 139 log.Fatalf("failed to build runtime context: %v", err) ··· 150 150 Usage: "Validate configuration and secret integrity", 151 151 Action: func(ctx context.Context, cmd *cli.Command) error { 152 152 rtx, err := config.BuildRuntimeContext(config.RuntimeOptions{ 153 - ConfigPath: configPath, 154 - StatePath: statePath, 155 - IdentityPath: identityPath, 153 + ConfigPath: configPath, 154 + StatePath: statePath, 155 + IdentityPaths: identityPaths, 156 156 }) 157 157 if err != nil { 158 158 log.Fatalf("failed to build runtime context: %v", err)
+18 -11
internal/config/context.go
··· 12 12 ) 13 13 14 14 type RuntimeOptions struct { 15 - ConfigPath string 16 - StatePath string 17 - IdentityPath string 18 - DryRun bool 19 - Force bool 20 - Verbose bool 21 - AppName string 15 + ConfigPath string 16 + StatePath string 17 + IdentityPaths []string 18 + DryRun bool 19 + Force bool 20 + Verbose bool 21 + AppName string 22 22 } 23 23 24 24 type RuntimeContext struct { ··· 47 47 return nil, err 48 48 } 49 49 50 - identityPath := opts.IdentityPath 51 - if identityPath == "" { 52 - identityPath = cfg.Age.Identity 50 + identityPaths := opts.IdentityPaths 51 + if len(identityPaths) == 0 { 52 + // try single identity file first 53 + if cfg.Age.Identity != "" { 54 + identityPaths = []string{cfg.Age.Identity} 55 + } else if len(cfg.Age.Identities) > 0 { 56 + identityPaths = cfg.Age.Identities 57 + } else { 58 + return nil, fmt.Errorf("no age identites found") 59 + } 53 60 } 54 - ids, err := crypto.LoadAgeIdentities(identityPath) 61 + ids, err := crypto.LoadAgeIdentitiesFromPaths(identityPaths) 55 62 if err != nil { 56 63 return nil, err 57 64 }
+14
internal/crypto/identity.go
··· 22 22 23 23 return identities, nil 24 24 } 25 + 26 + func LoadAgeIdentitiesFromPaths(paths []string) ([]age.Identity, error) { 27 + var allIdentities []age.Identity 28 + 29 + for _, path := range paths { 30 + idents, err := LoadAgeIdentities(path) 31 + if err != nil { 32 + return nil, fmt.Errorf("failed to load identities from %s: %w", path, err) 33 + } 34 + allIdentities = append(allIdentities, idents...) 35 + } 36 + 37 + return allIdentities, nil 38 + }