feat: Use COPY syntax for files module (#38)
This commit is contained in:
parent
933d25054a
commit
7f38fb04e6
2 changed files with 28 additions and 3 deletions
|
|
@ -118,7 +118,7 @@ fn running_gitlab_actions() -> bool {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
|
||||
fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
|
||||
if module.module_type.as_ref()? == "containerfile" {
|
||||
Some(
|
||||
module
|
||||
|
|
@ -135,7 +135,7 @@ pub fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn print_containerfile(containerfile: &str) -> String {
|
||||
fn print_containerfile(containerfile: &str) -> String {
|
||||
debug!("print_containerfile({containerfile})");
|
||||
debug!("Loading containerfile contents for {containerfile}");
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ pub fn print_containerfile(containerfile: &str) -> String {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn template_module_from_file(file_name: &str) -> String {
|
||||
fn template_module_from_file(file_name: &str) -> String {
|
||||
debug!("get_module_from_file({file_name})");
|
||||
|
||||
let file_path = PathBuf::from("config").join(file_name);
|
||||
|
|
@ -195,3 +195,22 @@ fn print_module_context(module: &Module) -> String {
|
|||
process::exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
fn get_files_list(module: &Module) -> Option<Vec<(String, String)>> {
|
||||
Some(
|
||||
module
|
||||
.config
|
||||
.get("files")?
|
||||
.as_sequence()?
|
||||
.iter()
|
||||
.filter_map(|entry| entry.as_mapping())
|
||||
.flatten()
|
||||
.filter_map(|(src, dest)| {
|
||||
Some((
|
||||
format!("./config/files/{}", src.as_str()?),
|
||||
dest.as_str()?.to_string(),
|
||||
))
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@
|
|||
{{ self::print_containerfile(c) }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- else if type == "files" %}
|
||||
{%- if let Some(files) = self::get_files_list(module) %}
|
||||
{%- for (src, dest) in files %}
|
||||
COPY {{ src }} {{ dest }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
RUN chmod +x /tmp/modules/{{ type }}/{{ type }}.sh && source /tmp/exports.sh && /tmp/modules/{{ type }}/{{ type }}.sh '{{ self::print_module_context(module) }}'
|
||||
{%- endif %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue