This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis.go
71 lines (64 loc) · 2.39 KB
/
analysis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package storecommon
import (
"fmt"
"path/filepath"
"strings"
"github.com/dpb587/boshua/analysis"
"github.com/dpb587/boshua/releaseversion"
releaseoptsutil "github.com/dpb587/boshua/releaseversion/cli/opts/optsutil"
"github.com/dpb587/boshua/releaseversion/compilation"
releaseversiondatastore "github.com/dpb587/boshua/releaseversion/datastore"
"github.com/dpb587/boshua/stemcellversion"
stemcelloptsutil "github.com/dpb587/boshua/stemcellversion/cli/opts/optsutil"
stemcellversiondatastore "github.com/dpb587/boshua/stemcellversion/datastore"
"github.com/dpb587/boshua/task"
"github.com/pkg/errors"
)
func AppendAnalysisStore(tt *task.Task, analysisRef analysis.Reference) *task.Task {
var storeArgs []string
var storeDatastore string
switch analysisSubject := analysisRef.Subject.(type) {
case stemcellversion.Artifact:
storeDatastore = fmt.Sprintf("internal/stemcell/%s", analysisSubject.GetDatastoreName())
storeArgs = append(
[]string{"stemcell"},
stemcelloptsutil.ArgsFromFilterParams(stemcellversiondatastore.FilterParamsFromArtifact(analysisSubject))...,
)
case releaseversion.Artifact:
storeDatastore = fmt.Sprintf("internal/release/%s", analysisSubject.GetDatastoreName())
storeArgs = append(
[]string{"release"},
releaseoptsutil.ArgsFromFilterParams(releaseversiondatastore.FilterParamsFromArtifact(analysisSubject))...,
)
case compilation.Artifact:
storeDatastore = analysisSubject.GetDatastoreName()
if storeDatastore[0:9] == "internal/" { // swap release -> compilation
storeDatastore = fmt.Sprintf("internal/release.compilation/%s", strings.SplitN(storeDatastore, "/", 3)[2])
}
analysisSubjectRef := analysisSubject.Reference().(compilation.Reference)
storeArgs = append(
append(
append(
[]string{"release"},
releaseoptsutil.ArgsFromFilterParams(releaseversiondatastore.FilterParamsFromReference(analysisSubjectRef.ReleaseVersion))...,
),
"compilation",
),
fmt.Sprintf("--os=%s/%s", analysisSubjectRef.OSVersion.Name, analysisSubjectRef.OSVersion.Version),
)
default:
panic(errors.New("unsupported analysis subject")) // TODO panic?
}
tt.Steps = append(tt.Steps, task.Step{
Name: "storing",
Args: append(
storeArgs,
"analysis",
"store-results",
fmt.Sprintf("--analyzer=%s", analysisRef.Analyzer),
fmt.Sprintf("--datastore=%s", storeDatastore),
filepath.Join("input", "results.jsonl.gz"),
),
})
return tt
}