@@ -15,9 +15,9 @@ pub mod rendered;
1515pub ( super ) struct Package {
1616 /// Download defines the supported repository sources for the packages.
1717 pub download : Download ,
18- /// Postdownload script to execute after downloading and extracting the package.
18+ /// Post-download hook script to execute after downloading and extracting the package.
1919 /// All validations, checks, and installation steps should go here.
20- pub postdownload : Option < Postdownload > ,
20+ pub post_download_hook : Option < PostDownloadHook > ,
2121}
2222
2323pub type PackageID = String ;
@@ -40,36 +40,32 @@ pub struct Oci {
4040}
4141
4242#[ derive( Debug , Deserialize , Clone , PartialEq ) ]
43- pub struct Postdownload {
44- /// Arguments where first element is the command/executable (e.g., "bash", "sh", "python3"),
45- /// second element is the script path, followed by additional arguments.
46- /// Example: ["bash", "postdownload.sh", "--verbose"]
43+ pub struct PostDownloadHook {
44+ /// Absolute path to the command/executable (e.g., "/bin/bash", "/usr/bin/python3").
45+ /// This is the interpreter or tool that will execute the script.
46+ pub path : TemplateableValue < String > ,
47+
48+ /// Arguments passed to the command. First element should be the script path (absolute),
49+ /// followed by additional arguments for the script.
50+ /// Example: ["install.sh", "--check-dependencies", "--verbose"]
4751 pub args : Vec < TemplateableValue < String > > ,
4852
4953 /// Environmental variables passed to the process.
5054 #[ serde( default ) ]
5155 pub env : HashMap < String , TemplateableValue < String > > ,
52-
53- /// Maximum time to wait for the script to complete.
54- #[ serde( default = "default_postdownload_timeout" ) ]
55- pub timeout : TemplateableValue < String > ,
56- }
57-
58- fn default_postdownload_timeout ( ) -> TemplateableValue < String > {
59- TemplateableValue :: new ( "300s" . to_string ( ) )
6056}
6157
6258impl Templateable for Package {
6359 type Output = rendered:: Package ;
6460 fn template_with ( self , variables : & Variables ) -> Result < Self :: Output , AgentTypeError > {
65- let postdownload = self
66- . postdownload
61+ let post_download_hook = self
62+ . post_download_hook
6763 . map ( |pd| pd. template_with ( variables) )
6864 . transpose ( ) ?;
6965
7066 Ok ( Self :: Output {
7167 download : self . download . template_with ( variables) ?,
72- postdownload ,
68+ post_download_hook ,
7369 } )
7470 }
7571}
@@ -116,21 +112,20 @@ impl Templateable for Oci {
116112 }
117113}
118114
119- impl Templateable for Postdownload {
120- type Output = rendered:: Postdownload ;
115+ impl Templateable for PostDownloadHook {
116+ type Output = rendered:: PostDownloadHook ;
121117 fn template_with ( self , variables : & Variables ) -> Result < Self :: Output , AgentTypeError > {
122- let timeout_str = self . timeout . template_with ( variables) ?;
118+ let path = self . path . template_with ( variables) ?;
123119
124120 let args: Vec < String > = self
125121 . args
126122 . into_iter ( )
127123 . map ( |arg| arg. template_with ( variables) )
128124 . collect :: < Result < Vec < String > , AgentTypeError > > ( ) ?;
129125
130- if args. len ( ) < 2 {
126+ if args. is_empty ( ) {
131127 return Err ( AgentTypeError :: OCIReferenceParsingError (
132- "postdownload args must have at least 2 elements: command and script path"
133- . to_string ( ) ,
128+ "post_download_hook args must have at least 1 element: the script path" . to_string ( ) ,
134129 ) ) ;
135130 }
136131
@@ -140,11 +135,7 @@ impl Templateable for Postdownload {
140135 . map ( |( k, v) | v. template_with ( variables) . map ( |templated| ( k, templated) ) )
141136 . collect :: < Result < HashMap < _ , _ > , AgentTypeError > > ( ) ?;
142137
143- let timeout = duration_str:: parse ( & timeout_str) . map_err ( |err| {
144- AgentTypeError :: OCIReferenceParsingError ( format ! ( "invalid timeout format: {err}" ) )
145- } ) ?;
146-
147- Ok ( Self :: Output { args, env, timeout } )
138+ Ok ( Self :: Output { path, args, env } )
148139 }
149140}
150141
0 commit comments