Skip to content

Commit c2c32d0

Browse files
committed
simplify the result.json file aggregating CoreInfo & LibInfo structs
1 parent 1b8abb8 commit c2c32d0

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

cmd/compile.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,20 @@ type CompileOutput struct {
2828
}
2929

3030
type BuilderResult struct {
31-
BuildPath string `json:"build_path"`
32-
UsedLibraries []*LibInfo `json:"used_libraries"`
31+
BuildPath string `json:"build_path"`
32+
UsedLibraries []*Info `json:"used_libraries"`
3333
}
3434

35-
// coreInfo contains information regarding the core used during the compile process
36-
type CoreInfo struct {
37-
// corePackager string `json: "CorePackager"`
38-
CoreName string `json:"coreName"`
39-
CoreVersion string `json:"coreVersion"`
40-
}
41-
42-
// LibInfo contains information regarding the library used during the compile process
43-
type LibInfo struct {
44-
LibName string `json:"name"`
45-
LibVersion string `json:"version"`
35+
// Info contains information regarding the library or the core used during the compile process
36+
type Info struct {
37+
Name string `json:"name"`
38+
Version string `json:"version"`
4639
}
4740

4841
// returnJson contains information regarding the core and libraries used during the compile process
4942
type ReturnJson struct {
50-
CoreInfo *CoreInfo `json:"coreInfo"`
51-
LibsInfo []*LibInfo `json:"libsInfo"`
43+
CoreInfo *Info `json:"coreInfo"`
44+
LibsInfo []*Info `json:"libsInfo"`
5245
}
5346

5447
// compileCmd represents the compile command
@@ -174,17 +167,17 @@ func parseOutput(cmdOutToParse []byte) ([]*paths.Path, *ReturnJson) {
174167

175168
// parseCoreLine takes the line containig info regarding the core and
176169
// returns a coreInfo object
177-
func parseCoreLine(coreLine string) *CoreInfo {
170+
func parseCoreLine(coreLine string) *Info {
178171
words := strings.Split(coreLine, " ")
179172
strCorePath := words[len(words)-1] // last string has the path of the core
180173
// maybe check if the path is legit before and logrus.Fatal if not
181174
corePath := paths.New(strCorePath)
182175
version := corePath.Base()
183176
name := corePath.Parent().Base()
184177
logrus.Debugf("core name: %s, core version: %s", name, version)
185-
coreInfo := &CoreInfo{
186-
CoreName: name,
187-
CoreVersion: version,
178+
coreInfo := &Info{
179+
Name: name,
180+
Version: version,
188181
}
189182
return coreInfo
190183
}

0 commit comments

Comments
 (0)