@@ -44,6 +44,7 @@ type substemManifest struct {
4444func main () {
4545 subsystem := flag .String ("subsystem" , viamServer , "subsystem type" ) // default to viam-server
4646 binaryPath := flag .String ("binary-path" , "" , "path to subsystem binary" )
47+ resourcesJSON := flag .String ("resources-json" , "" , "optional pre-dumped resource json" )
4748 uploadPath := flag .String ("upload-path" , "" , "path where this binary will be stored in gcs" )
4849 outputPath := flag .String ("output-path" , "" , "path where this manifest json file will be written" )
4950 version := flag .String ("version" , "" , "version" )
@@ -63,7 +64,7 @@ func main() {
6364 }
6465 var metadata * viamServerMetadata
6566 if * subsystem == viamServer {
66- metadata , err = getViamServerMetadata (* binaryPath )
67+ metadata , err = getViamServerMetadata (* binaryPath , * resourcesJSON )
6768 if err != nil {
6869 log .Fatalf ("failed to get viam-server metadata: %v" , err )
6970 }
@@ -93,18 +94,24 @@ func main() {
9394 }
9495}
9596
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+ }
108115 }
109116 //nolint:gosec
110117 resourcesBytes , err := os .ReadFile (resourcesOutputFileName )
0 commit comments