@@ -44,6 +44,7 @@ type substemManifest struct {
44
44
func main () {
45
45
subsystem := flag .String ("subsystem" , viamServer , "subsystem type" ) // default to viam-server
46
46
binaryPath := flag .String ("binary-path" , "" , "path to subsystem binary" )
47
+ resourcesJSON := flag .String ("resources-json" , "" , "optional pre-dumped resource json" )
47
48
uploadPath := flag .String ("upload-path" , "" , "path where this binary will be stored in gcs" )
48
49
outputPath := flag .String ("output-path" , "" , "path where this manifest json file will be written" )
49
50
version := flag .String ("version" , "" , "version" )
@@ -63,7 +64,7 @@ func main() {
63
64
}
64
65
var metadata * viamServerMetadata
65
66
if * subsystem == viamServer {
66
- metadata , err = getViamServerMetadata (* binaryPath )
67
+ metadata , err = getViamServerMetadata (* binaryPath , * resourcesJSON )
67
68
if err != nil {
68
69
log .Fatalf ("failed to get viam-server metadata: %v" , err )
69
70
}
@@ -93,18 +94,24 @@ func main() {
93
94
}
94
95
}
95
96
96
- func getViamServerMetadata (path string ) (* viamServerMetadata , error ) {
97
- resourcesOutputFile , err := os .CreateTemp ("" , "resources-" )
98
- if err != nil {
99
- return nil , err
100
- }
101
- resourcesOutputFileName := resourcesOutputFile .Name ()
102
- //nolint:errcheck
103
- defer os .Remove (resourcesOutputFileName )
104
- //nolint:gosec
105
- command := exec .Command (path , "--dump-resources" , resourcesOutputFileName )
106
- if err := command .Run (); err != nil {
107
- return nil , err
97
+ // `path` is the path to the binary.
98
+ // `resourcesOutputFileName` is an optional pre-dumped resource json.
99
+ // note: we pre-dump for the windows build so that we are not bound to a windows runner. (we can cross-compile,
100
+ // but we can't run the cross-compiled artifact).
101
+ func getViamServerMetadata (path , resourcesOutputFileName string ) (* viamServerMetadata , error ) {
102
+ if resourcesOutputFileName == "" {
103
+ resourcesOutputFile , err := os .CreateTemp ("" , "resources-" )
104
+ if err != nil {
105
+ return nil , err
106
+ }
107
+ resourcesOutputFileName = resourcesOutputFile .Name ()
108
+ //nolint:errcheck
109
+ defer os .Remove (resourcesOutputFileName )
110
+
111
+ command := exec .Command (path , "--dump-resources" , resourcesOutputFileName )
112
+ if err := command .Run (); err != nil {
113
+ return nil , err
114
+ }
108
115
}
109
116
//nolint:gosec
110
117
resourcesBytes , err := os .ReadFile (resourcesOutputFileName )
0 commit comments