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

Method UpdateCurrent

pkg/engine/apply.go:74–94  ·  view source on GitHub ↗
(ctx context.Context, target *Target, method string, newCurrent plumbing.Hash)

Source from the content-addressed store, hash-verified

72}
73
74func (fc *FetchitConfig) UpdateCurrent(ctx context.Context, target *Target, method string, newCurrent plumbing.Hash) error {
75 directory := filepath.Base(target.Url)
76 tagName := fmt.Sprintf("current-%s", method)
77
78 repo, err := git.PlainOpen(directory)
79 if err != nil {
80 return utils.WrapErr(err, "Error opening repository: %s", directory)
81 }
82
83 err = repo.DeleteTag(tagName)
84 if err != nil && err != git.ErrTagNotFound {
85 return utils.WrapErr(err, "Error deleting old current tag")
86 }
87
88 _, err = repo.CreateTag(tagName, newCurrent, nil)
89 if err != nil {
90 return utils.WrapErr(err, "Error creating new current tag with hash %s", newCurrent)
91 }
92
93 return nil
94}
95
96// Side effects are running/applying changes concurrently and on success moving old "current" tag
97func (fc *FetchitConfig) Apply(

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