| 126 | ) |
| 127 | |
| 128 | func MakeContext() context.Context { |
| 129 | ctx := context.Background() |
| 130 | config, err := GetConfig() |
| 131 | if err != nil { |
| 132 | panic(fmt.Errorf("failed to retrieve config: %w", err)) |
| 133 | } |
| 134 | ctx = context.WithValue(ctx, ConfigCtxKey, &config) |
| 135 | db, err := OpenLocalSqliteDb() |
| 136 | if err != nil { |
| 137 | panic(fmt.Errorf("failed to open local DB: %w", err)) |
| 138 | } |
| 139 | ctx = context.WithValue(ctx, DbCtxKey, db) |
| 140 | homedir, err := os.UserHomeDir() |
| 141 | if err != nil { |
| 142 | panic(fmt.Errorf("failed to get homedir: %w", err)) |
| 143 | } |
| 144 | ctx = context.WithValue(ctx, HomedirCtxKey, homedir) |
| 145 | return ctx |
| 146 | } |
| 147 | |
| 148 | func GetConf(ctx context.Context) *ClientConfig { |
| 149 | v := ctx.Value(ConfigCtxKey) |