@@ -66,13 +66,13 @@ struct ZoneInfo {
6666 omicron_zone : bool ,
6767
6868 /// The softnpu branch to use
69- #[ clap( long, default_value = "main" ) ]
70- softnpu_branch : String ,
69+ #[ clap( long) ]
70+ softnpu_commit : Option < String > ,
7171
7272 // hardcode for now until repo is open
7373 /// The sidecar-lite branch to use
74- #[ clap( long, default_value = "main" ) ]
75- sidecar_lite_branch : String ,
74+ #[ clap( long) ]
75+ sidecar_lite_commit : Option < String > ,
7676}
7777
7878#[ derive( Default ) ]
@@ -108,8 +108,8 @@ async fn main() -> anyhow::Result<()> {
108108 let mut resources = Resources :: default ( ) ;
109109 fetch_required_artifacts (
110110 & z. name ,
111- & z. softnpu_branch ,
112- & z. sidecar_lite_branch ,
111+ & z. softnpu_commit ,
112+ & z. sidecar_lite_commit ,
113113 )
114114 . await ?;
115115 create_ports ( & z. name , get_port_spec ( & z) ?, & mut resources) ?;
@@ -145,12 +145,12 @@ fn get_port_spec(z: &ZoneInfo) -> anyhow::Result<PortSpec> {
145145
146146async fn fetch_required_artifacts (
147147 name : & str ,
148- softnpu_branch : & str ,
149- sidecar_lite_branch : & str ,
148+ softnpu_commit : & Option < String > ,
149+ sidecar_lite_commit : & Option < String > ,
150150) -> anyhow:: Result < ( ) > {
151- fetch_softnpu ( name, softnpu_branch ) . await ?;
152- fetch_sidecar_lite ( name, sidecar_lite_branch ) . await ?;
153- fetch_scadm ( name, sidecar_lite_branch ) . await ?;
151+ fetch_softnpu ( name, softnpu_commit ) . await ?;
152+ fetch_sidecar_lite ( name, sidecar_lite_commit ) . await ?;
153+ fetch_scadm ( name, sidecar_lite_commit ) . await ?;
154154 Ok ( ( ) )
155155}
156156
@@ -186,9 +186,12 @@ async fn fetch_head_sidecar_lite_commit(
186186
187187async fn fetch_softnpu_url (
188188 shasum : bool ,
189- branch : & str ,
189+ commit : & Option < String > ,
190190) -> anyhow:: Result < String > {
191- let rev = fetch_head_softnpu_commit ( branch) . await ?;
191+ let rev = match commit {
192+ None => fetch_head_softnpu_commit ( "main" ) . await ?,
193+ Some ( commit) => commit. clone ( ) ,
194+ } ;
192195 let base = "https://buildomat.eng.oxide.computer" ;
193196 let path = "public/file/oxidecomputer/softnpu/image" ;
194197 let file = if shasum {
@@ -201,9 +204,12 @@ async fn fetch_softnpu_url(
201204
202205async fn fetch_sidecar_lite_url (
203206 shasum : bool ,
204- branch : & str ,
207+ commit : & Option < String > ,
205208) -> anyhow:: Result < String > {
206- let rev = fetch_head_sidecar_lite_commit ( branch) . await ?;
209+ let rev = match commit {
210+ None => fetch_head_sidecar_lite_commit ( "main" ) . await ?,
211+ Some ( commit) => commit. clone ( ) ,
212+ } ;
207213 let base = "https://buildomat.eng.oxide.computer" ;
208214 let path = "public/file/oxidecomputer/sidecar-lite/release" ;
209215 let file = if shasum {
@@ -214,8 +220,14 @@ async fn fetch_sidecar_lite_url(
214220 Ok ( format ! ( "{}/{}/{}/{}" , base, path, rev, file) )
215221}
216222
217- async fn fetch_scadm_url ( shasum : bool , branch : & str ) -> anyhow:: Result < String > {
218- let rev = fetch_head_sidecar_lite_commit ( branch) . await ?;
223+ async fn fetch_scadm_url (
224+ shasum : bool ,
225+ commit : & Option < String > ,
226+ ) -> anyhow:: Result < String > {
227+ let rev = match commit {
228+ None => fetch_head_sidecar_lite_commit ( "main" ) . await ?,
229+ Some ( commit) => commit. clone ( ) ,
230+ } ;
219231 let base = "https://buildomat.eng.oxide.computer" ;
220232 let path = "public/file/oxidecomputer/sidecar-lite/release" ;
221233 let file = if shasum { "scadm.sha256.txt" } else { "scadm" } ;
@@ -226,30 +238,39 @@ fn runtime_dir(name: &str) -> String {
226238 format ! ( "/var/run/softnpu/{}" , name)
227239}
228240
229- async fn fetch_sidecar_lite ( name : & str , branch : & str ) -> anyhow:: Result < ( ) > {
241+ async fn fetch_sidecar_lite (
242+ name : & str ,
243+ commit : & Option < String > ,
244+ ) -> anyhow:: Result < ( ) > {
230245 fetch_artifact (
231- & fetch_sidecar_lite_url ( false , branch ) . await ?,
232- & fetch_sidecar_lite_url ( true , branch ) . await ?,
246+ & fetch_sidecar_lite_url ( false , commit ) . await ?,
247+ & fetch_sidecar_lite_url ( true , commit ) . await ?,
233248 "asic_program.so" ,
234249 name,
235250 )
236251 . await
237252}
238253
239- async fn fetch_scadm ( name : & str , rev : & str ) -> anyhow:: Result < ( ) > {
254+ async fn fetch_scadm (
255+ name : & str ,
256+ commit : & Option < String > ,
257+ ) -> anyhow:: Result < ( ) > {
240258 fetch_artifact (
241- & fetch_scadm_url ( false , rev ) . await ?,
242- & fetch_scadm_url ( true , rev ) . await ?,
259+ & fetch_scadm_url ( false , commit ) . await ?,
260+ & fetch_scadm_url ( true , commit ) . await ?,
243261 "scadm" ,
244262 name,
245263 )
246264 . await
247265}
248266
249- async fn fetch_softnpu ( name : & str , branch : & str ) -> anyhow:: Result < ( ) > {
267+ async fn fetch_softnpu (
268+ name : & str ,
269+ commit : & Option < String > ,
270+ ) -> anyhow:: Result < ( ) > {
250271 fetch_artifact (
251- & fetch_softnpu_url ( false , branch ) . await ?,
252- & fetch_softnpu_url ( true , branch ) . await ?,
272+ & fetch_softnpu_url ( false , commit ) . await ?,
273+ & fetch_softnpu_url ( true , commit ) . await ?,
253274 "softnpu" ,
254275 name,
255276 )
0 commit comments