MCPcopy Create free account
hub / github.com/containers/fetchit / GetCurrent

Method GetCurrent

pkg/engine/apply.go:55–72  ·  view source on GitHub ↗
(target *Target, method string)

Source from the content-addressed store, hash-verified

53}
54
55func (fc *FetchitConfig) GetCurrent(target *Target, method string) (plumbing.Hash, error) {
56 directory := filepath.Base(target.Url)
57 tagName := fmt.Sprintf("current-%s", method)
58
59 repo, err := git.PlainOpen(directory)
60 if err != nil {
61 return plumbing.Hash{}, utils.WrapErr(err, "Error opening repository: %s", directory)
62 }
63
64 ref, err := repo.Tag(tagName)
65 if err == git.ErrTagNotFound {
66 return plumbing.Hash{}, nil
67 } else if err != nil {
68 return plumbing.Hash{}, utils.WrapErr(err, "Error getting reference to current tag")
69 }
70
71 return ref.Hash(), err
72}
73
74func (fc *FetchitConfig) UpdateCurrent(ctx context.Context, target *Target, method string, newCurrent plumbing.Hash) error {
75 directory := filepath.Base(target.Url)

Callers 5

processRawMethod · 0.95
processAnsibleMethod · 0.95
processSystemdMethod · 0.95
processFileTransferMethod · 0.95
processKubeMethod · 0.95

Calls 1

WrapErrFunction · 0.92

Tested by

no test coverage detected