()
| 47 | } |
| 48 | |
| 49 | func run() error { |
| 50 | localPath, err := localFilePath() |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | databasePath := filepath.Join(localPath, "..", "..", "..", "coderd", "database") |
| 55 | err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbmetrics", "querymetrics.go"), "m", "queryMetricsStore", func(params stubParams) string { |
| 56 | return fmt.Sprintf(` |
| 57 | start := time.Now() |
| 58 | %s := m.s.%s(%s) |
| 59 | m.queryLatencies.WithLabelValues("%s").Observe(time.Since(start).Seconds()) |
| 60 | m.queryCounts.WithLabelValues(httpmw.ExtractHTTPRoute(ctx), httpmw.ExtractHTTPMethod(ctx), "%s").Inc() |
| 61 | return %s |
| 62 | `, params.Returns, params.FuncName, params.Parameters, params.FuncName, params.FuncName, params.Returns) |
| 63 | }) |
| 64 | if err != nil { |
| 65 | return xerrors.Errorf("stub dbmetrics: %w", err) |
| 66 | } |
| 67 | |
| 68 | err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbauthz", "dbauthz.go"), "q", "querier", func(_ stubParams) string { |
| 69 | return `panic("not implemented")` |
| 70 | }) |
| 71 | if err != nil { |
| 72 | return xerrors.Errorf("stub dbauthz: %w", err) |
| 73 | } |
| 74 | |
| 75 | err = generateUniqueConstraints() |
| 76 | if err != nil { |
| 77 | return xerrors.Errorf("generate unique constraints: %w", err) |
| 78 | } |
| 79 | |
| 80 | err = generateForeignKeyConstraints() |
| 81 | if err != nil { |
| 82 | return xerrors.Errorf("generate foreign key constraints: %w", err) |
| 83 | } |
| 84 | |
| 85 | err = generateCheckConstraints() |
| 86 | if err != nil { |
| 87 | return xerrors.Errorf("generate check constraints: %w", err) |
| 88 | } |
| 89 | |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | type stubParams struct { |
| 94 | FuncName string |
no test coverage detected