MCPcopy Create free account
hub / github.com/encoder-run/operator / SetReference

Method SetReference

pkg/cache/postgres/reference.go:21–35  ·  view source on GitHub ↗

SetReference stores a reference in Postgres.

(ref *plumbing.Reference)

Source from the content-addressed store, hash-verified

19
20// SetReference stores a reference in Postgres.
21func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error {
22 reference := &database.Reference{
23 Name: ref.Name().String(),
24 Type: ref.Type().String(),
25 Target: ref.Target().String(),
26 Hash: ref.Hash().String(),
27 URL: r.namespacePrefix,
28 }
29
30 // Upsert operation: Update if exists, else create
31 return r.db.Clauses(clause.OnConflict{
32 Columns: []clause.Column{{Name: "url"}, {Name: "name"}}, // conflict target
33 DoUpdates: clause.Assignments(map[string]interface{}{"hash": ref.Hash().String()}), // update just the hash
34 }).Create(reference).Error
35}
36
37// Reference retrieves a reference from Postgres by its name.
38func (r *ReferenceStorage) Reference(name plumbing.ReferenceName) (*plumbing.Reference, error) {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected