MCPcopy Index your code
hub / github.com/coder/coder / valid

Method valid

enterprise/cli/server_dbcrypt.go:281–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

279}
280
281func (f *rotateFlags) valid() error {
282 if f.PostgresURL == "" {
283 return xerrors.Errorf("no database configured")
284 }
285
286 if f.New == "" {
287 return xerrors.Errorf("no new key provided")
288 }
289
290 if val, err := base64.StdEncoding.DecodeString(f.New); err != nil {
291 return xerrors.Errorf("new key must be base64-encoded")
292 } else if len(val) != 32 {
293 return xerrors.Errorf("new key must be exactly 32 bytes in length")
294 }
295
296 for i, k := range f.Old {
297 if val, err := base64.StdEncoding.DecodeString(k); err != nil {
298 return xerrors.Errorf("old key at index %d must be base64-encoded", i)
299 } else if len(val) != 32 {
300 return xerrors.Errorf("old key at index %d must be exactly 32 bytes in length", i)
301 }
302
303 // Pedantic, but typos here will ruin your day.
304 if k == f.New {
305 return xerrors.Errorf("old key at index %d is the same as the new key", i)
306 }
307 }
308
309 return nil
310}
311
312type decryptFlags struct {
313 PostgresURL string

Callers 2

dbcryptRotateCmdMethod · 0.95
getDisplayVersionStatusFunction · 0.45

Calls 2

DecodeStringMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected