Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
168 changes: 168 additions & 0 deletions .tekton/acs-instance-report-cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: acs-instance-report-cron
namespace: acscs-rhacs-tenant
annotations:
pipelinesascode.tekton.dev/on-cron-expression: "0 7 * * 5"
pipelinesascode.tekton.dev/target-branch: main
pipelinesascode.tekton.dev/max-keep-runs: "3"
labels:
appstudio.openshift.io/application: acscs-main
spec:
params:
- name: git-url
value: '{{source_url}}'
- name: revision
value: '{{revision}}'
- name: konflux-base-url
value: "https://konflux-ui.apps.stone-prd-rh01.pg1f.p1.openshiftapps.com"
- name: konflux-application-name
value: acscs-main
pipelineSpec:
params:
- name: git-url
type: string
- name: revision
type: string
- name: konflux-base-url
type: string
- name: konflux-application-name
type: string
tasks:
- name: clone-repository
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.revision)
taskRef:
resolver: bundles
params:
- name: name
value: git-clone
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-git-clone:0.1@sha256:fedaacbf05ff7b2cdd36bff6cb1f103755cb5dc0b4adc0540136d3606ade18a5
- name: kind
value: task
workspaces:
- name: output
workspace: workspace
- name: basic-auth
workspace: git-auth
- name: build-and-report
runAfter:
- clone-repository
params:
- name: pipeline-run-url
value: "$(params.konflux-base-url)/ns/$(context.pipelineRun.namespace)/applications/$(params.konflux-application-name)/pipelineruns/$(context.pipelineRun.name)"
- name: pipeline-run-name
value: $(context.pipelineRun.name)
workspaces:
- name: source
workspace: workspace
taskSpec:
params:
- name: pipeline-run-url
type: string
- name: pipeline-run-name
type: string
results:
- name: message
description: Formatted report message for Slack
workspaces:
- name: source
steps:
- name: build-and-report
image: registry.access.redhat.com/ubi9/go-toolset:1.26.3@sha256:430cd439ea3bb4af3727a843c0302594bb1973211ecbfc98e4450a40798075df
workingDir: $(workspaces.source.path)
env:
- name: RHSSO_SERVICE_ACCOUNT_CLIENT_ID
valueFrom:
secretKeyRef:
name: acs-instance-report
key: client-id
- name: RHSSO_SERVICE_ACCOUNT_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: acs-instance-report
key: client-secret
- name: RHSSO_ENDPOINT
value: "https://auth.redhat.com"
- name: RHSSO_REALM
value: "EmployeeIDP"
- name: FLEET_MANAGER_API_URL
value: "https://api.openshift.com"
- name: PIPELINE_RUN_NAME
value: $(params.pipeline-run-name)
- name: PIPELINE_RUN_URL
value: $(params.pipeline-run-url)
script: |
#!/bin/bash
set -u

if ! BUILD_OUTPUT=$(make fleet-manager 2>&1); then
MESSAGE="Failed to build fleet-manager binary\n\n${BUILD_OUTPUT}"
EXIT_CODE=1
else
REPORT=$(./fleet-manager admin central report \
--api-url="${FLEET_MANAGER_API_URL}" \
--auth-type=RHSSO 2>&1)
EXIT_CODE=$?

if [ "${EXIT_CODE}" -ne 0 ]; then
MESSAGE="Instance report command returned error (exit code ${EXIT_CODE})\n\nOutput:\n${REPORT}"
else
MESSAGE="${REPORT}"
fi
fi

PIPELINE_LINK="<${PIPELINE_RUN_URL}|${PIPELINE_RUN_NAME}>"
printf '%s' "${MESSAGE}\n\nPipeline run: ${PIPELINE_LINK}" > $(results.message.path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

printf '%s' will not expand \n; Slack message will contain literal \n.

With %s, the \n\n between the message and pipeline link (and the \n\n embedded in the build-failure MESSAGE) are emitted as literal backslash-n rather than newlines. Use %b (or actual newlines) so the separators render correctly.

🔧 Proposed fix
-            printf '%s' "${MESSAGE}\n\nPipeline run: ${PIPELINE_LINK}" > $(results.message.path)
+            printf '%b' "${MESSAGE}\n\nPipeline run: ${PIPELINE_LINK}" > $(results.message.path)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
printf '%s' "${MESSAGE}\n\nPipeline run: ${PIPELINE_LINK}" > $(results.message.path)
printf '%b' "${MESSAGE}\n\nPipeline run: ${PIPELINE_LINK}" > $(results.message.path)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.tekton/acs-instance-report-cron.yaml at line 121, Update the printf command
in the pipeline report step to use a format that interprets escaped newline
sequences, such as %b, so the separators in MESSAGE and PIPELINE_LINK render as
actual blank lines rather than literal \n text.

exit "${EXIT_CODE}"
computeResources:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
finally:
- name: send-notification
params:
- name: message
value: $(tasks.build-and-report.results.message)
- name: secret-name
value: acs-instance-report
- name: key-name
value: slack-webhook-url
taskRef:
resolver: bundles
params:
- name: name
value: slack-webhook-notification
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-slack-webhook-notification:0.1@sha256:d34a3789505f829493636a265eb04790695dba84bbb2bb716a7551a6911f2816
- name: kind
value: task
workspaces:
- name: workspace
- name: git-auth
optional: true
taskRunTemplate:
serviceAccountName: build-pipeline-acs-fleet-manager
workspaces:
- name: workspace
volumeClaimTemplate:
metadata:
creationTimestamp: null
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
status: {}
- name: git-auth
secret:
secretName: '{{ git_auth_secret }}'
2 changes: 0 additions & 2 deletions cmd/acsfleetctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/cmd/admin"
"github.com/stackrox/acs-fleet-manager/internal/central/pkg/cmd/centrals"
gitopsCmd "github.com/stackrox/acs-fleet-manager/internal/central/pkg/gitops/cmd"
)
Expand All @@ -26,6 +25,5 @@ func main() {

func setupSubCommands(rootCmd *cobra.Command) {
rootCmd.AddCommand(centrals.NewCentralsCommand())
rootCmd.AddCommand(admin.NewAdminCommand())
rootCmd.AddCommand(gitopsCmd.NewGitOpsCommand())
}
2 changes: 2 additions & 0 deletions cmd/fleet-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main
import (
"flag"

"github.com/stackrox/acs-fleet-manager/internal/central/pkg/cmd/admin"
"github.com/stackrox/acs-fleet-manager/pkg/cmd/migrate"
"github.com/stackrox/acs-fleet-manager/pkg/cmd/serve"

Expand Down Expand Up @@ -44,6 +45,7 @@ func main() {
glog.Fatalf("Unable to add global flags: %s", err.Error())
}

rootCmd.AddCommand(admin.NewAdminCommand())
rootCmd.AddCommand(migrate.NewMigrateCommand(env))
rootCmd.AddCommand(serve.NewServeCommand(env))
// Unsupported CLI commands. Eventually some of them can be removed.
Expand Down
2 changes: 2 additions & 0 deletions internal/central/pkg/api/admin/private/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions internal/central/pkg/api/admin/private/model_central.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions internal/central/pkg/cmd/admin/centrals/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const (
// NewAdminCentralsCommand creates a new admin central command.
func NewAdminCentralsCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "centrals",
Aliases: []string{"central"},
Short: "Perform admin central API calls.",
Long: "Perform admin central API calls.",
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
Use: "centrals",
Aliases: []string{"central"},
Short: "Perform admin central API calls.",
Long: "Perform admin central API calls.",
}
cmd.AddCommand(
NewAdminCentralsListCommand(),
NewAdminReportCommand(),
)

return cmd
Expand Down
2 changes: 1 addition & 1 deletion internal/central/pkg/cmd/admin/centrals/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewAdminCentralsListCommand() *cobra.Command {
Short: "lists all managed central requests",
Long: "lists all managed central requests",
Run: func(cmd *cobra.Command, args []string) {
runList(fleetmanagerclient.AuthenticatedClientWithRHOASToken(cmd.Context()), cmd, args)
runList(fleetmanagerclient.ClientFromContext(cmd.Context()), cmd, args)
},
}
return cmd
Expand Down
Loading
Loading