$npx -y skills add opendatahub-io/ai-helpers --skill konflux-componentManage Konflux component
| 1 | ## Name |
| 2 | odh-ai-helpers:konflux-component |
| 3 | |
| 4 | ## Synopsis |
| 5 | |
| 6 | ``` |
| 7 | /konflux:component status <component> |
| 8 | /konflux:component build <components> [--wait duration] [--nudge] [--wait-for-release release-duration] |
| 9 | ``` |
| 10 | |
| 11 | ## Description |
| 12 | The `konflux:component` command to manage Konflux component(s). |
| 13 | |
| 14 | This command helps you: |
| 15 | - Get status of a component - last build, commit message, snapshot and release |
| 16 | - Trigger build of a component and wait until the build or release is done |
| 17 | |
| 18 | ## Implementation |
| 19 | |
| 20 | ### Subcommand: status |
| 21 | |
| 22 | The command performs the following steps: |
| 23 | |
| 24 | 1. **Prerequisites Check**: |
| 25 | - Verify `oc` CLI is installed: `which oc` |
| 26 | - Verify cluster access: `oc whoami` |
| 27 | - If not installed or not authenticated, provide clear instructions |
| 28 | - Verify `git` CLI is installed: `which git` |
| 29 | - Verify the current directory is a Git repository: `git remote -v` |
| 30 | |
| 31 | 2. **Parse Arguments**: |
| 32 | - `component`: Component name (required) |
| 33 | |
| 34 | 3. **List components**: |
| 35 | - Get component |
| 36 | ```bash |
| 37 | kubeclt get component {component} -o yaml |
| 38 | ``` |
| 39 | - The application name is provided `.spec.application` |
| 40 | - The component name is provided `.spec.componentName` |
| 41 | - The Git repository URL is provided `.spec.source.git.url` |
| 42 | - The commit SHA is provided `.status.lastBuiltCommit` |
| 43 | - The image is provided `.status.lastPromotedImage` |
| 44 | |
| 45 | 4. **Get Git information**: |
| 46 | - Use `git branch -a --contains <commit-sha>` to find the branch name |
| 47 | - The Git repository should be in the current working directory. If it is not fail the command. |
| 48 | |
| 49 | 5. **Get Snapshots**: |
| 50 | - Get snapshots of the component and order by oldest |
| 51 | ```bash |
| 52 | kubectl get snapshot -l pac.test.appstudio.openshift.io/sha={commit},appstudio.openshift.io/component={component} --sort-by=.metadata.creationTimestamp |
| 53 | ``` |
| 54 | |
| 55 | 6. **Get Releases**: |
| 56 | - Get releases object for each snapshot |
| 57 | ```bash |
| 58 | kubectl get release -l pac.test.appstudio.openshift.io/sha={commit},appstudio.openshift.io/component={component} |
| 59 | ``` |
| 60 | - The snapshot is specified in `.spec.snapshot` |
| 61 | - The `.status.conditions` show if the release failed or succeeded |
| 62 | |
| 63 | 7. **Display result**: |
| 64 | - Display the result: |
| 65 | ``` |
| 66 | | Component | Built SHA | lastPromotedImage | Commit Message | Git Branch | Snapshots (oldest first) | |
| 67 | |------------------|-----------|----------------------|-----------------------------|--------------|--------------------------| |
| 68 | | {component} | {commit} | {lastPromotedImage} | {commit-message} | {git-branch} | {snapshots} | |
| 69 | | otel-bundle-main | 8ba2e60 | | Fix service account (#693) | main | otel-main-jnhfz | |
| 70 | ``` |
| 71 | - Display snapshot with release information for each snapshot |
| 72 | ``` |
| 73 | Component: {component} |
| 74 | | Snapshot | Release | Release status | |
| 75 | |-----------------|-------------------------------|------------------------------------------| |
| 76 | | {snapshot} | {release} | {release-status} | |
| 77 | | otel-main-jnhfz | otel-main-jnhfz-8ba2e60-nnwnp | Failed (ManagedPipelineProcessed failed) | |
| 78 | ``` |
| 79 | |
| 80 | ### Subcommand: build |
| 81 | |
| 82 | The command performs the following steps: |
| 83 | |
| 84 | 1. **Prerequisites Check**: |
| 85 | - Verify `oc` CLI is installed: `which oc` |
| 86 | - Verify cluster access: `oc whoami` |
| 87 | - If not installed or not authenticated, provide clear instructions |
| 88 | - Verify `git` CLI is installed: `which git` |
| 89 | - Verify the current directory is a Git repository |
| 90 | |
| 91 | 2. **Parse Arguments**: |
| 92 | - `$1`: Component(s) (required): Konflux Component(s) name |
| 93 | - `$2`: flag `--wait <duration>` (optional) wait duration for the build to finish |
| 94 | - The duration can have suffix `s` for seconds, `m` for minutes or `h` for hours. |
| 95 | - If other suffixes are specified fail the command |
| 96 | - `$3`: flag `--nudge` (optional) nudge files after the build finishes |
| 97 | - `--nudge` can be used only if `--wait` is used |
| 98 | - `$4`: flag `--wait-for-release <release-duration>` (optional) wait until release is done |
| 99 | - `--wait-for-release` can be used only if `--wait` is used |
| 100 | - The duration can have suffix `s` for seconds, `m` for minutes or `h` for hours. |
| 101 | |
| 102 | 3. **Trigger the build**: |
| 103 | - Annotate each component to trigger the build |
| 104 | ```bash |
| 105 | kubectl annotate components/{compponent} build.appstudio.openshift.io/request=trigger-pac-build |
| 106 | ``` |
| 107 | |
| 108 | 4. **Get the build information**: |
| 109 | ```bash |
| 110 | kubectl get pipelinerun -l appstudio.openshift.io/component={component} |
| 111 | ``` |
| 112 | - Wait up to 5 minutes, it takes time for the PipelineRun to be created |
| 113 | - The started pipeline name must have `-on-push` in the name |
| 114 | |
| 115 | 5. **Wait for the build to finish**: |
| 116 | - If `--wait <duration>` is provided wait for the PipelineRun t |