Last active
May 22, 2024 19:35
-
-
Save ralphbean/dbee2755b4077caa4056a46660d2907f to your computer and use it in GitHub Desktop.
Revisions
-
ralphbean revised this gist
May 22, 2024 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,14 +6,19 @@ filename=$1 taskname=$2 prefix=".spec.pipelineSpec" kind=$(yq .kind "$filename") if [ $kind == "Pipeline" ]; then prefix=".spec" fi task=$(cat "$filename" | yq "$prefix.tasks[] | select(.name == \"$taskname\")") bundle=$(echo "$task" | yq ".taskRef.params[] | select(.name == \"bundle\") | .value") bundle=$(echo $bundle | awk -F '@' '{ print $1 }') repo=$(echo $bundle | awk -F ':' '{ print $1 }') for layer in $(skopeo inspect --no-tags "docker://$bundle" | jq -r '.Layers[]'); do spec=$(oras blob fetch --no-tty $repo@$layer -o - | tar zxf - --to-stdout | yq .spec) done yq -i "del($prefix.tasks[] | select(.name == \"$taskname\") | .taskRef)" $filename yq -i "($prefix.tasks[] | select(.name == \"$taskname\") | .taskSpec) = $spec" $filename sed -i 's/\\\\/\\/g' $filename -
ralphbean revised this gist
May 16, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,3 +16,4 @@ done yq -i "del(.spec.pipelineSpec.tasks[] | select(.name == \"$taskname\") | .taskRef)" $filename yq -i "(.spec.pipelineSpec.tasks[] | select(.name == \"$taskname\") | .taskSpec) = $spec" $filename sed -i 's/\\\\/\\/g' $filename -
ralphbean revised this gist
May 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ bundle=$(echo "$task" | yq ".taskRef.params[] | select(.name == \"bundle\") | .v bundle=$(echo $bundle | awk -F '@' '{ print $1 }') repo=$(echo $bundle | awk -F ':' '{ print $1 }') for layer in $(skopeo inspect --no-tags "docker://$bundle" | jq -r '.Layers[]'); do spec=$(oras blob fetch --no-tty $repo@$layer -o - | tar zxf - --to-stdout | yq .spec) done yq -i "del(.spec.pipelineSpec.tasks[] | select(.name == \"$taskname\") | .taskRef)" $filename -
ralphbean created this gist
Apr 19, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #!/bin/bash -e # Given a filename with a pipelines-as-code pipelinerun and a task name within it # remove the bundle taskref and replace it with an inline version of the task definition. # For hacking. filename=$1 taskname=$2 task=$(cat "$filename" | yq ".spec.pipelineSpec.tasks[] | select(.name == \"$taskname\")") bundle=$(echo "$task" | yq ".taskRef.params[] | select(.name == \"bundle\") | .value") bundle=$(echo $bundle | awk -F '@' '{ print $1 }') repo=$(echo $bundle | awk -F ':' '{ print $1 }') for layer in $(skopeo inspect --no-tags "docker://$bundle" | jq -r '.Layers[]'); do spec=$(oras blob fetch --no-tty $repo@$layer -o - | tar zxf - --to-stdout) done yq -i "del(.spec.pipelineSpec.tasks[] | select(.name == \"$taskname\") | .taskRef)" $filename yq -i "(.spec.pipelineSpec.tasks[] | select(.name == \"$taskname\") | .taskSpec) = $spec" $filename