MCPcopy Create free account
hub / github.com/celer-pkg/celer / validate

Method validate

buildtools/build_tools.go:173–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171}
172
173func (b *BuildTool) validate() error {
174 // Validate download url.
175 if b.Url == "" {
176 return fmt.Errorf("url of %s is empty", b.Name)
177 }
178
179 // Validate version.
180 if b.Version == "" {
181 return fmt.Errorf("version of %s is empty", b.Name)
182 }
183
184 // Validate url.
185 if b.Url == "" {
186 return fmt.Errorf("url of %s is empty", b.Name)
187 }
188
189 // Set rootDir and paths based on tool type.
190 // Archive tools (has paths) are extracted to subdirectories.
191 if len(b.Paths) > 0 {
192 // Archive with paths specified: extract to subdirectory.
193 folderName := strings.Split(b.Paths[0], "/")[0]
194 b.rootDir = filepath.Join(b.ctx.Downloads(), "tools", folderName)
195 for _, path := range b.Paths {
196 b.abspaths = append(b.abspaths, filepath.Join(b.ctx.Downloads(), "tools", path))
197 }
198 os.Setenv("PATH", env.JoinPaths("PATH", b.abspaths...))
199 } else {
200 // Single-file tool: use directly from /downloads/
201 b.rootDir = b.ctx.Downloads()
202 }
203
204 // Check and fix tool.
205 if err := b.checkAndFix(); err != nil {
206 return err
207 }
208
209 return nil
210}
211
212func (b *BuildTool) checkAndFix() error {
213 var (

Callers 1

CheckToolsFunction · 0.45

Calls 3

checkAndFixMethod · 0.95
JoinPathsFunction · 0.92
DownloadsMethod · 0.65

Tested by

no test coverage detected