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

Function SeedFromBytes

coderd/aibridge/prices/prices.go:45–54  ·  view source on GitHub ↗

SeedFromBytes applies an arbitrary JSON seed. Most callers should use Seed, which applies the seed embedded in this binary; SeedFromBytes is exposed for tests that need to inject a deterministic seed.

(ctx context.Context, db database.Store, data []byte)

Source from the content-addressed store, hash-verified

43// which applies the seed embedded in this binary; SeedFromBytes is exposed
44// for tests that need to inject a deterministic seed.
45func SeedFromBytes(ctx context.Context, db database.Store, data []byte) error {
46 rows, err := parseSeed(data)
47 if err != nil {
48 return xerrors.Errorf("parse price seed: %w", err)
49 }
50 if len(rows) == 0 {
51 return xerrors.New("price seed is empty")
52 }
53 return db.UpsertAIModelPrices(ctx, data)
54}
55
56func parseSeed(data []byte) ([]seedRow, error) {
57 var rows []seedRow

Callers 2

TestSeedFromBytesFunction · 0.92
SeedFunction · 0.85

Calls 4

parseSeedFunction · 0.85
NewMethod · 0.65
UpsertAIModelPricesMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestSeedFromBytesFunction · 0.74