Skip to content

Commit

Permalink
Further refinements to the version_depth in ci.yml
Browse files Browse the repository at this point in the history
This commit tunes the version_depth handling in the ci.yml generation to
only apply to the `git` git resource for the genesis-assets repo, and not to
the other `*-cached` and `*-changes` git resources.
  • Loading branch information
dennisjbell committed Nov 13, 2024
1 parent dc17cb3 commit 796a88f
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions lib/Genesis/CI/Legacy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ sub validate_pipeline {
$p->{pipeline}{git}{commits}{user_email} ||= 'concourse@pipeline';
}
($p->{pipeline}{git}{root} ||= '.') =~ s#/*$##;
$p->{pipeline}{git}{branch} ||= 'master';
$p->{pipeline}{git}{version_depth} ||= 0;
}

Expand Down Expand Up @@ -715,20 +716,30 @@ sub generate_pipeline_concourse_yaml {
pipeline:
EOF
# -- pipeline.git {{{
my $git_credentials;
my ($git_credentials, $git_resource_creds, $git_env_creds);
if ($pipeline->{pipeline}{git}{private_key}) {
$git_credentials = " private_key: |-\n ".join("\n ",split("\n",$pipeline->{pipeline}{git}{private_key}));
$git_resource_creds = " private_key: (( grab pipeline.git.private_key ))";
$git_env_creds = " GIT_PRIVATE_KEY: (( grab pipeline.git.private_key ))";
} else {
my $git_password_as_yaml = string_to_yaml($pipeline->{pipeline}{git}{password});
$git_credentials = " username: $pipeline->{pipeline}{git}{username}\n password: \"$git_password_as_yaml\"";
$git_resource_creds = " username: (( grab pipeline.git.username ))\n password: (( grab pipeline.git.password ))";
$git_env_creds = " GIT_USERNAME: (( grab pipeline.git.username ))\n GIT_PASSWORD: (( grab pipeline.git.password || \"\" ))";
}
my $git_genesis_root = $pipeline->{pipeline}{git}{root} ne '.' ? " GIT_GENESIS_ROOT: $pipeline->{pipeline}{git}{root}\n" : "";

print $OUT <<"EOF";
git:
uri: $pipeline->{pipeline}{git}{uri}
branch: master
branch: $pipeline->{pipeline}{git}{branch}
$git_credentials
config:
icon: github
resource_source:
branch: (( grab pipeline.git.branch ))
$git_resource_creds
uri: (( grab pipeline.git.uri ))
commits:
user_name: $pipeline->{pipeline}{git}{commits}{user_name}
user_email: $pipeline->{pipeline}{git}{commits}{user_email}
Expand Down Expand Up @@ -870,26 +881,14 @@ EOF
- update-genesis-assets
EOF
}
my ($git_resource_creds,$git_env_creds);
if ($pipeline->{pipeline}{git}{private_key}) {
$git_resource_creds = " private_key: (( grab pipeline.git.private_key ))";
$git_env_creds = " GIT_PRIVATE_KEY: (( grab pipeline.git.private_key ))";
} else {
$git_resource_creds = " username: (( grab pipeline.git.username ))\n password: (( grab pipeline.git.password ))";
$git_env_creds = " GIT_USERNAME: (( grab pipeline.git.username ))\n GIT_PASSWORD: (( grab pipeline.git.password || \"\" ))";
}
my $git_genesis_root = $pipeline->{pipeline}{git}{root} ne '.' ? " GIT_GENESIS_ROOT: $pipeline->{pipeline}{git}{root}\n" : "";

print $OUT <<EOF;
resources:
- name: git
type: git
.: (( inject pipeline.git.config ))
source:
branch: (( grab pipeline.git.branch ))
$git_resource_creds
uri: (( grab pipeline.git.uri ))
.: (( inject pipeline.git.resource_source ))
EOF
if ($pipeline->{pipeline}{git}{version_depth}) {
print $OUT " version_depth: $pipeline->{pipeline}{git}{version_depth}\n";
Expand Down Expand Up @@ -919,7 +918,7 @@ EOF
type: git
.: (( inject pipeline.git.config ))
source:
.: (( inject resources.git.source ))
.: (( inject pipeline.git.resource_source ))
paths:
EOF
# }}}
Expand Down Expand Up @@ -953,7 +952,7 @@ EOF
type: git
.: (( inject pipeline.git.config ))
source:
.: (( inject resources.git.source ))
.: (( inject pipeline.git.resource_source ))
paths:
EOF
print $OUT "# $trigger -> $env\n";
Expand Down

0 comments on commit 796a88f

Please sign in to comment.