Skip to content

[DRAFT] - AAP-24999 #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1993649
init commit / changing tags
SiddharthRajaraman Jun 13, 2024
a9cd9f4
adding bundle image tasks
SiddharthRajaraman Jun 13, 2024
3113cf0
testing build catalog index
SiddharthRajaraman Jun 17, 2024
5d6480f
testing prepare catalog
SiddharthRajaraman Jun 17, 2024
7aa364f
adding to results
SiddharthRajaraman Jun 17, 2024
48f9af0
testing prepare-catalog
SiddharthRajaraman Jun 17, 2024
2a6fbf5
removing build img path
SiddharthRajaraman Jun 17, 2024
7c85bd4
changing prepare catalog script
SiddharthRajaraman Jun 17, 2024
5302990
moving to bash script
SiddharthRajaraman Jun 17, 2024
e6e7092
fixes
SiddharthRajaraman Jun 17, 2024
8f900e4
installing buildah and moving dockerfile
SiddharthRajaraman Jun 17, 2024
2d6c744
removing buildah installation
SiddharthRajaraman Jun 17, 2024
167dd4f
echo to find shell
SiddharthRajaraman Jun 17, 2024
e70ed01
different command to find shell and printing hi
SiddharthRajaraman Jun 17, 2024
5cc4873
different shell command
SiddharthRajaraman Jun 17, 2024
2d816e9
forgot echo
SiddharthRajaraman Jun 17, 2024
4f46b23
testing bash and zsh versions
SiddharthRajaraman Jun 17, 2024
44d5330
removing echos
SiddharthRajaraman Jun 17, 2024
fa68c8f
testing simple commands
SiddharthRajaraman Jun 17, 2024
dce4b02
testing more code in buildah image
SiddharthRajaraman Jun 17, 2024
5c673c1
removing bad code
SiddharthRajaraman Jun 24, 2024
d01d9a9
changing capital to lowercase
SiddharthRajaraman Jun 24, 2024
16e4649
removing comment
SiddharthRajaraman Jun 24, 2024
9827f1f
check contents after bundle
SiddharthRajaraman Jun 24, 2024
76a5b06
entering bundle directory
SiddharthRajaraman Jun 24, 2024
a21051b
testing skopeo
SiddharthRajaraman Jun 24, 2024
2c34a88
adding --no-xattrs
SiddharthRajaraman Jun 24, 2024
90c4f44
stop using apk
SiddharthRajaraman Jun 24, 2024
6053f63
testing diff libs
SiddharthRajaraman Jun 24, 2024
852fe63
test pull
SiddharthRajaraman Jun 24, 2024
373f214
checking contents
SiddharthRajaraman Jun 24, 2024
a79f72d
checking contents
SiddharthRajaraman Jun 24, 2024
c5dc273
making dir
SiddharthRajaraman Jun 24, 2024
1547e46
not changing dir
SiddharthRajaraman Jun 24, 2024
a42547d
checking contents
SiddharthRajaraman Jun 24, 2024
039433f
adding to temp directory
SiddharthRajaraman Jun 24, 2024
6c2888f
blah
SiddharthRajaraman Jun 24, 2024
e34ec2c
testing pushes
SiddharthRajaraman Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 297 additions & 2 deletions .tekton/ansible-ai-connect-operator-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ spec:
value: $(params.git-url)
- name: revision
value: $(params.revision)
- name: fetchTags
value: true
runAfter:
- init
taskRef:
Expand All @@ -183,6 +185,297 @@ spec:
workspace: workspace
- name: basic-auth
workspace: git-auth
- name: git-metadata
runAfter:
- clone-repository
workspaces:
- name: source
workspace: workspace
taskSpec:
workspaces:
- name: source
steps:
- name: get-commit-timestamp
image: alpine/git
script: |
#!/bin/sh
set -euo pipefail
cd "$(workspaces.source.path)/source"
echo -n $(date -d @$(git log -1 --format=%at) "+%Y%m%d%H%M") > $(results.commit-timestamp.path)
results:
- name: commit-timestamp
- name: common-get-operator-versions
runAfter:
- clone-repository
workspaces:
- name: source
workspace: workspace
taskSpec:
workspaces:
- name: source
steps:
- name: get-latest-tag
image: alpine/git
script: |
#!/bin/sh
set -euo pipefail
cd "$(workspaces.source.path)/source"
LATEST_TAG=$(git tag -l --sort=v:refname | tail -n1)
echo -n $LATEST_TAG > $(results.operator_version_latest.path)

echo -n $LATEST_TAG

MAJOR=$(echo $LATEST_TAG | cut -d. -f1)
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
PATCH=$(echo $LATEST_TAG | cut -d. -f3)
PATCH=$((PATCH + 1))
NEW_TAG="$MAJOR.$MINOR.$PATCH"
echo -n $NEW_TAG > $(results.operator_version_next.path)
echo -n $NEW_TAG

results:
- name: operator_version_latest
description: the _latest_ Operator version
- name: operator_version_next
description: The _next_ Operator version
- name: bundle
runAfter:
- clone-repository
- common-get-operator-versions
workspaces:
- name: source
workspace: workspace
taskSpec:
params:
- name: IMAGE
default: quay.io/ansible/ansible-ai-connect-konflux
- name: ADDITIONAL_TAGS
default: ""
- name: STORAGE_DRIVER
default: overlay
workspaces:
- name: source
steps:
- name: bundle
image: quay.io/operator-framework/operator-sdk:v1.10.0
script: |
cd "$(workspaces.source.path)/source"
operator-sdk generate kustomize manifests -q

# install kustomize
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
mv kustomize /usr/local/bin/

cd config/manager

kustomize edit set image controller=$(params.IMAGE):0.1.0

cd ../..
kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 0.1.0
operator-sdk bundle validate ./bundle

echo "====================="
ls
echo "====================="
cd bundle
echo "cd bundle"
echo "====================="
ls
echo "====================="
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
securityContext:
capabilities:
add: ["SETFCAP"]
volumes:
- name: varlibcontainers
emptyDir: {}
- name: update-cluster-service-version
runAfter:
- bundle
workspaces:
- name: source
workspace: workspace
taskSpec:
workspaces:
- name: source
steps:
- name: update-cluster-service-version
image: alpine/git
script: |
#!/bin/sh
set -euo pipefail
cd "$(workspaces.source.path)/source"
if [[ "$(tasks.common-get-operator-versions.results.operator_version_latest)" == "0.0.0" ]]; then
>&2 echo "No previous version found."
exit 0
fi

VERSION="$(tasks.common-get-operator-versions.results.operator_version_next)"
PREV_VERSION="$(tasks.common-get-operator-versions.results.operator_version_latest)"
if ! grep -qF "replaces: ansible-ai-connect-operator.v${PREV_VERSION}" bundle/manifests/ansible-ai-connect-operator.clusterserviceversion.yaml; then
sed -i "/version: ${VERSION}/a\\
replaces: ansible-ai-connect-operator.v${PREV_VERSION}" ./bundle/manifests/ansible-ai-connect-operator.clusterserviceversion.yaml
fi
- name: bundle-build-push
runAfter:
- update-cluster-service-version
workspaces:
- name: source
workspace: workspace
taskSpec:
params:
- name: IMAGE
default: quay.io/ansible/ansible-ai-connect-konflux
- name: ADDITIONAL_TAGS
default: ""
- name: STORAGE_DRIVER
default: overlay
workspaces:
- name: source
steps:
- name: bundle-build
image: quay.io/buildah/stable:v1.17.0
script: |
cd "$(workspaces.source.path)/source"

OPERATOR_VERSION_NEXT=$(tasks.common-get-operator-versions.results.operator_version_next)
ADDITIONAL_TAGS="$(params.IMAGE):bundle-$OPERATOR_VERSION_NEXT-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp) $(params.IMAGE):$OPERATOR_VERSION_NEXT"

buildah --storage-driver=$(params.STORAGE_DRIVER) bud \
--no-cache -f bundle.Dockerfile -t $(params.IMAGE) .

for tag in $ADDITIONAL_TAGS; do
buildah tag $(params.IMAGE) $tag
done
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
securityContext:
capabilities:
add: ["SETFCAP"]
- name: bundle-push
image: quay.io/buildah/stable:v1.17.0
script: |
OPERATOR_VERSION_NEXT=$(tasks.common-get-operator-versions.results.operator_version_next)
ADDITIONAL_TAGS="$(params.IMAGE):bundle-$OPERATOR_VERSION_NEXT-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp) $(params.IMAGE):$OPERATOR_VERSION_NEXT"

for tag in $ADDITIONAL_TAGS; do
buildah --storage-driver=$(params.STORAGE_DRIVER) push \
$tag
done
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
securityContext:
capabilities:
add: ["SETFCAP"]
volumes:
- name: varlibcontainers
emptyDir: {}

- name: build-catalog-index-bundle-image-list
runAfter:
- clone-repository
workspaces:
- name: source
workspace: workspace
taskSpec:
workspaces:
- name: source
steps:
- name: build-catalog-index-bundle-image-list
image: alpine/git
script: |
#!/bin/sh
set -euo pipefail

# Install bash
apk add --no-cache bash skopeo

# Create the actual script to run
cat << 'EOF' > /tmp/script.sh
#!/bin/bash
set -euo pipefail
cd "$(workspaces.source.path)/source"
LATEST_TAGS=($(git tag -l --sort=v:refname))
echo "${LATEST_TAGS[@]}"

# Filter array by tags that end with a semver
filtered_tags=()
regex="^([0-9]+\.[0-9]+\.[0-9]+)$"
for i in "${LATEST_TAGS[@]}" ; do
if [[ $i =~ $regex ]]; then
filtered_tags+=("quay.io/ansible/ansible-ai-connect-bundle:${BASH_REMATCH[1]}") ;
fi
done

echo "${filtered_tags[@]}"

# Include the version being built
filtered_tags+=("quay.io/ansible/ansible-ai-connect-bundle:$(tasks.common-get-operator-versions.results.operator_version_next)")

# Convert array back to comma separated list
output_tags=${filtered_tags[@]}
output=${output_tags// /,}

echo "================"
echo "${output}"
echo "================"


mkdir temp
skopeo copy --src-creds srajaram:LBtYCLwC9JgPwf3lFNMZMjim6NBA42siAIo2JlprKwEr1k2kXACxxDiiaSrPrChg6WDzmviEX6A7YATtiT+DhA== docker://quay.io/ansible/ansible-ai-connect-bundle:0.1.0 dir:/temp

echo "================"
ls
echo "================"
echo "cd temp"

# echo "${output}" > $(results.build-imgs.path)

exit 0
EOF

# Make the script executable
chmod +x /tmp/script.sh

# Execute the script using bash
/bin/bash /tmp/script.sh
results:
- name: build-imgs

- name: prepare-catalog
runAfter:
- build-catalog-index-bundle-image-list
workspaces:
- name: source
workspace: workspace
taskSpec:
workspaces:
- name: source
steps:
- name: prepare-catalog
image: quay.io/buildah/stable:v1.17.0
script: |
echo "hi"
#!/bin/bash
set -euo pipefail
echo $(tasks.build-catalog-index-bundle-image-list.results.build-imgs)













- name: prefetch-dependencies
params:
- name: input
Expand Down Expand Up @@ -225,8 +518,7 @@ spec:
- name: COMMIT_SHA
value: $(tasks.clone-repository.results.commit)
- name: BUILD_ARGS
value:
- $(params.build-args[*])
value: ["IMAGE_TAGS=$(tasks.common-get-operator-versions.results.operator_version_next)-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp)"]
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
runAfter:
Expand Down Expand Up @@ -411,8 +703,11 @@ spec:
params:
- name: IMAGE
value: $(tasks.build-container.results.IMAGE_URL)
- name: ADDITIONAL_TAGS
value: ["$(tasks.common-get-operator-versions.results.operator_version_next)-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp)"]
runAfter:
- build-container
- common-get-operator-versions
taskRef:
params:
- name: name
Expand Down
Loading
Loading