MCPcopy Create free account
hub / github.com/cloudbase/garm / updateTools

Method updateTools

workers/cache/tool_cache.go:107–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105}
106
107func (t *toolsUpdater) updateTools() error {
108 slog.DebugContext(t.ctx, "updating tools", "last_update", t.lastUpdate, "entity", t.entity.String(), "forge_type", t.entity.Credentials.ForgeType)
109 entity, ok := cache.GetEntity(t.entity.ID)
110 if !ok {
111 return fmt.Errorf("getting entity from cache: %s", t.entity.ID)
112 }
113 ghCli, err := github.Client(t.ctx, entity)
114 if err != nil {
115 return fmt.Errorf("getting github client: %w", err)
116 }
117
118 tools, err := garmUtil.FetchTools(t.ctx, ghCli)
119 if err != nil {
120 return fmt.Errorf("error fetching tools: %w", err)
121 }
122
123 if len(tools) == 0 {
124 return fmt.Errorf("FetchTools returned no tools")
125 }
126
127 t.tools = tools
128
129 slog.DebugContext(t.ctx, "updating tools cache", "entity", t.entity.String())
130 cache.SetGithubToolsCache(entity, tools)
131 return nil
132}
133
134func (t *toolsUpdater) Reset() {
135 t.mux.Lock()

Callers 1

loopMethod · 0.95

Calls 5

GetEntityFunction · 0.92
ClientFunction · 0.92
SetGithubToolsCacheFunction · 0.92
FetchToolsMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected