Skip to content

Add cli tooling checks and downloads#141

Draft
fgharo wants to merge 8 commits into
mainfrom
add-cli-tooling-checks-and-downloads
Draft

Add cli tooling checks and downloads#141
fgharo wants to merge 8 commits into
mainfrom
add-cli-tooling-checks-and-downloads

Conversation

@fgharo

@fgharo fgharo commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds default download logic in the event yq is not already installed on the user's machine when bootstrapping. Also during download failure it prompts the user to halt or continue.

Checklist

  • You have completed the described test plan and included screenshots in the PR or comments showing the results
  • Relevant documentation has been updated
  • You have squashed commits (including commits to test from your branch) to be logical and reduce unnecessary commits

Test Plan

Carried out the following use cases:

  1. [DONE] Installing yq on Linux for first time. Yq is downloaded without error.
source scripts/functions.sh
setup_bin
check_bin yq
    Validating CLI tool: yq
    /usr/bin/which: no yq in (/home/fharo/Documents/Workspace/practices/ai-practice/work/ai-accelerator-issues/add-yq-cli-tooling-check-and-download/source-code/ai-accelerator/tmp/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.local/bin:/home/fharo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
    Downloading Yq CLI: https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
    yq                   100% [=======================================================>]   10.91M    2.35MB/s
                            [Files: 1  Bytes: 10.91M [2.29MB/s] Redirects: 2  Todo: 0]
    Continuing...
    /home/fharo/Documents/Workspace/practices/ai-practice/work/ai-accelerator-issues/add-yq-cli-tooling-check-and-download/source-code/ai-accelerator

    yq (https://github.com/mikefarah/yq/) version v4.47.1
  1. [DONE] Download of yq on Linux for first time fails. User is prompted to continue or halt.
mv tmp/bin/yq  tmp/bin/yq.bak # Simulate yq absence.
source scripts/functions.sh
setup_bin
check_bin yq
    Validating CLI tool: yq
    /usr/bin/which: no yq in (/home/fharo/Documents/Workspace/practices/ai-practice/work/ai-accelerator-issues/add-yq-cli-tooling-check-and-download/source-code/ai-accelerator/tmp/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.jbang/bin:/home/fharo/.jenv/shims:/home/fharo/.jenv/bin:/home/fharo/.local/bin/apache-maven-3.6.3/bin:/home/fharo/.local/bin/node-v14.17.0-linux-x64/bin:/home/fharo/.local/bin:/home/fharo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
    Downloading Yq CLI: https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd644
    0 files              100% [=======================================================>]  125.86K  466.08KB/s
                              [Files: 0  Bytes: 125.86K [147.04KB/s] Redirects: 1  Todo]
    The download failed. Do you want to continue with the script? (y/n): 
  1. [DONE] Yq already installed on Linux with high enough version. Script moves onto printing the version of yq.
mv tmp/bin/yq  tmp/bin/yq.bak # Simulate yq absence.
source scripts/functions.sh
setup_bin
check_bin yq
    Validating CLI tool: yq
    ~/Documents/Workspace/practices/ai-practice/work/ai-accelerator-issues/add-yq-cli-tooling-check-and- 
    download/source-code/ai-accelerator/tmp/bin/yq

    yq (https://github.com/mikefarah/yq/) version v4.47.1
  1. [DONE] Installing yq on Mac for first time. Yq is downloaded without error.
fharo-mac:ai-accelerator fharo$ source scripts/functions.sh 
fharo-mac:ai-accelerator fharo$ setup_bin 
fharo-mac:ai-accelerator fharo$ check_bin yq
Validating CLI tool: yq
Downloading Yq CLI: https://github.com/mikefarah/yq/releases/latest/download/yq_darwin_arm64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 10.5M  100 10.5M    0     0  7246k      0  0:00:01  0:00:01 --:--:-- 7246k

yq (https://github.com/mikefarah/yq/) version v4.47.1
  1. [DONE] Download of yq on Mac fails. User is prompted to continue or halt.
fharo-mac:ai-accelerator fharo$ check_bin yq
Validating CLI tool: yq
Downloading Yq CLI: https://github.com/mikefarah/yq/releases/latest/download/yq_darwin_arm645
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     9    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (56) The requested URL returned error: 404
The download failed. Do you want to continue with the script? (y/n): y
Continuing ...
  1. [DONE] Yq already installed on Mac. Script moves onto printing the version of yq.
fharo-mac:ai-accelerator fharo$ sudo mv /usr/local/bin/yq.bak /usr/local/bin/yq
Password:
fharo-mac:ai-accelerator fharo$ source scripts/functions.sh 
fharo-mac:ai-accelerator fharo$ setup_bin 
fharo-mac:ai-accelerator fharo$ check_bin yq
Validating CLI tool: yq
/Users/fharo/Workspace/ai-practice/ai-accelerator/tmp/bin/yq

yq (https://github.com/mikefarah/yq/) version v4.47.1
  1. [DONE] Version of cli already installed on Linux is too old. Script either halts, or warn the end user before continuing.
$ ./bootstrap.sh 
Validating CLI tool: oc
/home/fharo/.local/bin/oc
oc case
Downloading OpenShift CLI: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.18/openshift-client-linux.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:  0 69.9M    0 51723    0     0  57224      0  0:21:21 --:--:--  0:21:21 57215oc
  2 69.9M    2 1596k    0     0   841k      0  0:01:  3 69.9M    3 2732k    0     0   941k      0  0:01:  6 69.9M    6 4668k    0     0  1193k      0  0:01: 12 69.9M   12 8940k    0     0  1826k      0  0:00: 18 69.9M   18 13.0M    0     0  2258k      0  0:00:31  0:00:05  0 24 69.9M   24 17.4M    0     0  2591k      0  0:00:27  0:00:06  0 31 69.9M   31 22.3M    0     0  2893k      0  0:00:24  0:00:07  0 40 69.9M   40 28.0M    0     0  3225k      0  0:00:22  0:00:08  0 49 69.9M   49 34.3M    0     0  3557k      0  0:00:20  0:00:09  0 56 69.9M   56 39.2M    0     0  3683k      0  0:00:19  0:00:10  0 63 69.9M   63 44.7M    0     0  3854k      0  0:00:18  0:00:11  0 73 69.9M   73 51.7M    0     0  4109k      0  0:00:17  0:00:12  0 81 69.9M   81 57.1M    0     0  4208k      0  0:00:17  0:00:13  0 86 69.9M   86 60.4M    0     0  4154k      0  0:00:17  0:00:14  0 92 69.9M   92 64.5M    0     0  4158k      0  0:00:17  0:00:15  0 97 69.9M   97 68.3M    0     0  4139k      0  0:00:17  0:00:16  0100 69.9M  100 69.9M    0     0  4170k      0  0:00:17  0:00:17 --:--:-- 4353k
auto-complete: . <(oc completion bash)
Client Version: 4.18.21
Kustomize Version: v5.4.2
Server Version: 4.18.21
Kubernetes Version: v1.31.10

Validating CLI tool: kustomize
/home/fharo/.local/bin/kustomize
other case
kustomize version 5.1.0 is less than expected 5.4.0.
Do you want to download newer cli version before continuing with the script? (y/n): y
Continuing with download ...
v5.7.1
kustomize installed to /home/fharo/Documents/Workspace/practices/ai-practice/work/ai-accelerator-issues/add-yq-cli-tooling-check-and-download/source-code/ai-accelerator/tmp/bin/kustomize
auto-complete: . <(kustomize completion bash)
v5.7.1

Validating CLI tool: yq
/usr/local/bin/yq
yq case
Downloading Yq CLI: https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- -- 17 10.9M   17 1935k    0     0  1042k      0  0:00:10  0:00:01  0 47 10.9M   47 5340k    0     0  1870k      0  0:00:05  0:00:02  0 85 10.9M   85 9532k    0     0  2459k      0  0:00:04  0:00:03  0100 10.9M  100 10.9M    0     0  2630k      0  0:00:04  0:00:04 --:--:-- 3303k

yq (https://github.com/mikefarah/yq/) version v4.47.1

Kubernetes control plane is running at https://api.cluster-dk2fx.dk2fx.sandbox1294.opentlc.com:6443
kube:admin


Checking if GitOps Operator is already installed and running

GitOps operator is already installed and running

1) rhoai-eus-2.16-aws-gpu     5) rhoai-stable-2.19-aws-gpu
2) rhoai-eus-2.16             6) rhoai-stable-2.19
3) rhoai-fast-aws-gpu         7) rhoai-stable-2.22-aws-gpu
4) rhoai-fast                 8) rhoai-stable-2.22
Please enter a number to select a bootstrap folder: 5

Selected: rhoai-stable-2.19-aws-gpu


Your working branch add-cli-tooling-checks-and-downloads, matches your cluster overlay branch add-cli-tooling-checks-and-downloads

Your current working repo is
  https://github.com/redhat-ai-services/ai-accelerator

Your cluster overlay repo is
  https://github.com/redhat-ai-services/ai-accelerator.git

Do you wish to update it to the following?
  https://github.com/https://github.com/redhat-ai-services/ai-accelerator.git

1) Yes
2) No
Please enter a number to select: 2
Apply overlay to override default instance
clusterrolebinding.rbac.authorization.k8s.io/openshift-gitops-application-controller-cluster-admin configured
appproject.argoproj.io/cluster-config configured
appproject.argoproj.io/gitops-config configured
appproject.argoproj.io/operators-config configured
appproject.argoproj.io/tenants configured
application.argoproj.io/cluster-config-app-of-apps configured
applicationset.argoproj.io/cluster-configs configured
applicationset.argoproj.io/cluster-operators configured
applicationset.argoproj.io/tenants configured
argocd.argoproj.io/openshift-gitops configured
group.user.openshift.io/gitops-admins configured
Checking status of all openshift-gitops pods
Waiting for deployment/cluster state to be condition=Available...
deployment.apps/cluster condition met
Waiting for statefulset/openshift-gitops-application-controller state to be jsonpath={.status.readyReplicas}=1...
pod/openshift-gitops-application-controller-0 condition met
Waiting for deployment/openshift-gitops-applicationset-controller state to be condition=Available...
deployment.apps/openshift-gitops-applicationset-controller condition met
Waiting for deployment/openshift-gitops-redis state to be condition=Available...
deployment.apps/openshift-gitops-redis condition met
Waiting for deployment/openshift-gitops-repo-server state to be condition=Available...
deployment.apps/openshift-gitops-repo-server condition met
Waiting for deployment/openshift-gitops-server state to be condition=Available...
deployment.apps/openshift-gitops-server condition met

Restart the application-controller to start the sync
pod "openshift-gitops-application-controller-0" deleted
Checking status of all openshift-gitops pods
Waiting for deployment/cluster state to be condition=Available...
deployment.apps/cluster condition met
Waiting for statefulset/openshift-gitops-application-controller state to be jsonpath={.status.readyReplicas}=1...
pod/openshift-gitops-application-controller-0 condition met
Waiting for deployment/openshift-gitops-applicationset-controller state to be condition=Available...
deployment.apps/openshift-gitops-applicationset-controller condition met
Waiting for deployment/openshift-gitops-redis state to be condition=Available...
deployment.apps/openshift-gitops-redis condition met
Waiting for deployment/openshift-gitops-repo-server state to be condition=Available...
deployment.apps/openshift-gitops-repo-server condition met
Waiting for deployment/openshift-gitops-server state to be condition=Available...
deployment.apps/openshift-gitops-server condition met

GitOps has successfully deployed!  Check the status of the sync here:
https://openshift-gitops-server-openshift-gitops.apps.cluster-dk2fx.dk2fx.sandbox1294.opentlc.com

@fgharo

fgharo commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

@carlmes Starting this Draft PR to get some feedback from you so as not to make too many assumptions about the solution before moving on with other use cases.

I have tested 3 basic scenarios on Linux. However is this the sort of behavior you were thinking of?

Namely the following:

  1. Am I missing any use cases in the test plan?
  2. Can we push the download failure scenarios for the other binaries oc, kustomize, etc out to another ticket? I just feel like its scope creep but you let me know.
  3. For test case 4. Is it okay to make the assumption that the latest actual version of yq as of this writing (Aug 6th 2025, version v4.47.1) is the version in the file we can pin/test against for checking whether any subsequent user's yq version is "high" enough?

@fgharo fgharo linked an issue Aug 6, 2025 that may be closed by this pull request
@carlmes

carlmes commented Aug 7, 2025

Copy link
Copy Markdown
Member

That looks great! Thanks for doing the comprehensive tests too, it's amazing how many variants of operating system and tooling could potentially exist on a workstation where the bootstrap script is run.

I'm going to ping this PR in the Slack channel for the accelerator bootcamp training to see if anyone else has any special / unique requests, but otherwise the updates made so far look great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add additional CLI tooling checks and downloads

2 participants