From 74659fd653e29b01de9b7bd16b727144be8c354e Mon Sep 17 00:00:00 2001 From: Jozef Marko Date: Wed, 18 Dec 2024 15:20:31 +0100 Subject: [PATCH 1/5] kie-issues#1547: DMN Editor: Render evaluation highlights in the Boxed Expression Editor (#2681) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luiz João Motta --- .../src/BoxedExpressionEditor.tsx | 3 + .../src/BoxedExpressionEditorContext.tsx | 3 + .../src/api/BeeTable.ts | 2 + .../ConditionalExpression.tsx | 12 +- .../DecisionTableExpression.tsx | 5 + .../src/table/BeeTable/BeeTable.css | 76 ++++++++ .../src/table/BeeTable/BeeTable.tsx | 2 + .../src/table/BeeTable/BeeTableBody.tsx | 32 ++- .../src/table/BeeTable/BeeTableTd.tsx | 22 ++- .../stories/boxedExpressionStoriesWrapper.tsx | 1 + .../Conditional/Conditional.stories.tsx | 184 ++++++++++++++++++ .../DecisionTable/DecisionTable.stories.tsx | 77 ++++++++ 12 files changed, 411 insertions(+), 8 deletions(-) diff --git a/packages/boxed-expression-component/src/BoxedExpressionEditor.tsx b/packages/boxed-expression-component/src/BoxedExpressionEditor.tsx index 920e4110257..de4354ec49a 100644 --- a/packages/boxed-expression-component/src/BoxedExpressionEditor.tsx +++ b/packages/boxed-expression-component/src/BoxedExpressionEditor.tsx @@ -59,6 +59,7 @@ export interface BoxedExpressionEditorProps { isReadOnly?: boolean; /** PMML models available to use on Boxed PMML Function */ pmmlDocuments?: PmmlDocument[]; + evaluationHitsCountById?: Map; /** The containing HTMLElement which is scrollable */ scrollableParentRef: React.RefObject; /** Parsed variables used for syntax coloring and auto-complete */ @@ -79,6 +80,7 @@ export function BoxedExpressionEditor({ isResetSupportedOnRootExpression, scrollableParentRef, pmmlDocuments, + evaluationHitsCountById, onRequestFeelVariables, widthsById, onWidthsChange, @@ -103,6 +105,7 @@ export function BoxedExpressionEditor({ isReadOnly={isReadOnly} dataTypes={dataTypes} pmmlDocuments={pmmlDocuments} + evaluationHitsCountById={evaluationHitsCountById} onRequestFeelVariables={onRequestFeelVariables} widthsById={widthsById} hideDmn14BoxedExpressions={hideDmn14BoxedExpressions} diff --git a/packages/boxed-expression-component/src/BoxedExpressionEditorContext.tsx b/packages/boxed-expression-component/src/BoxedExpressionEditorContext.tsx index ce879f8808c..5bf11e36f4e 100644 --- a/packages/boxed-expression-component/src/BoxedExpressionEditorContext.tsx +++ b/packages/boxed-expression-component/src/BoxedExpressionEditorContext.tsx @@ -34,6 +34,7 @@ export interface BoxedExpressionEditorContextType { pmmlDocuments?: PmmlDocument[]; dataTypes: DmnDataType[]; isReadOnly?: boolean; + evaluationHitsCountById?: Map; // State currentlyOpenContextMenu: string | undefined; @@ -74,6 +75,7 @@ export function BoxedExpressionEditorContextProvider({ beeGwtService, children, pmmlDocuments, + evaluationHitsCountById, scrollableParentRef, onRequestFeelVariables, widthsById, @@ -114,6 +116,7 @@ export function BoxedExpressionEditorContextProvider({ dataTypes, isReadOnly, pmmlDocuments, + evaluationHitsCountById, //state // FIXME: Move to a separate context (https://github.com/apache/incubator-kie-issues/issues/168) currentlyOpenContextMenu, diff --git a/packages/boxed-expression-component/src/api/BeeTable.ts b/packages/boxed-expression-component/src/api/BeeTable.ts index 68c662f4ba2..4a2db5972ca 100644 --- a/packages/boxed-expression-component/src/api/BeeTable.ts +++ b/packages/boxed-expression-component/src/api/BeeTable.ts @@ -97,6 +97,8 @@ export interface BeeTableProps { shouldShowColumnsInlineControls: boolean; resizerStopBehavior: ResizerStopBehavior; lastColumnMinWidth?: number; + /** Method should return true for table rows, that can display evaluation hits count, false otherwise. If not set, BeeTableBody defaults to false. */ + supportsEvaluationHitsCount?: (row: ReactTable.Row) => boolean; } /** Possible status for the visibility of the Table's Header */ diff --git a/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx b/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx index ab9871d81e8..ac4923eacce 100644 --- a/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx +++ b/packages/boxed-expression-component/src/expressions/ConditionalExpression/ConditionalExpression.tsx @@ -226,14 +226,23 @@ export function ConditionalExpression({ [setExpression] ); + const getRowKey = useCallback((row: ReactTable.Row) => { + return row.original.part["@_id"]; + }, []); + + const supportsEvaluationHitsCount = useCallback((row: ReactTable.Row) => { + return row.original.label !== "if"; + }, []); + return ( -
+
isReadOnly={isReadOnly} isEditableHeader={!isReadOnly} resizerStopBehavior={ResizerStopBehavior.SET_WIDTH_WHEN_SMALLER} tableId={id} + getRowKey={getRowKey} headerLevelCountForAppendingRowIndexColumn={1} headerVisibility={headerVisibility} cellComponentByColumnAccessor={cellComponentByColumnAccessor} @@ -247,6 +256,7 @@ export function ConditionalExpression({ shouldRenderRowIndexColumn={false} shouldShowRowsInlineControls={false} shouldShowColumnsInlineControls={false} + supportsEvaluationHitsCount={supportsEvaluationHitsCount} />
diff --git a/packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx b/packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx index e22e1da0ce0..ec9cf39be4b 100644 --- a/packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx +++ b/packages/boxed-expression-component/src/expressions/DecisionTableExpression/DecisionTableExpression.tsx @@ -1045,6 +1045,10 @@ export function DecisionTableExpression({ [beeTableRows.length] ); + const supportsEvaluationHitsCount = useCallback((row: ReactTable.Row) => { + return true; + }, []); + return (
@@ -1073,6 +1077,7 @@ export function DecisionTableExpression({ shouldRenderRowIndexColumn={true} shouldShowRowsInlineControls={true} shouldShowColumnsInlineControls={true} + supportsEvaluationHitsCount={supportsEvaluationHitsCount} // lastColumnMinWidth={lastColumnMinWidth} // FIXME: Check if this is a good strategy or not when doing https://github.com/apache/incubator-kie-issues/issues/181 />
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTable.css b/packages/boxed-expression-component/src/table/BeeTable/BeeTable.css index 7f18dc54aab..8a730ce590e 100644 --- a/packages/boxed-expression-component/src/table/BeeTable/BeeTable.css +++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTable.css @@ -203,6 +203,82 @@ border: 0; } +.expression-container-box + .conditional-expression + .table-component + tr.evaluation-hits-count-row-overlay + > td:first-child::before { + content: ""; + position: absolute; + background-color: rgb(215, 201, 255, 0.5); + left: 0; + top: 0; + width: 100%; + height: 100%; +} + +.expression-container-box + .conditional-expression + .table-component + tr.evaluation-hits-count-row-overlay + > td + > div + > div + > div + > .logic-type-selected-header::before { + content: ""; + position: absolute; + background-color: rgb(215, 201, 255, 0.5); + left: 0; + top: 0; + width: 100%; + height: 100%; +} + +.expression-container-box + .decision-table-expression + .table-component + tr.evaluation-hits-count-row-overlay + > td::before { + content: ""; + position: absolute; + background-color: rgb(215, 201, 255, 0.5); + left: 0; + top: 0; + width: 100%; + height: 100%; +} + +.evaluation-hits-count-badge-non-colored::before { + content: attr(data-evaluation-hits-count); + font-size: 0.8em; + text-align: left; + color: white; + background-color: var(--pf-global--palette--black-600); + position: absolute; + top: 0px; + left: 0px; + height: 40px; + width: 40px; + clip-path: polygon(0% 100%, 100% 0%, 0% 0%); + padding-left: 0.2em; +} + +.evaluation-hits-count-badge-colored::before { + content: attr(data-evaluation-hits-count); + font-size: 0.8em; + text-align: left; + color: white; + background-color: rgb(134, 106, 212); + position: absolute; + top: 0px; + left: 0px; + height: 40px; + width: 40px; + clip-path: polygon(0% 100%, 100% 0%, 0% 0%); + padding-left: 0.2em; +} + .expression-container .table-component table tbody tr td.row-index-cell-column { padding: 1.1em 0; } diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTable.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTable.tsx index 6bd456c9f80..6fcadbf14f3 100644 --- a/packages/boxed-expression-component/src/table/BeeTable/BeeTable.tsx +++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTable.tsx @@ -103,6 +103,7 @@ export function BeeTableInternal({ resizerStopBehavior, lastColumnMinWidth, rowWrapper, + supportsEvaluationHitsCount, }: BeeTableProps & { selectionRef?: React.RefObject; }) { @@ -657,6 +658,7 @@ export function BeeTableInternal({ onDataCellKeyUp={onDataCellKeyUp} lastColumnMinWidth={lastColumnMinWidth} isReadOnly={isReadOnly} + supportsEvaluationHitsCount={supportsEvaluationHitsCount} /> { /** Table instance */ @@ -55,6 +56,8 @@ export interface BeeTableBodyProps { rowWrapper?: React.FunctionComponent>; isReadOnly: boolean; + /** See BeeTable.ts */ + supportsEvaluationHitsCount?: (row: ReactTable.Row) => boolean; } export function BeeTableBody({ @@ -72,18 +75,37 @@ export function BeeTableBody({ lastColumnMinWidth, rowWrapper, isReadOnly, + supportsEvaluationHitsCount, }: BeeTableBodyProps) { + const { evaluationHitsCountById } = useBoxedExpressionEditor(); + const renderRow = useCallback( (row: ReactTable.Row, rowIndex: number) => { reactTableInstance.prepareRow(row); + const rowKey = getRowKey(row); + const rowEvaluationHitsCount = evaluationHitsCountById ? evaluationHitsCountById?.get(rowKey) ?? 0 : undefined; + const canDisplayEvaluationHitsCountRowOverlay = + rowEvaluationHitsCount !== undefined && (supportsEvaluationHitsCount?.(row) ?? false); + const rowClassName = `${rowKey}${canDisplayEvaluationHitsCountRowOverlay && rowEvaluationHitsCount > 0 ? " evaluation-hits-count-row-overlay" : ""}`; + + let evaluationHitsCountBadgeColumnIndex = -1; const renderTr = () => ( - + {row.cells.map((cell, cellIndex) => { const columnKey = getColumnKey(reactTableInstance.allColumns[cellIndex]); + const isColumnToRender = + (cell.column.isRowIndexColumn && shouldRenderRowIndexColumn) || !cell.column.isRowIndexColumn; + if (evaluationHitsCountBadgeColumnIndex === -1 && isColumnToRender) { + // We store the index of the first column in the row + // We show evaluation hits count badge in this column + evaluationHitsCountBadgeColumnIndex = cellIndex; + } + const canDisplayEvaluationHitsCountBadge = + canDisplayEvaluationHitsCountRowOverlay && cellIndex === evaluationHitsCountBadgeColumnIndex; return ( - {((cell.column.isRowIndexColumn && shouldRenderRowIndexColumn) || !cell.column.isRowIndexColumn) && ( + {isColumnToRender && ( resizerStopBehavior={resizerStopBehavior} shouldShowRowsInlineControls={shouldShowRowsInlineControls} @@ -104,6 +126,8 @@ export function BeeTableBody({ cellIndex === reactTableInstance.allColumns.length - 1 ? lastColumnMinWidth : undefined } isReadOnly={isReadOnly} + canDisplayEvaluationHitsCountBadge={canDisplayEvaluationHitsCountBadge} + evaluationHitsCount={rowEvaluationHitsCount} /> )} @@ -114,8 +138,6 @@ export function BeeTableBody({ const RowWrapper = rowWrapper; - const rowKey = getRowKey(row); - return ( {RowWrapper ? ( @@ -129,6 +151,8 @@ export function BeeTableBody({ ); }, [ + evaluationHitsCountById, + supportsEvaluationHitsCount, reactTableInstance, rowWrapper, getRowKey, diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableTd.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableTd.tsx index b9a0a71da04..a9ce90b8575 100644 --- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableTd.tsx +++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableTd.tsx @@ -49,6 +49,10 @@ export interface BeeTableTdProps { onDataCellClick?: (columnID: string) => void; onDataCellKeyUp?: (columnID: string) => void; isReadOnly: boolean; + /** True means the table cell can display evaluation hits count. False means evaluation hits count is not displayed in the table cell. */ + canDisplayEvaluationHitsCountBadge?: boolean; + /** Actuall evaluation hits count number that will be displayed in the table cell if 'canDisplayEvaluationHitsCountBadge' is set to true. */ + evaluationHitsCount?: number; } export type HoverInfo = @@ -73,6 +77,8 @@ export function BeeTableTd({ onDataCellClick, onDataCellKeyUp, isReadOnly, + canDisplayEvaluationHitsCountBadge, + evaluationHitsCount, }: BeeTableTdProps) { const [isResizing, setResizing] = useState(false); const [hoverInfo, setHoverInfo] = useState({ isHovered: false }); @@ -225,6 +231,14 @@ export function BeeTableTd({ return onDataCellKeyUp?.(column.id); }, [column.id, onDataCellKeyUp]); + const evaluationHitsCountBadgeClassName = useMemo(() => { + return canDisplayEvaluationHitsCountBadge + ? (evaluationHitsCount ?? 0) > 0 + ? "evaluation-hits-count-badge-colored" + : "evaluation-hits-count-badge-non-colored" + : ""; + }, [canDisplayEvaluationHitsCountBadge, evaluationHitsCount]); + return ( ({ }} > {column.isRowIndexColumn ? ( - <>{rowIndexLabel} +
+ {rowIndexLabel} +
) : ( - <> +
{tdContent} {!isReadOnly && shouldRenderResizer && ( @@ -262,7 +278,7 @@ export function BeeTableTd({ setResizing={setResizing} /> )} - +
)} {!isReadOnly && diff --git a/packages/boxed-expression-component/stories/boxedExpressionStoriesWrapper.tsx b/packages/boxed-expression-component/stories/boxedExpressionStoriesWrapper.tsx index 92276209843..20c1cea9f8d 100644 --- a/packages/boxed-expression-component/stories/boxedExpressionStoriesWrapper.tsx +++ b/packages/boxed-expression-component/stories/boxedExpressionStoriesWrapper.tsx @@ -175,6 +175,7 @@ export function BoxedExpressionEditorStory(props?: Partial + BoxedExpressionEditorStory({ + evaluationHitsCountById: new Map([ + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B7", 70], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B8", 30], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B9", 40], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B0", 50], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B1", 20], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B2", 70], + ["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B3", 20], + ]), + }), + parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] }, + args: { + ...EmptyExpression.args, + expression: { + __$$element: "conditional", + "@_id": generateUuid(), + "@_label": "Expression Name", + if: { + "@_id": generateUuid(), + expression: { + __$$element: "literalExpression", + "@_id": generateUuid(), + }, + }, + then: { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B7", + expression: { + __$$element: "decisionTable", + "@_id": generateUuid(), + "@_typeRef": "Any", + "@_hitPolicy": "UNIQUE", + input: [ + { + "@_id": generateUuid(), + inputExpression: { + "@_id": generateUuid(), + text: { __$$text: "input-1" }, + }, + }, + { + "@_id": generateUuid(), + inputExpression: { + "@_id": generateUuid(), + text: { __$$text: "input-2" }, + }, + }, + ], + output: [ + { + "@_id": generateUuid(), + "@_label": "output-1", + }, + { + "@_id": generateUuid(), + "@_label": "output-2", + }, + { + "@_id": generateUuid(), + "@_label": "output-3", + }, + ], + annotation: [ + { + "@_name": "Annotations", + }, + ], + rule: [ + { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B8", + inputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "E" } }, + { "@_id": generateUuid(), text: { __$$text: "E" } }, + ], + outputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + ], + annotationEntry: [{ text: { __$$text: "// Your annotations here" } }], + }, + { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B9", + inputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "E" } }, + { "@_id": generateUuid(), text: { __$$text: "E" } }, + ], + outputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + ], + annotationEntry: [{ text: { __$$text: "// Your annotations here" } }], + }, + ], + }, + }, + else: { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B2", + expression: { + __$$element: "conditional", + "@_id": generateUuid(), + "@_label": "Expression Name", + if: { + "@_id": generateUuid(), + expression: { + __$$element: "literalExpression", + "@_id": generateUuid(), + }, + }, + then: { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B0", + expression: { + __$$element: "literalExpression", + "@_id": generateUuid(), + }, + }, + else: { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B3", + expression: { + __$$element: "decisionTable", + "@_id": generateUuid(), + "@_typeRef": "Any", + "@_hitPolicy": "UNIQUE", + input: [ + { + "@_id": generateUuid(), + inputExpression: { + "@_id": generateUuid(), + text: { __$$text: "input-1" }, + }, + }, + { + "@_id": generateUuid(), + inputExpression: { + "@_id": generateUuid(), + text: { __$$text: "input-2" }, + }, + }, + ], + output: [ + { + "@_id": generateUuid(), + "@_label": "output-1", + }, + { + "@_id": generateUuid(), + "@_label": "output-2", + }, + { + "@_id": generateUuid(), + "@_label": "output-3", + }, + ], + annotation: [ + { + "@_name": "Annotations", + }, + ], + rule: [ + { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B1", + inputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "E" } }, + { "@_id": generateUuid(), text: { __$$text: "E" } }, + ], + outputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + ], + annotationEntry: [{ text: { __$$text: "// Your annotations here" } }], + }, + ], + }, + }, + }, + }, + }, + }, +}; + export const MonthlyFee: Story = { render: (args) => BoxedExpressionEditorStory(), parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] }, diff --git a/packages/boxed-expression-component/stories/boxedExpressions/DecisionTable/DecisionTable.stories.tsx b/packages/boxed-expression-component/stories/boxedExpressions/DecisionTable/DecisionTable.stories.tsx index 0a8d78dfc98..859819df758 100644 --- a/packages/boxed-expression-component/stories/boxedExpressions/DecisionTable/DecisionTable.stories.tsx +++ b/packages/boxed-expression-component/stories/boxedExpressions/DecisionTable/DecisionTable.stories.tsx @@ -103,6 +103,83 @@ export const Base: Story = { }, }; +export const EvaluationHits: Story = { + render: (args) => + BoxedExpressionEditorStory({ + evaluationHitsCountById: new Map([["_1FA12B9F-288C-42E8-B77F-BE2D3702B7B8", 30]]), + }), + parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] }, + args: { + ...EmptyExpression.args, + expression: { + __$$element: "decisionTable", + "@_id": "_92929AE6-3BB5-4217-B66E-07614680971D", + "@_label": "Expression Name", + "@_hitPolicy": "UNIQUE", + input: [ + { + "@_id": generateUuid(), + inputExpression: { + "@_id": generateUuid(), + text: { __$$text: "input-1" }, + "@_typeRef": undefined, + }, + }, + ], + output: [ + { + "@_id": generateUuid(), + "@_label": "output-1", + "@_typeRef": undefined, + }, + ], + annotation: [ + { + "@_name": "Annotations", + }, + ], + rule: [ + { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B8", + inputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "E" } }, + { "@_id": generateUuid(), text: { __$$text: "E" } }, + ], + outputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + ], + annotationEntry: [{ text: { __$$text: "// Your annotations here" } }], + }, + { + "@_id": "_1FA12B9F-288C-42E8-B77F-BE2D3702B7B4", + inputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "E" } }, + { "@_id": generateUuid(), text: { __$$text: "E" } }, + ], + outputEntry: [ + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + { "@_id": generateUuid(), text: { __$$text: "aaa" } }, + ], + annotationEntry: [{ text: { __$$text: "// Your annotations here" } }], + }, + ], + }, + widthsById: { + "_92929AE6-3BB5-4217-B66E-07614680971D": [ + BEE_TABLE_ROW_INDEX_COLUMN_WIDTH, + DECISION_TABLE_INPUT_DEFAULT_WIDTH, + DECISION_TABLE_OUTPUT_DEFAULT_WIDTH, + DECISION_TABLE_ANNOTATION_DEFAULT_WIDTH, + ], + }, + + isResetSupportedOnRootExpression: true, + }, +}; + export const Readonly: Story = { render: (args) => BoxedExpressionEditorStory(), parameters: { exclude: ["dataTypes", "beeGwtService", "pmmlDocuments"] }, From fafdb6de68dcd1a5c54d50f9b45fa7c4feffe9a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:00:48 -0300 Subject: [PATCH 2/5] build(deps): bump golang.org/x/crypto from 0.21.0 to 0.31.0 in /examples/kie-sandbox-commit-message-validation-service (#2812) --- .../go.mod | 6 +++--- .../go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/kie-sandbox-commit-message-validation-service/go.mod b/examples/kie-sandbox-commit-message-validation-service/go.mod index f03c6e132f8..736cc5d88e7 100644 --- a/examples/kie-sandbox-commit-message-validation-service/go.mod +++ b/examples/kie-sandbox-commit-message-validation-service/go.mod @@ -28,10 +28,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect golang.org/x/arch v0.7.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/examples/kie-sandbox-commit-message-validation-service/go.sum b/examples/kie-sandbox-commit-message-validation-service/go.sum index 8d5a336d4b9..185cc9b8ab0 100644 --- a/examples/kie-sandbox-commit-message-validation-service/go.sum +++ b/examples/kie-sandbox-commit-message-validation-service/go.sum @@ -76,16 +76,16 @@ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc= golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= From bc20d5ddce8a63cd8fc5f84c879203f9919fe271 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:33:19 -0500 Subject: [PATCH 3/5] [sonataflow-images] [kogito-images] Fix #2817 - Disable debug on e2e tests (#2818) Signed-off-by: Ricardo Zanini --- .../added/kogito-app-launch.sh | 14 +++++--- .../features/kogito-data-index-common.feature | 34 ------------------- .../kogito-data-index-ephemeral.feature | 10 +++--- .../added/kogito-app-launch.sh | 14 +++++--- .../kogito-common-postresql-services.feature | 4 +-- .../features/kogito-data-index-common.feature | 8 ++--- .../kogito-data-index-postgresql.feature | 2 +- .../added/kogito-app-launch.sh | 14 +++++--- .../tests/features/kogito-jit-runner.feature | 8 ++--- .../added/kogito-app-launch.sh | 12 ++++--- .../kogito-jobs-service-all-in-one.feature | 16 ++++----- .../kogito-jobs-service-common.feature | 4 +-- .../added/kogito-app-launch.sh | 12 ++++--- .../kogito-jobs-service-common.feature | 6 ++-- .../kogito-jobs-service-ephemeral.feature | 4 +-- .../added/kogito-app-launch.sh | 12 ++++--- .../kogito-jobs-service-common.feature | 6 ++-- .../kogito-jobs-service-postgresql.feature | 8 ++--- .../tests/features/sonataflow-builder.feature | 8 ++--- .../runtime/common/added/run-app-devmode.sh | 13 ++++--- .../tests/features/sonataflow-devmode.feature | 14 +++----- 21 files changed, 99 insertions(+), 124 deletions(-) delete mode 100644 packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-common.feature diff --git a/packages/kogito-data-index-ephemeral-image/resources/modules/kogito-data-index-ephemeral/added/kogito-app-launch.sh b/packages/kogito-data-index-ephemeral-image/resources/modules/kogito-data-index-ephemeral/added/kogito-app-launch.sh index aa15cda2106..83dea09ddb2 100644 --- a/packages/kogito-data-index-ephemeral-image/resources/modules/kogito-data-index-ephemeral/added/kogito-app-launch.sh +++ b/packages/kogito-data-index-ephemeral-image/resources/modules/kogito-data-index-ephemeral/added/kogito-app-launch.sh @@ -42,9 +42,13 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_DATA_INDEX_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Djava.library.path="${KOGITO_HOME}"/lib \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/quarkus-app/quarkus-run.jar +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_DATA_INDEX_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Djava.library.path=\"${KOGITO_HOME}/lib\" \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-common.feature b/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-common.feature deleted file mode 100644 index d5a359d17dd..00000000000 --- a/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-common.feature +++ /dev/null @@ -1,34 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -@docker.io/apache/incubator-kie-kogito-data-index-ephemeral -Feature: Kogito-data-index common feature. - - Scenario: Verify if the debug is correctly enabled and test default http port - When container is started with env - | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Djava.library.path=/home/kogito/lib -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 - - Scenario: check if a provided data index quarkus profile is correctly set on data index - When container is started with env - | variable | value | - | SCRIPT_DEBUG | true | - | KOGITO_DATA_INDEX_QUARKUS_PROFILE | http-events-support | - Then container log should contain -Dquarkus.profile=http-events-support \ No newline at end of file diff --git a/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-ephemeral.feature b/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-ephemeral.feature index f7e817c3c16..4929ab7d171 100644 --- a/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-ephemeral.feature +++ b/packages/kogito-data-index-ephemeral-image/test-resources/tests/features/kogito-data-index-ephemeral.feature @@ -17,7 +17,7 @@ # under the License. # @docker.io/apache/incubator-kie-kogito-data-index-ephemeral -Feature: Kogito-data-index ephemeral postgresql feature. +Feature: Kogito-data-index ephemeral feature. Scenario: verify if all labels are correctly set on kogito-data-index-ephemeral image Given image is built @@ -27,16 +27,16 @@ Feature: Kogito-data-index ephemeral postgresql feature. And the image should contain label io.k8s.display-name with value Kogito Data Index Service - ephemeral PostgreSQL And the image should contain label io.openshift.tags with value kogito,data-index,data-index-ephemeral - Scenario: verify if of kogito-data-index-ephemeral container is correctly started + Scenario: verify if kogito-data-index-ephemeral container is correctly started When container is started with env | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Djava.library.path=/home/kogito/lib -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/quarkus-app/quarkus-run.jar + | SCRIPT_DEBUG | false | + Then container log should match regex exec java.*-Djava\.library\.path="/home/kogito/lib" -Dquarkus\.http\.host=0\.0\.0\.0 -Dquarkus\.http\.port=8080 -jar "/home/kogito/bin/quarkus-app/quarkus-run\.jar" And container log should contain Embedded Postgres started at port And container log should not contain Application failed to start Scenario: check if the default quarkus profile is correctly set on data index When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | Then available container log should contain -Dquarkus.profile=http-events-support diff --git a/packages/kogito-data-index-postgresql-image/resources/modules/kogito-data-index-postgresql/added/kogito-app-launch.sh b/packages/kogito-data-index-postgresql-image/resources/modules/kogito-data-index-postgresql/added/kogito-app-launch.sh index ec77a25695a..d106377e204 100644 --- a/packages/kogito-data-index-postgresql-image/resources/modules/kogito-data-index-postgresql/added/kogito-app-launch.sh +++ b/packages/kogito-data-index-postgresql-image/resources/modules/kogito-data-index-postgresql/added/kogito-app-launch.sh @@ -42,8 +42,12 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_DATA_INDEX_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Djava.library.path="${KOGITO_HOME}"/lib \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/quarkus-app/quarkus-run.jar \ No newline at end of file +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_DATA_INDEX_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Djava.library.path=\"${KOGITO_HOME}/lib\" \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-common-postresql-services.feature b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-common-postresql-services.feature index a4146f52bb7..ead2f4b6752 100644 --- a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-common-postresql-services.feature +++ b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-common-postresql-services.feature @@ -23,9 +23,9 @@ Feature: Kogito-data-index postgresql feature. Scenario: verify if of container is correctly started with postgresql parameters When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_DATASOURCE_JDBC_URL | jdbc:postgresql://localhost:5432/quarkus | | QUARKUS_DATASOURCE_USERNAME | kogito | | QUARKUS_DATASOURCE_PASSWORD | s3cr3t | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/quarkus-app/quarkus-run.jar + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/quarkus-app/quarkus-run.jar" And container log should contain Datasource '': Connection to localhost:5432 refused \ No newline at end of file diff --git a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-common.feature b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-common.feature index fae736f08d5..3684a1caa45 100644 --- a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-common.feature +++ b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-common.feature @@ -20,15 +20,15 @@ @docker.io/apache/incubator-kie-kogito-data-index-postgresql Feature: Kogito-data-index common feature. - Scenario: Verify if the debug is correctly enabled and test default http port + Scenario: Verify default http port When container is started with env | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Djava.library.path=/home/kogito/lib -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 + | SCRIPT_DEBUG | false | + Then container log should match regex -Djava\.library\.path="/home/kogito/lib" -Dquarkus\.http\.host=0\.0\.0\.0 -Dquarkus\.http\.port=8080 Scenario: check if a provided data index quarkus profile is correctly set on data index When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | KOGITO_DATA_INDEX_QUARKUS_PROFILE | http-events-support | Then container log should contain -Dquarkus.profile=http-events-support \ No newline at end of file diff --git a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-postgresql.feature b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-postgresql.feature index ced19dc790a..28039e8cd51 100644 --- a/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-postgresql.feature +++ b/packages/kogito-data-index-postgresql-image/test-resources/tests/features/kogito-data-index-postgresql.feature @@ -31,5 +31,5 @@ Feature: Kogito-data-index postgresql feature. Scenario: check if the default quarkus profile is correctly set on data index When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | Then container log should contain -Dquarkus.profile=kafka-events-support \ No newline at end of file diff --git a/packages/kogito-jit-runner-image/resources/modules/kogito-jit-runner/added/kogito-app-launch.sh b/packages/kogito-jit-runner-image/resources/modules/kogito-jit-runner/added/kogito-app-launch.sh index f519f07d4eb..afd40aae86e 100644 --- a/packages/kogito-jit-runner-image/resources/modules/kogito-jit-runner/added/kogito-app-launch.sh +++ b/packages/kogito-jit-runner-image/resources/modules/kogito-jit-runner/added/kogito-app-launch.sh @@ -41,8 +41,12 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Djava.library.path="${KOGITO_HOME}"/lib \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/quarkus-app/quarkus-run.jar \ No newline at end of file +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Djava.library.path=\"${KOGITO_HOME}/lib\" \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-jit-runner-image/test-resources/tests/features/kogito-jit-runner.feature b/packages/kogito-jit-runner-image/test-resources/tests/features/kogito-jit-runner.feature index 4c6e51aed3b..ac96c384a70 100644 --- a/packages/kogito-jit-runner-image/test-resources/tests/features/kogito-jit-runner.feature +++ b/packages/kogito-jit-runner-image/test-resources/tests/features/kogito-jit-runner.feature @@ -28,16 +28,16 @@ Feature: Kogito-jit-runner feature. And the image should contain label io.k8s.display-name with value Kogito JIT Runner And the image should contain label io.openshift.tags with value kogito,jit-runner - Scenario: Verify if the debug is correctly enabled and test default http port + Scenario: Verify default http port When container is started with env | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Djava.library.path=/home/kogito/lib -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/quarkus-app/quarkus-run.jar + | SCRIPT_DEBUG | false | + Then container log should match regex -Djava\.library\.path="/home/kogito/lib" -Dquarkus\.http\.host=0\.0\.0\.0 -Dquarkus\.http\.port=8080 -jar "/home/kogito/bin/quarkus-app/quarkus-run\.jar" Scenario: Verify that jit runner can evaluate a DMN model with a context When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | Then check that page is served | property | value | | port | 8080 | diff --git a/packages/kogito-jobs-service-allinone-image/resources/modules/kogito-jobs-service-all-in-one/added/kogito-app-launch.sh b/packages/kogito-jobs-service-allinone-image/resources/modules/kogito-jobs-service-all-in-one/added/kogito-app-launch.sh index 43fc15e1c50..447dbbae762 100644 --- a/packages/kogito-jobs-service-allinone-image/resources/modules/kogito-jobs-service-all-in-one/added/kogito-app-launch.sh +++ b/packages/kogito-jobs-service-allinone-image/resources/modules/kogito-jobs-service-all-in-one/added/kogito-app-launch.sh @@ -52,7 +52,11 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/${jobs_service_flavor}/quarkus-app/quarkus-run.jar +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/${jobs_service_flavor}/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-all-in-one.feature b/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-all-in-one.feature index 8d897bdf35f..7501ed99c6a 100644 --- a/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-all-in-one.feature +++ b/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-all-in-one.feature @@ -36,32 +36,28 @@ Feature: Kogito-jobs-service-all-in-one feature. Scenario: Verify if the debug is correctly enabled with the ephemeral jar When container is started with env | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/ephemeral/quarkus-app/quarkus-run.jar + | SCRIPT_DEBUG | false | + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/ephemeral/quarkus-app/quarkus-run.jar" And container log should contain started in And container log should not contain Application failed to start Scenario: verify if the container is started with invalid jobs-service flavor When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | JOBS_SERVICE_PERSISTENCE | something | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/ephemeral/quarkus-app/quarkus-run.jar + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/ephemeral/quarkus-app/quarkus-run.jar" And container log should contain something is not supported, the allowed flavors are [ephemeral postgresql], defaulting to ephemeral Scenario: verify if container starts as expected When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_LOG_LEVEL | DEBUG | | JOBS_SERVICE_PERSISTENCE | postgresql | | QUARKUS_DATASOURCE_DB_KIND | postgresql | | QUARKUS_DATASOURCE_USERNAME | test | | QUARKUS_DATASOURCE_PASSWORD | 123456 | | QUARKUS_DATASOURCE_JDBC_URL | jdbc:postgresql://10.11.12.13:5432/hibernate_orm_test | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/postgresql/quarkus-app/quarkus-run.jar - And container log should contain QUARKUS_DATASOURCE_DB_KIND=postgresql - And container log should contain QUARKUS_DATASOURCE_USERNAME=test - And container log should contain QUARKUS_DATASOURCE_PASSWORD=123456 - And container log should contain QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://10.11.12.13:5432/hibernate_orm_test + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/postgresql/quarkus-app/quarkus-run.jar" And container log should contain Trying to establish a protocol version 3 connection to 10.11.12.13:5432 diff --git a/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-common.feature b/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-common.feature index 81743a49b80..58fb8bea9c2 100644 --- a/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-common.feature +++ b/packages/kogito-jobs-service-allinone-image/test-resources/tests/features/kogito-jobs-service-common.feature @@ -25,7 +25,7 @@ Feature: Kogito-jobs-service common feature. Scenario: verify if the events is correctly enabled When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | ENABLE_EVENTS | true | | KOGITO_JOBS_PROPS | -Dkafka.bootstrap.servers=localhost:11111 | - Then container log should contain -Dkafka.bootstrap.servers=localhost:11111 -Dquarkus.profile=events-support -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar + Then container log should contain localhost:11111 diff --git a/packages/kogito-jobs-service-ephemeral-image/resources/modules/kogito-jobs-service-ephemeral/added/kogito-app-launch.sh b/packages/kogito-jobs-service-ephemeral-image/resources/modules/kogito-jobs-service-ephemeral/added/kogito-app-launch.sh index 0f470cac6d3..43295a8e7e6 100644 --- a/packages/kogito-jobs-service-ephemeral-image/resources/modules/kogito-jobs-service-ephemeral/added/kogito-app-launch.sh +++ b/packages/kogito-jobs-service-ephemeral-image/resources/modules/kogito-jobs-service-ephemeral/added/kogito-app-launch.sh @@ -42,7 +42,11 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/quarkus-app/quarkus-run.jar +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-common.feature b/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-common.feature index 56a431c9c5f..d59d9868f2c 100644 --- a/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-common.feature +++ b/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-common.feature @@ -17,15 +17,13 @@ # under the License. # -@docker.io/apache/incubator-kie-kogito-jobs-service-ephemeral -@docker.io/apache/incubator-kie-kogito-jobs-service-ephemeral @docker.io/apache/incubator-kie-kogito-jobs-service-ephemeral Feature: Kogito-jobs-service common feature. Scenario: verify if the events is correctly enabled When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | ENABLE_EVENTS | true | | KOGITO_JOBS_PROPS | -Dkafka.bootstrap.servers=localhost:11111 | - Then container log should contain -Dkafka.bootstrap.servers=localhost:11111 -Dquarkus.profile=events-support -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar + Then container log should contain localhost:11111 diff --git a/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-ephemeral.feature b/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-ephemeral.feature index f9458b09d65..3138b9b6754 100644 --- a/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-ephemeral.feature +++ b/packages/kogito-jobs-service-ephemeral-image/test-resources/tests/features/kogito-jobs-service-ephemeral.feature @@ -35,8 +35,8 @@ Feature: Kogito-jobs-service-ephemeral feature. Scenario: Verify if the debug is correctly enabled with the ephemeral jar When container is started with env | variable | value | - | SCRIPT_DEBUG | true | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/quarkus-app/quarkus-run.jar + | SCRIPT_DEBUG | false | + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/quarkus-app/quarkus-run.jar" And container log should contain started in And container log should not contain Application failed to start diff --git a/packages/kogito-jobs-service-postgresql-image/resources/modules/kogito-jobs-service-postgresql/added/kogito-app-launch.sh b/packages/kogito-jobs-service-postgresql-image/resources/modules/kogito-jobs-service-postgresql/added/kogito-app-launch.sh index 0f470cac6d3..43295a8e7e6 100644 --- a/packages/kogito-jobs-service-postgresql-image/resources/modules/kogito-jobs-service-postgresql/added/kogito-app-launch.sh +++ b/packages/kogito-jobs-service-postgresql-image/resources/modules/kogito-jobs-service-postgresql/added/kogito-app-launch.sh @@ -42,7 +42,11 @@ source "${KOGITO_HOME}"/launch/configure.sh DYNAMIC_RESOURCES_OPTS="$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" # shellcheck disable=SC2086 -exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ - -Dquarkus.http.host=0.0.0.0 \ - -Dquarkus.http.port=8080 \ - -jar "${KOGITO_HOME}"/bin/quarkus-app/quarkus-run.jar +CMD="exec java ${SHOW_JVM_SETTINGS} ${DYNAMIC_RESOURCES_OPTS} ${JAVA_OPTIONS} ${KOGITO_JOBS_PROPS} ${CUSTOM_TRUSTSTORE_ARGS} \ +-Dquarkus.http.host=0.0.0.0 \ +-Dquarkus.http.port=8080 \ +-jar \"${KOGITO_HOME}/bin/quarkus-app/quarkus-run.jar\"" + +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-common.feature b/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-common.feature index 6c9ad4a7738..8076381b3b7 100644 --- a/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-common.feature +++ b/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-common.feature @@ -17,15 +17,13 @@ # under the License. # -@docker.io/apache/incubator-kie-kogito-jobs-service-postgresql -@docker.io/apache/incubator-kie-kogito-jobs-service-postgresql @docker.io/apache/incubator-kie-kogito-jobs-service-postgresql Feature: Kogito-jobs-service common feature. Scenario: verify if the events is correctly enabled When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | ENABLE_EVENTS | true | | KOGITO_JOBS_PROPS | -Dkafka.bootstrap.servers=localhost:11111 | - Then container log should contain -Dkafka.bootstrap.servers=localhost:11111 -Dquarkus.profile=events-support -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar + Then container log should contain localhost:11111 diff --git a/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-postgresql.feature b/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-postgresql.feature index c8aa91d8fb8..c7f2a1d1e93 100644 --- a/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-postgresql.feature +++ b/packages/kogito-jobs-service-postgresql-image/test-resources/tests/features/kogito-jobs-service-postgresql.feature @@ -35,15 +35,11 @@ Feature: Kogito-jobs-service-postgresql feature. Scenario: verify if container starts as expected When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_LOG_LEVEL | DEBUG | | QUARKUS_DATASOURCE_DB_KIND | postgresql | | QUARKUS_DATASOURCE_USERNAME | test | | QUARKUS_DATASOURCE_PASSWORD | 123456 | | QUARKUS_DATASOURCE_JDBC_URL | jdbc:postgresql://10.11.12.13:5432/hibernate_orm_test | - Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar /home/kogito/bin/quarkus-app/quarkus-run.jar - And container log should contain QUARKUS_DATASOURCE_DB_KIND=postgresql - And container log should contain QUARKUS_DATASOURCE_USERNAME=test - And container log should contain QUARKUS_DATASOURCE_PASSWORD=123456 - And container log should contain QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://10.11.12.13:5432/hibernate_orm_test + Then container log should contain -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8080 -jar "/home/kogito/bin/quarkus-app/quarkus-run.jar" And container log should contain Trying to establish a protocol version 3 connection to 10.11.12.13:5432 diff --git a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature index fefd17bc48f..728cb34f4e1 100644 --- a/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature +++ b/packages/sonataflow-builder-image/test-resources/tests/features/sonataflow-builder.feature @@ -4,7 +4,7 @@ Feature: Serverless Workflow builder images Scenario: Verify that the application is built and started correctly When container is started with command bash -c '/home/kogito/launch/build-app.sh && java -jar target/quarkus-app/quarkus-run.jar' | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | Then check that page is served | property | value | | port | 8080 | @@ -12,7 +12,6 @@ Feature: Serverless Workflow builder images | wait | 480 | | request_method | GET | | expected_status_code | 200 | - And container log should contain -Duser.home=/home/kogito And container log should match regex Installed features:.*kogito-serverless-workflow And container log should match regex Installed features:.*kie-addon-knative-eventing-extension And container log should match regex Installed features:.*smallrye-health @@ -20,7 +19,7 @@ Feature: Serverless Workflow builder images Scenario: Verify that the application is built and started correctly when QUARKUS_EXTENSIONS env is used When container is started with command bash -c '/home/kogito/launch/build-app.sh && java -jar target/quarkus-app/quarkus-run.jar' | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_EXTENSIONS | io.quarkus:quarkus-elytron-security-jdbc | Then check that page is served | property | value | @@ -29,8 +28,7 @@ Feature: Serverless Workflow builder images | wait | 480 | | request_method | GET | | expected_status_code | 200 | - And container log should contain -Duser.home=/home/kogito - And container log should contain Extension io.quarkus:quarkus-elytron-security-jdbc has been installed + And container log should match regex Extension io\.quarkus:quarkus-elytron-security-jdbc.* has been installed And container log should match regex Installed features:.*kogito-serverless-workflow And container log should match regex Installed features:.*kie-addon-knative-eventing-extension And container log should match regex Installed features:.*smallrye-health diff --git a/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/common/added/run-app-devmode.sh b/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/common/added/run-app-devmode.sh index 6f5ec36109e..93a9bffb7d2 100755 --- a/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/common/added/run-app-devmode.sh +++ b/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/common/added/run-app-devmode.sh @@ -43,11 +43,16 @@ if [ ! -z "${QUARKUS_EXTENSIONS}" ]; then offline_param="" fi -"${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ +CMD="\"${MAVEN_HOME}\"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ ${offline_param} \ - -s "${MAVEN_SETTINGS_PATH}" \ + -s \"${MAVEN_SETTINGS_PATH}\" \ -DskipTests \ -Dquarkus.http.host=0.0.0.0 \ -Dquarkus.test.continuous-testing=${QUARKUS_CONTINUOUS_TESTING:-disabled} \ - -Dquarkus.analytics.disabled=${QUARKUS_ANALYTICS_DISABLED:true} \ - clean compile quarkus:dev \ No newline at end of file + -Dquarkus.analytics.disabled=${QUARKUS_ANALYTICS_DISABLED:-true} \ + clean compile quarkus:dev" + +# Prints the command before executing for troubleshooting purposes +log_info "Running application start mvn command" +echo "$CMD" +eval "$CMD" diff --git a/packages/sonataflow-devmode-image/test-resources/tests/features/sonataflow-devmode.feature b/packages/sonataflow-devmode-image/test-resources/tests/features/sonataflow-devmode.feature index f9abddb709d..f381ebb10cc 100644 --- a/packages/sonataflow-devmode-image/test-resources/tests/features/sonataflow-devmode.feature +++ b/packages/sonataflow-devmode-image/test-resources/tests/features/sonataflow-devmode.feature @@ -4,7 +4,7 @@ Feature: Serverless Workflow devmode images Scenario: Verify if container starts in devmode by default When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | Then check that page is served | property | value | | port | 8080 | @@ -12,8 +12,6 @@ Feature: Serverless Workflow devmode images | wait | 480 | | request_method | GET | | expected_status_code | 200 | - And container log should contain -Duser.home=/home/kogito -o - And container log should contain -Dquarkus.test.continuous-testing=disabled And container log should match regex Installed features:.*kogito-serverless-workflow And container log should match regex Installed features:.*kie-addon-knative-eventing-extension And container log should match regex Installed features:.*smallrye-health @@ -25,7 +23,7 @@ Feature: Serverless Workflow devmode images Scenario: Verify if container starts correctly when continuous testing is enabled When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_CONTINUOUS_TESTING | enabled | Then check that page is served | property | value | @@ -34,14 +32,12 @@ Feature: Serverless Workflow devmode images | wait | 480 | | request_method | GET | | expected_status_code | 200 | - And container log should contain -Duser.home=/home/kogito - And container log should not contain /bin/mvn -B -X --batch-mode -o And container log should contain -Dquarkus.test.continuous-testing=enabled Scenario: Verify if container starts correctly when QUARKUS_EXTENSIONS env is used When container is started with env | variable | value | - | SCRIPT_DEBUG | true | + | SCRIPT_DEBUG | false | | QUARKUS_EXTENSIONS | io.quarkus:quarkus-elytron-security-jdbc | Then check that page is served | property | value | @@ -50,9 +46,7 @@ Feature: Serverless Workflow devmode images | wait | 960 | | request_method | GET | | expected_status_code | 200 | - And container log should contain -Duser.home=/home/kogito - And container log should not contain /bin/mvn -B -X --batch-mode -o - And container log should contain Extension io.quarkus:quarkus-elytron-security-jdbc has been installed + And container log should match regex Extension io\.quarkus:quarkus-elytron-security-jdbc.* has been installed And container log should match regex Installed features:.*kogito-serverless-workflow And container log should match regex Installed features:.*kie-addon-knative-eventing-extension And container log should match regex Installed features:.*smallrye-health From c690d462602da4cf2c01b90279815b60a1959162 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:07:27 -0500 Subject: [PATCH 4/5] kie-tools#2751: Remove references to Quarkus and Kogito versions; Automatic change of platform images based on env context (#2794) Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Signed-off-by: Ricardo Zanini --- ...kie-kogito-data-index-ephemeral-image.yaml | 1 + ...ie-kogito-data-index-postgresql-image.yaml | 1 + ...ie-kogito-jobs-service-allinone-image.yaml | 1 + ...e-kogito-jobs-service-ephemeral-image.yaml | 1 + ...-kogito-jobs-service-postgresql-image.yaml | 1 + .../common/scripts/added/add-extension.sh | 28 ++---- .../scripts/added/quarkus-mvn-plugin.sh | 94 +++++++++++++++++++ .../tests/bats/quarkus-mvn-plugin.bats | 83 ++++++++++++++++ packages/sonataflow-operator/Makefile | 28 +++++- .../config/manager/controllers_cfg.yaml | 3 - .../config/manager/kustomization.yaml | 4 +- ...flow.org_v1alpha08_sonataflowplatform.yaml | 2 +- .../container-builder/api/build_types.go | 2 +- .../builder/kubernetes/builder_kaniko_test.go | 4 +- .../builder/kubernetes/builder_test.go | 2 +- .../kubernetes/testdata/sample.Dockerfile} | 43 ++++++--- .../PlatformBuild_usingKanikowithCache.yaml | 4 +- .../sonataflow-operator/hack/bump-version.sh | 23 ----- .../hack/update_controllers_cfg.py | 93 ++++++++++++++++++ packages/sonataflow-operator/install.js | 75 --------------- .../builder/kogitoserverlessbuild_manager.go | 6 +- .../controller/cfg/controllers_cfg.go | 39 ++++---- .../controller/cfg/controllers_cfg_test.go | 9 +- .../cfg/testdata/controllers-cfg-test.yaml | 3 - .../controller/platform/platformutils_test.go | 13 +-- .../platform/testdata/platformTest.Dockerfile | 2 +- .../profiles/common/object_creators_test.go | 16 ++-- .../profiles/common/persistence/postgresql.go | 2 +- .../profiles/dev/profile_dev_test.go | 2 +- .../preview/deployment_handler_test.go | 2 +- .../sonataflowplatform_controller_test.go | 18 ++-- packages/sonataflow-operator/operator.yaml | 3 - packages/sonataflow-operator/package.json | 3 +- .../ephemeral/02-sonataflow_platform.yaml | 2 +- .../dev/ephemeral/02-sonataflow_platform.yaml | 2 +- .../postgreSQL/02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- .../02-sonataflow_platform.yaml | 2 +- ...ataflow.org_v1alpha08_sonataflowbuild.yaml | 2 +- ...flow.org_v1alpha08_sonataflowplatform.yaml | 2 +- ...alpha08_sonataflowplatform_withBroker.yaml | 2 +- packages/sonataflow-operator/test/yaml.go | 50 ++++------ 43 files changed, 427 insertions(+), 252 deletions(-) create mode 100644 packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh create mode 100644 packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats rename packages/sonataflow-operator/{test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml => container-builder/builder/kubernetes/testdata/sample.Dockerfile} (50%) create mode 100644 packages/sonataflow-operator/hack/update_controllers_cfg.py delete mode 100644 packages/sonataflow-operator/install.js diff --git a/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml b/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml index 8e2f84baad2..a84340f07a5 100644 --- a/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml +++ b/packages/kogito-data-index-ephemeral-image/resources/incubator-kie-kogito-data-index-ephemeral-image.yaml @@ -49,6 +49,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.dataindex.ephemeral diff --git a/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml b/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml index 00ae72ecac4..cf4c8027420 100644 --- a/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml +++ b/packages/kogito-data-index-postgresql-image/resources/incubator-kie-kogito-data-index-postgresql-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.dataindex.postgresql diff --git a/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml b/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml index 2872d6a0132..03a41ec9d9d 100644 --- a/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml +++ b/packages/kogito-jobs-service-allinone-image/resources/incubator-kie-kogito-jobs-service-allinone-image.yaml @@ -54,6 +54,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.allinone diff --git a/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml b/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml index f622fec9eed..e9b17647ad7 100644 --- a/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml +++ b/packages/kogito-jobs-service-ephemeral-image/resources/incubator-kie-kogito-jobs-service-ephemeral-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.ephemeral diff --git a/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml b/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml index f2ccc8bc2c5..06ac396d1cb 100644 --- a/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml +++ b/packages/kogito-jobs-service-postgresql-image/resources/incubator-kie-kogito-jobs-service-postgresql-image.yaml @@ -51,6 +51,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.logging + - name: org.kie.kogito.project.versions - name: org.kie.kogito.dynamic.resources - name: org.kie.kogito.launch.scripts - name: org.kie.kogito.jobs.service.postgresql diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh index fcddc18727b..5eb3b2b2e8f 100755 --- a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/add-extension.sh @@ -20,31 +20,15 @@ set -e -script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # extensions to be added, comma separated. extensions="$1" +if [ -z "$extensions" ]; then + return 0 +fi + # parameter passed which will trigger or not the jvm/maven configuration. ignore_jvm_settings=${2:-false} -# shellcheck source=/dev/null -source "${script_dir_path}"/logging.sh - -if [ "${SCRIPT_DEBUG}" = "true" ] ; then - set -x - export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" - log_info "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" - printenv -fi - -if [ "${ignore_jvm_settings}" != "true" ]; then - source "${script_dir_path}"/configure-jvm-mvn.sh -fi +source "${KOGITO_HOME}"/launch/quarkus-mvn-plugin.sh -"${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ - -nsu \ - -B \ - -s "${MAVEN_SETTINGS_PATH}" \ - -DplatformVersion="${QUARKUS_PLATFORM_VERSION}" \ - -Dextensions="${extensions}" \ - ${QUARKUS_ADD_EXTENSION_ARGS} \ - "${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":add-extension +run_quarkus_mvn_add_extension "$extensions", "$ignore_jvm_settings" diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh new file mode 100644 index 00000000000..44417c39ca8 --- /dev/null +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/added/quarkus-mvn-plugin.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +# Useful functions for runnning Quarkus Maven Plugin. Moved from bare scripts to facilitate testing. + +set -e + +# Default version variables +quarkus_version="${QUARKUS_PLATFORM_VERSION}" +kogito_version="${KOGITO_VERSION}" + +# shellcheck source=/dev/null +source "${KOGITO_HOME}"/launch/logging.sh + +# Function to append the correct version to the extension if needed +append_version() { + local extension="$1" + local group_id + local artifact_id + local version + + # Split extension into groupId, artifactId, and version + IFS=":" read -r group_id artifact_id version <<< "$extension" + + # If the version is missing, append the default version based on the groupId + if [ -z "$version" ]; then + if [[ "$group_id" == "io.quarkus" ]]; then + extension="${group_id}:${artifact_id}:${quarkus_version}" + elif [[ "$group_id" == *"kie"* || "$group_id" == *"kogito"* || "$artifact_id" == *"kogito"* || "$artifact_id" == *"sonataflow"* ]]; then + extension="${group_id}:${artifact_id}:${kogito_version}" + fi + fi + + echo "$extension" +} + +process_extensions() { + local extensions="$1" + local processed_extensions="" + IFS=',' read -r -a extension_array <<< "$extensions" + for ext in "${extension_array[@]}"; do + processed_extensions+=$(append_version "$ext")"," + done + # Remove the trailing comma + processed_extensions="${processed_extensions%,}" + echo "$processed_extensions" +} + +run_quarkus_mvn_add_extension() { + local extensions="$1" + local ignore_jvm_settings=${2:-false} + + local processed_extensions=$(process_extensions "$extensions") + + if [ "${SCRIPT_DEBUG}" = "true" ]; then + set -x + export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" + log_info "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" + printenv + fi + + if [ "${ignore_jvm_settings}" != "true" ]; then + source "${KOGITO_HOME}"/launch/configure-jvm-mvn.sh + fi + + log_info "Processed extensions to be added ${processed_extensions}" + + "${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ + -nsu \ + -B \ + -s "${MAVEN_SETTINGS_PATH}" \ + -DplatformVersion="${QUARKUS_PLATFORM_VERSION}" \ + -Dextensions="${processed_extensions}" \ + ${QUARKUS_ADD_EXTENSION_ARGS} \ + "${QUARKUS_PLATFORM_GROUPID}":quarkus-maven-plugin:"${QUARKUS_PLATFORM_VERSION}":add-extension +} \ No newline at end of file diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats new file mode 100644 index 00000000000..5bab3a99bf4 --- /dev/null +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/scripts/tests/bats/quarkus-mvn-plugin.bats @@ -0,0 +1,83 @@ +#!/usr/bin/env bats +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +set -e + +# Set up some environment variables for testing +setup() { + export QUARKUS_PLATFORM_VERSION="2.0.0" + export KOGITO_VERSION="1.5.0" + export KOGITO_HOME=$BATS_TMPDIR/maven + mkdir -p ${KOGITO_HOME}/"launch" + cp ${BATS_TEST_DIRNAME}/../../../../../kogito-logging/added/logging.sh ${KOGITO_HOME}/launch/logging.sh + + load ${BATS_TEST_DIRNAME}/../../added/quarkus-mvn-plugin.sh +} + +teardown() { + rm -rf ${KOGITO_HOME} +} + +# Test that a full extension with version does not get modified +@test "Extension with version should remain unchanged" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive:2.0.0" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0" ] +} + +# Test that an extension without version for io.quarkus gets the default version +@test "io.quarkus extension without version should get the default version" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0" ] +} + +# Test that an extension without version for kogito gets the KOGITO version +@test "Kogito extension without version should get the KOGITO version" { + run process_extensions "org.kie:kie-server" + echo "Test Output:" + echo "$output" + [ "$output" == "org.kie:kie-server:1.5.0" ] +} + +# Test that an extension without version for a non-quarkus and non-kogito group gets the default version +@test "Non-quarkus, non-kogito extension without version should get the default version" { + run process_extensions "org.acme:acme-component" + echo "Test Output:" + echo "$output" + [ "$output" == "org.acme:acme-component" ] +} + +# Test that multiple extensions are handled correctly +@test "Multiple extensions should get versions added" { + run process_extensions "io.quarkus:quarkus-resteasy-reactive,org.acme:acme-component,io.quarkus:quarkus-core" + echo "Test Output:" + echo "$output" + [ "$output" == "io.quarkus:quarkus-resteasy-reactive:2.0.0,org.acme:acme-component,io.quarkus:quarkus-core:2.0.0" ] +} + +# Test that the script fails when no extensions are provided +@test "No extensions should cause an error" { + run process_extensions "" + echo "Test Output:" + echo "$output" + [ "$output" == "" ] # Expecting an empty result for no extensions +} \ No newline at end of file diff --git a/packages/sonataflow-operator/Makefile b/packages/sonataflow-operator/Makefile index 1aafc812e07..c21179bae11 100644 --- a/packages/sonataflow-operator/Makefile +++ b/packages/sonataflow-operator/Makefile @@ -42,7 +42,7 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) -# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. +# IMAGE_TAG_BASE defines the image namespace and part of the image name for remote images. # This variable is used to construct full image tags for bundle and catalog images. # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both @@ -471,8 +471,8 @@ before-pr: generate-all test ## Run generate-all before executing tests. .PHONY: load-docker-image load-docker-image: install-kind kind load docker-image $(IMG) - kind load docker-image docker.io/apache/incubator-kie-sonataflow-builder:main - kind load docker-image docker.io/apache/incubator-kie-sonataflow-devmode:main + kind load docker-image $(shell pnpm build-env sonataFlowOperator.sonataflowBuilderImage) + kind load docker-image $(shell pnpm build-env sonataFlowOperator.sonataflowDevModeImage) .PHONY: install-kind install-kind: @@ -505,3 +505,25 @@ deploy-grafana: create-cluster .PHONY: delete-cluster delete-cluster: install-kind kind delete cluster && $(BUILDER) rm -f kind-registry + +# Updates the controllers_cfg.yaml file with the images used by the operator. +# These params come from the package.json file processing the env vars at ./env/index.js +.PHONY: update-config +update-config: + @echo "🔧 Preparing to update controllers config file..." + $(eval PARAMS := \ + jobsServicePostgreSQLImageTag=$$(shell build-env sonataFlowOperator.kogitoJobsServicePostgresqlImage) \ + jobsServiceEphemeralImageTag=$$(shell build-env sonataFlowOperator.kogitoJobsServiceEphemeralImage) \ + dataIndexPostgreSQLImageTag=$$(shell build-env sonataFlowOperator.kogitoDataIndexPostgresqlImage) \ + dataIndexEphemeralImageTag=$$(shell build-env sonataFlowOperator.kogitoDataIndexEphemeralImage) \ + sonataFlowBaseBuilderImageTag=$$(shell build-env sonataFlowOperator.sonataflowBuilderImage) \ + sonataFlowDevModeImageTag=$$(shell build-env sonataFlowOperator.sonataflowDevModeImage)) + @if [ -z "$(strip $(PARAMS))" ]; then \ + echo "⚠️ No variables resolved. Skipping updates to controllers config file."; \ + else \ + echo "📋 Resolved variables:"; \ + echo "$(PARAMS)" | tr ' ' '\n'; \ + echo "🚀 Running Python script to update controllers config file..."; \ + python ./hack/update_controllers_cfg.py $(PARAMS); \ + echo "✅ Configuration updated successfully!"; \ + fi diff --git a/packages/sonataflow-operator/config/manager/controllers_cfg.yaml b/packages/sonataflow-operator/config/manager/controllers_cfg.yaml index 5bfcc6c51c9..72780469e03 100644 --- a/packages/sonataflow-operator/config/manager/controllers_cfg.yaml +++ b/packages/sonataflow-operator/config/manager/controllers_cfg.yaml @@ -48,13 +48,10 @@ builderConfigMapName: "sonataflow-operator-builder-config" postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true diff --git a/packages/sonataflow-operator/config/manager/kustomization.yaml b/packages/sonataflow-operator/config/manager/kustomization.yaml index 0c430ec01b1..bcb8522fa41 100644 --- a/packages/sonataflow-operator/config/manager/kustomization.yaml +++ b/packages/sonataflow-operator/config/manager/kustomization.yaml @@ -35,7 +35,9 @@ configMapGenerator: - controllers_cfg.yaml name: controllers-config apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization +kind: + Kustomization + # Changed during "make build", do not attempt to modify it manually! images: - name: controller newName: docker.io/apache/incubator-kie-sonataflow-operator diff --git a/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml b/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml index cc73c324fc9..33d18f2b718 100644 --- a/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml +++ b/packages/sonataflow-operator/config/samples/sonataflow.org_v1alpha08_sonataflowplatform.yaml @@ -23,5 +23,5 @@ spec: build: config: registry: - address: docker.io/apache + address: host/namespace secret: regcred diff --git a/packages/sonataflow-operator/container-builder/api/build_types.go b/packages/sonataflow-operator/container-builder/api/build_types.go index 193142413ee..293c6c1b212 100644 --- a/packages/sonataflow-operator/container-builder/api/build_types.go +++ b/packages/sonataflow-operator/container-builder/api/build_types.go @@ -107,7 +107,7 @@ type PublishTask struct { } // GetRepositoryImageTag gets the full qualified Repository Name for the given image in the PublishTask. -// For example docker.io/myrepo/myimage:latest. +// For example registry.org/myrepo/myimage:latest. func (p *PublishTask) GetRepositoryImageTag() string { if len(p.Registry.Address) > 0 { return fmt.Sprintf("%s/%s", p.Registry.Address, p.Image) diff --git a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go index e2dfdc740e2..b15ac6387b3 100644 --- a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_kaniko_test.go @@ -41,7 +41,7 @@ func TestNewBuildWithKanikoCustomizations(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") @@ -116,7 +116,7 @@ func TestNewBuildWithKanikoWithBuildArgsAndEnv(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") diff --git a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go index 0d8ef87aae2..a5b029a10ba 100644 --- a/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/builder_test.go @@ -39,7 +39,7 @@ func TestNewBuild(t *testing.T) { ns := "test" c := test.NewFakeClient() - dockerFile, err := os.ReadFile("testdata/Dockerfile") + dockerFile, err := os.ReadFile("testdata/sample.Dockerfile") assert.NoError(t, err) workflowDefinition, err := os.ReadFile("testdata/greetings.sw.json") diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml b/packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile similarity index 50% rename from packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml rename to packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile index 178b173a54d..63307297b0b 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml +++ b/packages/sonataflow-operator/container-builder/builder/kubernetes/testdata/sample.Dockerfile @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -15,14 +15,33 @@ # specific language governing permissions and limitations # under the License. -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlowPlatform -metadata: - name: sonataflow-platform -spec: - build: - config: - strategy: operator - baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main - strategyOptions: - KanikoBuildCacheEnabled: "true" +# Sample Dockerfile used in tests +FROM ubuntu:20.04 + +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive + +# Update and install necessary dependencies +RUN apt-get update && apt-get install -y \ + curl \ + git \ + python3 \ + python3-pip \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies (if needed) +COPY requirements.txt /app/requirements.txt +RUN pip3 install -r /app/requirements.txt + +# Set up working directory +WORKDIR /app + +# Copy project files into the container +COPY . /app + +# Expose any ports (if your application needs it) +EXPOSE 8080 + +# Command to run the application or test +CMD ["python3", "app.py"] diff --git a/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml b/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml index a6608195102..81ae3ff6a09 100644 --- a/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml +++ b/packages/sonataflow-operator/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml @@ -18,9 +18,9 @@ name: platform-kaniko-using-cache spec: publishStrategy: "Kaniko" - baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main + baseImage: host/namespace/image:latest registry: - address: docker.io/apache + address: host/namespace secret: regcred PublishStrategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/hack/bump-version.sh b/packages/sonataflow-operator/hack/bump-version.sh index ffc95cef13a..ca7e4b92bad 100755 --- a/packages/sonataflow-operator/hack/bump-version.sh +++ b/packages/sonataflow-operator/hack/bump-version.sh @@ -20,20 +20,10 @@ set -e -script_dir_path=$(dirname "${BASH_SOURCE[0]}") -source "${script_dir_path}"/env.sh - imageName=$(pnpm build-env sonataFlowOperator.registry)/$(pnpm build-env sonataFlowOperator.account)/$(pnpm build-env sonataFlowOperator.name) imageTag=$(pnpm build-env sonataFlowOperator.buildTag) version=$(pnpm build-env sonataFlowOperator.version) -targetSonataflowBuilderImage=$(pnpm build-env sonataFlowOperator.sonataflowBuilderImage) -targetSonataflowDevModeImage=$(pnpm build-env sonataFlowOperator.sonataflowDevModeImage) -targetKogitoDataIndexEphemeralImage=$(pnpm build-env sonataFlowOperator.kogitoDataIndexEphemeralImage) -targetKogitoDataIndexPostgresqlImage=$(pnpm build-env sonataFlowOperator.kogitoDataIndexPostgresqlImage) -targetKogitoJobsServiceEphemeralImage=$(pnpm build-env sonataFlowOperator.kogitoJobsServiceEphemeralImage) -targetKogitoJobsServicePostgresqlImage=$(pnpm build-env sonataFlowOperator.kogitoJobsServicePostgresqlImage) - if [ -z "${version}" ]; then echo "Please inform the new version" exit 1 @@ -51,22 +41,9 @@ node -p "require('replace-in-file').sync({ from: /\bnewName:.*\b/g, to: 'newName node -p "require('replace-in-file').sync({ from: /\bversion: .*\b/g, to: 'version: ${version}', files: ['./images/bundle.yaml'] });" node -p "require('replace-in-file').sync({ from: /\bversion: .*\b/g, to: 'version: ${version}', files: ['./images/manager.yaml'] });" -# Update sonataflow-* images -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-builder:[\w\.]*/g, to: '${targetSonataflowBuilderImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-devmode:[\w\.]*/g, to: '${targetSonataflowDevModeImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-sonataflow-operator:[\w\.]*/g, to: '${targetSonataflowOperatorImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-data-index-ephemeral:[\w\.]*/g, to: '${targetKogitoDataIndexEphemeralImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-data-index-postgresql:[\w\.]*/g, to: '${targetKogitoDataIndexPostgresqlImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-jobs-service-ephemeral:[\w\.]*/g, to: '${targetKogitoJobsServiceEphemeralImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" -node -p "require('replace-in-file').sync({ from: /docker\.io\/apache\/incubator-kie-kogito-jobs-service-postgresql:[\w\.]*/g, to: '${targetKogitoJobsServicePostgresqlImage}', files: ['**/*.yaml', '**/*.containerfile', '**/*.dockerfile', '**/*Dockerfile', '**/*.go'] });" - -node -p "require('replace-in-file').sync({ from: /sonataflow-operator-system\/sonataflow-operator:[\w\.]*/g, to: 'sonataflow-operator-system/sonataflow-operator:${imageTag}', files: ['**/*.yaml'] });" - node -p "require('replace-in-file').sync({ from: /\boperatorVersion = .*/g, to: 'operatorVersion = \"${version}\"', files: ['version/version.go'] });" node -p "require('replace-in-file').sync({ from: /\btagVersion = .*/g, to: 'tagVersion = \"${imageTag}\"', files: ['version/version.go'] });" -node -p "require('replace-in-file').sync({ from: /\bcontainerImage:.*\b/g, to: 'containerImage: ${targetSonataflowOperatorImage}', files: ['$(getCsvFile)'] });" - make generate-all make vet diff --git a/packages/sonataflow-operator/hack/update_controllers_cfg.py b/packages/sonataflow-operator/hack/update_controllers_cfg.py new file mode 100644 index 00000000000..f309f07b9d1 --- /dev/null +++ b/packages/sonataflow-operator/hack/update_controllers_cfg.py @@ -0,0 +1,93 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from ruamel.yaml import YAML +import re + +# Relative to the project root +CONFIG_FILE = "config/manager/controllers_cfg.yaml" +BUILDER_DOCKERFILE = "config/manager/SonataFlow-Builder.containerfile" + +# Load the YAML file +yaml = YAML() +yaml.preserve_quotes = True + + +def update_imagetags(attribute_mappings): + """ + Update the YAML file based on provided variable mappings. + + :param attribute_mappings: Dictionary mapping YAML attribute names to their new values. + """ + # Read the YAML file + with open(CONFIG_FILE, "r") as file: + data = yaml.load(file) + + # Apply updates based on var_mappings + for cfg_key, cfg_value in attribute_mappings.items(): + if cfg_key in data and cfg_value: + data[cfg_key] = cfg_value + + # Write the updated YAML back to the file + with open(CONFIG_FILE, "w") as file: + yaml.dump(data, file) + + +def update_dockerfile(base_image_tag): + """ + Update the first FROM clause in the Dockerfile with the specified base image tag. + Preserves any trailing 'AS ' or other content after the image tag. + + :param base_image_tag: The new base image tag for the Dockerfile. + """ + with open(BUILDER_DOCKERFILE, "r") as file: + dockerfile_lines = file.readlines() + + for i, line in enumerate(dockerfile_lines): + if line.strip().startswith("FROM"): + match = re.match(r"FROM\s+(\S+)(.*)", line.strip()) + if match: + trailing_content = match.group(2) # Everything after the image tag + updated_line = f"FROM {base_image_tag}{trailing_content}\n" + print(f"📋 Updating first FROM clause to: {updated_line.strip()}") + dockerfile_lines[i] = updated_line + break + + with open(BUILDER_DOCKERFILE, "w") as file: + file.writelines(dockerfile_lines) + + +if __name__ == "__main__": + import sys + + if len(sys.argv) < 2: + print("Usage: python update_config.py ...") + sys.exit(1) + + # Parse the mappings from the command line arguments + var_mappings = {} + + for mapping in sys.argv[1:]: + yaml_attr, value = mapping.split("=", 1) + var_mappings[yaml_attr] = value + + # Update the YAML file + update_imagetags(var_mappings) + + # Update Dockerfile if the `sonataFlowBaseBuilderImageTag` is provided + if "sonataFlowBaseBuilderImageTag" in var_mappings: + update_dockerfile(var_mappings["sonataFlowBaseBuilderImageTag"]) diff --git a/packages/sonataflow-operator/install.js b/packages/sonataflow-operator/install.js deleted file mode 100644 index cd9c5c35ecb..00000000000 --- a/packages/sonataflow-operator/install.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const fs = require("fs"); -const path = require("path"); -const { env } = require("./env"); - -function getAllYamlFiles(dir) { - let results = []; - const list = fs.readdirSync(dir); - - list.forEach((file) => { - const fullPath = path.join(dir, file); - const stat = fs.statSync(fullPath); - - // Skip node_modules directory - if (stat && stat.isDirectory() && file !== "node_modules") { - // Recurse into subdirectory - results = results.concat(getAllYamlFiles(fullPath)); - } else if (file.endsWith(".yaml")) { - // Add .yaml file to results - results.push(fullPath); - } - }); - - return results; -} - -const baseDir = path.resolve(__dirname, "."); - -const yamlFiles = getAllYamlFiles(baseDir); - -yamlFiles.forEach((filePath) => { - const updatedContent = fs - .readFileSync(filePath, "utf-8") - .replace( - /org\.kie:kie-addons-quarkus-persistence-jdbc:\S*/, - `org.kie:kie-addons-quarkus-persistence-jdbc:${env.versions.kogito}` - ) - .replace( - /org\.kie\.kogito:kogito-addons-quarkus-jobs-knative-eventing:\S*/, - `org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:${env.versions.kogito}` - ) - .replace( - /- groupId: io\.quarkus\s+artifactId: quarkus-jdbc-postgresql\s+version: \S+/g, - `- groupId: io.quarkus\n artifactId: quarkus-jdbc-postgresql\n version: ${env.versions.quarkus}` - ) - .replace( - /- groupId: io\.quarkus\s+artifactId: quarkus-agroal\s+version: \S+/g, - `- groupId: io.quarkus\n artifactId: quarkus-agroal\n version: ${env.versions.quarkus}` - ) - .replace( - /- groupId: org\.kie\s+artifactId: kie-addons-quarkus-persistence-jdbc\s+version: \S+/g, - `- groupId: org.kie\n artifactId: kie-addons-quarkus-persistence-jdbc\n version: ${env.versions.kogito}` - ); - - fs.writeFileSync(filePath, updatedContent); - console.log(`Updated: ${filePath}`); -}); diff --git a/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go b/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go index b0585c86242..be67b5a33fc 100644 --- a/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go +++ b/packages/sonataflow-operator/internal/controller/builder/kogitoserverlessbuild_manager.go @@ -127,7 +127,7 @@ func getBuildArg(buildArgs []v1.EnvVar, name string) *v1.EnvVar { return nil } -func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GAV) bool { +func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GroupArtifactId) bool { for _, extension := range extensions { if isExtensionPresent(buildArg, extension) { return true @@ -136,6 +136,6 @@ func hasAnyExtensionPresent(buildArg *v1.EnvVar, extensions []cfg.GAV) bool { return false } -func isExtensionPresent(buildArg *v1.EnvVar, extension cfg.GAV) bool { - return strings.Contains(buildArg.Value, extension.GroupAndArtifact()) +func isExtensionPresent(buildArg *v1.EnvVar, extension cfg.GroupArtifactId) bool { + return strings.Contains(buildArg.Value, extension.String()) } diff --git a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go index 4b6a4fecdec..927d8d62e20 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go +++ b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg.go @@ -45,36 +45,31 @@ var defaultControllersCfg = &ControllersCfg{ BuilderConfigMapName: "sonataflow-operator-builder-config", } -type GAV struct { +type GroupArtifactId struct { GroupId string `yaml:"groupId,omitempty"` ArtifactId string `yaml:"artifactId,omitempty"` - Version string `yaml:"version,omitempty"` } -func (g *GAV) GroupAndArtifact() string { +func (g *GroupArtifactId) String() string { return fmt.Sprintf("%s:%s", g.GroupId, g.ArtifactId) } -func (g *GAV) String() string { - return fmt.Sprintf("%s:%s:%s", g.GroupId, g.ArtifactId, g.Version) -} - type ControllersCfg struct { - DefaultPvcKanikoSize string `yaml:"defaultPvcKanikoSize,omitempty"` - HealthFailureThresholdDevMode int32 `yaml:"healthFailureThresholdDevMode,omitempty"` - KanikoDefaultWarmerImageTag string `yaml:"kanikoDefaultWarmerImageTag,omitempty"` - KanikoExecutorImageTag string `yaml:"kanikoExecutorImageTag,omitempty"` - JobsServicePostgreSQLImageTag string `yaml:"jobsServicePostgreSQLImageTag,omitempty"` - JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"` - DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"` - DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"` - SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"` - SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"` - BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"` - PostgreSQLPersistenceExtensions []GAV `yaml:"postgreSQLPersistenceExtensions,omitempty"` - KogitoEventsGrouping bool `yaml:"kogitoEventsGrouping,omitempty"` - KogitoEventsGroupingBinary bool `yaml:"KogitoEventsGroupingBinary,omitempty"` - KogitoEventsGroupingCompress bool `yaml:"KogitoEventsGroupingCompress,omitempty"` + DefaultPvcKanikoSize string `yaml:"defaultPvcKanikoSize,omitempty"` + HealthFailureThresholdDevMode int32 `yaml:"healthFailureThresholdDevMode,omitempty"` + KanikoDefaultWarmerImageTag string `yaml:"kanikoDefaultWarmerImageTag,omitempty"` + KanikoExecutorImageTag string `yaml:"kanikoExecutorImageTag,omitempty"` + JobsServicePostgreSQLImageTag string `yaml:"jobsServicePostgreSQLImageTag,omitempty"` + JobsServiceEphemeralImageTag string `yaml:"jobsServiceEphemeralImageTag,omitempty"` + DataIndexPostgreSQLImageTag string `yaml:"dataIndexPostgreSQLImageTag,omitempty"` + DataIndexEphemeralImageTag string `yaml:"dataIndexEphemeralImageTag,omitempty"` + SonataFlowBaseBuilderImageTag string `yaml:"sonataFlowBaseBuilderImageTag,omitempty"` + SonataFlowDevModeImageTag string `yaml:"sonataFlowDevModeImageTag,omitempty"` + BuilderConfigMapName string `yaml:"builderConfigMapName,omitempty"` + PostgreSQLPersistenceExtensions []GroupArtifactId `yaml:"postgreSQLPersistenceExtensions,omitempty"` + KogitoEventsGrouping bool `yaml:"kogitoEventsGrouping,omitempty"` + KogitoEventsGroupingBinary bool `yaml:"KogitoEventsGroupingBinary,omitempty"` + KogitoEventsGroupingCompress bool `yaml:"KogitoEventsGroupingCompress,omitempty"` } // InitializeControllersCfg initializes the platform configuration for this instance. diff --git a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go index 2cdc5e1779f..0e81299c51e 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go +++ b/packages/sonataflow-operator/internal/controller/cfg/controllers_cfg_test.go @@ -37,22 +37,19 @@ func TestInitializeControllersCfgAt_ValidFile(t *testing.T) { assert.Equal(t, "local/sonataflow-devmode:1.0.0", cfg.SonataFlowDevModeImageTag) assert.Equal(t, 3, len(cfg.PostgreSQLPersistenceExtensions)) postgresExtensions := cfg.PostgreSQLPersistenceExtensions - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "io.quarkus", ArtifactId: "quarkus-jdbc-postgresql", - Version: "3.8.6", }, postgresExtensions[0]) - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "io.quarkus", ArtifactId: "quarkus-agroal", - Version: "3.8.6", }, postgresExtensions[1]) - assert.Equal(t, GAV{ + assert.Equal(t, GroupArtifactId{ GroupId: "org.kie", ArtifactId: "kie-addons-quarkus-persistence-jdbc", - Version: "999-20241208-SNAPSHOT", }, postgresExtensions[2]) assert.True(t, cfg.KogitoEventsGrouping) assert.True(t, cfg.KogitoEventsGroupingBinary) diff --git a/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml b/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml index e86fd8d56c2..b6d76a7e646 100644 --- a/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml +++ b/packages/sonataflow-operator/internal/controller/cfg/testdata/controllers-cfg-test.yaml @@ -27,13 +27,10 @@ sonataFlowDevModeImageTag: "local/sonataflow-devmode:1.0.0" postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT kogitoEventsGrouping: true kogitoEventsGroupingBinary: true kogitoEventsGroupingCompress: false diff --git a/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go b/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go index a8208fd517f..4381c7d679d 100644 --- a/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go +++ b/packages/sonataflow-operator/internal/controller/platform/platformutils_test.go @@ -20,6 +20,7 @@ package platform import ( + "fmt" "os" "regexp" "testing" @@ -43,16 +44,16 @@ func TestSonataFlowBuildController(t *testing.T) { assert.Fail(t, "Unable to read base Dockerfile") } dockerfile := string(dockerfileBytes) - // 1 - Let's verify that the default image is used (for this unit test is docker.io/apache/incubator-kie-sonataflow-builder:main) + // 1 - Let's verify that the default image is used resDefault := GetCustomizedBuilderDockerfile(dockerfile, *platform) - foundDefault, err := regexp.MatchString("FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder", resDefault) + foundDefault, err := regexp.MatchString(fmt.Sprintf("FROM %s AS builder", test.CommonImageTag), resDefault) assert.NoError(t, err) assert.True(t, foundDefault) // 2 - Let's try to override using the productized image - platform.Spec.Build.Config.BaseImage = "registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8" + platform.Spec.Build.Config.BaseImage = "host2.org/namespace2/builder2:main" resProductized := GetCustomizedBuilderDockerfile(dockerfile, *platform) - foundProductized, err := regexp.MatchString("FROM registry.access.redhat.com/openshift-serverless-1-tech-preview/logic-swf-builder-rhel8 AS builder", resProductized) + foundProductized, err := regexp.MatchString(fmt.Sprintf("FROM %s AS builder", platform.Spec.Build.Config.BaseImage), resProductized) assert.NoError(t, err) assert.True(t, foundProductized) } @@ -76,14 +77,14 @@ func TestGetCustomizedBuilderDockerfile_BaseImageCustomizationFromPlatform(t *te Build: v1alpha08.BuildPlatformSpec{ Template: v1alpha08.BuildTemplate{}, Config: v1alpha08.BuildPlatformConfig{ - BaseImage: "docker.io/apache/platfom-sonataflow-builder:main", + BaseImage: test.CommonImageTag, }, }, }, Status: v1alpha08.SonataFlowPlatformStatus{}, } - expectedDockerFile := "FROM docker.io/apache/platfom-sonataflow-builder:main AS builder\n\n# ETC, \n\n# ETC, \n\n# ETC" + expectedDockerFile := fmt.Sprintf("FROM %s AS builder\n\n# ETC, \n\n# ETC, \n\n# ETC", test.CommonImageTag) customizedDockerfile := GetCustomizedBuilderDockerfile(dockerFile, sfp) assert.Equal(t, expectedDockerFile, customizedDockerfile) } diff --git a/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile b/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile index c9b902ba326..dd8a8591387 100644 --- a/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile +++ b/packages/sonataflow-operator/internal/controller/platform/testdata/platformTest.Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder +FROM host/namespace/image:latest AS builder # Kogito User USER 1001 diff --git a/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go b/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go index be84323929f..5abc02f6c18 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/common/object_creators_test.go @@ -106,7 +106,7 @@ func TestMergePodSpec(t *testing.T) { workflow.Spec.PodTemplate = v1alpha08.FlowPodTemplateSpec{ Container: v1alpha08.ContainerSpec{ // this one we can override - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ // let's override a immutable attribute {Name: utils.DefaultServicePortName, ContainerPort: 9090}, @@ -148,7 +148,7 @@ func TestMergePodSpec(t *testing.T) { assert.Equal(t, "superuser", deployment.Spec.Template.Spec.ServiceAccountName) assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.Equal(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.Equal(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Equal(t, "VALUE_CUSTOM", flowContainer.Env[0].Value) assert.Len(t, flowContainer.VolumeMounts, 1) @@ -162,7 +162,7 @@ func TestMergePodSpecOverrideContainers(t *testing.T) { Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, @@ -181,7 +181,7 @@ func TestMergePodSpecOverrideContainers(t *testing.T) { assert.Len(t, deployment.Spec.Template.Spec.Containers, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.NotEqual(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.NotEqual(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Empty(t, flowContainer.Env) } @@ -382,7 +382,7 @@ func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) { PodTemplate: v1alpha08.FlowPodTemplateSpec{ Container: v1alpha08.ContainerSpec{ // this one we can override - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ // let's override a immutable attribute {Name: utils.DefaultServicePortName, ContainerPort: 9090}, @@ -466,7 +466,7 @@ func TestMergePodSpec_WithPostgreSQL_and_JDBC_URL_field(t *testing.T) { assert.Equal(t, "superuser", deployment.Spec.Template.Spec.ServiceAccountName) assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1) flowContainer, _ := kubeutil.GetContainerByName(v1alpha08.DefaultContainerName, &deployment.Spec.Template.Spec) - assert.Equal(t, "docker.io/example/my-workflow:1.0.0", flowContainer.Image) + assert.Equal(t, test.CommonImageTag, flowContainer.Image) assert.Equal(t, int32(8080), flowContainer.Ports[0].ContainerPort) assert.Equal(t, expectedEnvVars, flowContainer.Env) assert.Len(t, flowContainer.VolumeMounts, 1) @@ -485,7 +485,7 @@ func TestMergePodSpec_OverrideContainers_WithPostgreSQL_In_Workflow_CR(t *testin Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, @@ -658,7 +658,7 @@ func TestMergePodSpec_WithServicedPostgreSQL_In_Platform_And_In_Workflow_CR(t *t Containers: []corev1.Container{ { Name: v1alpha08.DefaultContainerName, - Image: "docker.io/example/my-workflow:1.0.0", + Image: test.CommonImageTag, Ports: []corev1.ContainerPort{ {Name: utils.DefaultServicePortName, ContainerPort: 9090}, }, diff --git a/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go b/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go index b81f3d53d73..e0aa6456230 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go +++ b/packages/sonataflow-operator/internal/controller/profiles/common/persistence/postgresql.go @@ -153,7 +153,7 @@ func UsesPostgreSQLPersistence(workflow *operatorapi.SonataFlow, platform *opera } // GetPostgreSQLExtensions returns the Quarkus extensions required for postgresql persistence. -func GetPostgreSQLExtensions() []cfg.GAV { +func GetPostgreSQLExtensions() []cfg.GroupArtifactId { return cfg.GetCfg().PostgreSQLPersistenceExtensions } diff --git a/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go b/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go index 78f50629258..7eb43f2768e 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/dev/profile_dev_test.go @@ -241,7 +241,7 @@ func Test_devProfileWithImageSnapshotOverrideWithPlatform(t *testing.T) { // check if the objects have been created deployment := test.MustGetDeployment(t, client, workflow) - assert.Equal(t, "docker.io/customgroup/custom-swf-builder-nightly:42.43.7", deployment.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, test.CommonImageTag, deployment.Spec.Template.Spec.Containers[0].Image) } func Test_devProfileWithWPlatformWithoutDevBaseImageAndWithBaseImage(t *testing.T) { diff --git a/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go b/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go index 099e4d07659..dbc5e405b2d 100644 --- a/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go +++ b/packages/sonataflow-operator/internal/controller/profiles/preview/deployment_handler_test.go @@ -85,7 +85,7 @@ func Test_CheckPodTemplateChangesReflectDeployment(t *testing.T) { assert.True(t, result.Requeue) // Second reconciliation, we do change the image and that must reflect the deployment - expectedImg := "docker.io/apache/my-new-workflow:1.0.0" + expectedImg := test.CommonImageTag workflow.Spec.PodTemplate.Container.Image = expectedImg utilruntime.Must(client.Update(context.TODO(), workflow)) result, objects, err = handler.Reconcile(context.TODO(), workflow) diff --git a/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go b/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go index cb983e82f51..b1de0db704a 100644 --- a/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go +++ b/packages/sonataflow-operator/internal/controller/sonataflowplatform_controller_test.go @@ -83,7 +83,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.Equal(t, v1alpha08.PlatformClusterKubernetes, ksp.Status.Cluster) @@ -121,7 +121,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -214,7 +214,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -524,7 +524,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.JobService) @@ -612,7 +612,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.JobService) @@ -688,7 +688,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -780,7 +780,7 @@ func TestSonataFlowPlatformController(t *testing.T) { // Perform some checks on the created CR assert.True(t, ksp.Status.IsReady()) assert.True(t, kscp.Status.IsReady()) - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Services.DataIndex) @@ -894,7 +894,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Eventing) @@ -994,7 +994,7 @@ func TestSonataFlowPlatformController(t *testing.T) { assert.NoError(t, cl.Get(context.TODO(), types.NamespacedName{Name: ksp.Name, Namespace: ksp.Namespace}, ksp)) // Perform some checks on the created CR - assert.Equal(t, "docker.io/apache", ksp.Spec.Build.Config.Registry.Address) + assert.Equal(t, test.CommonImageRegistryAccount, ksp.Spec.Build.Config.Registry.Address) assert.Equal(t, "regcred", ksp.Spec.Build.Config.Registry.Secret) assert.Equal(t, v1alpha08.OperatorBuildStrategy, ksp.Spec.Build.Config.BuildStrategy) assert.NotNil(t, ksp.Spec.Eventing) diff --git a/packages/sonataflow-operator/operator.yaml b/packages/sonataflow-operator/operator.yaml index c90861259e7..050b16eec7a 100644 --- a/packages/sonataflow-operator/operator.yaml +++ b/packages/sonataflow-operator/operator.yaml @@ -28166,13 +28166,10 @@ data: postgreSQLPersistenceExtensions: - groupId: io.quarkus artifactId: quarkus-jdbc-postgresql - version: 3.8.6 - groupId: io.quarkus artifactId: quarkus-agroal - version: 3.8.6 - groupId: org.kie artifactId: kie-addons-quarkus-persistence-jdbc - version: 999-20241208-SNAPSHOT # If true, the workflow deployments will be configured to send accumulated workflow status change events to the Data # Index Service reducing the number of produced events. Set to false to send individual events. kogitoEventsGrouping: true diff --git a/packages/sonataflow-operator/package.json b/packages/sonataflow-operator/package.json index 615fabf297e..655c7e6cac0 100644 --- a/packages/sonataflow-operator/package.json +++ b/packages/sonataflow-operator/package.json @@ -22,6 +22,7 @@ "bump-version": "run-script-os", "bump-version:darwin:linux": "./hack/bump-version.sh", "bump-version:win32": "echo 'Bumping version not supported on Windows'", + "controllers:update:cfg": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && make update-config", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", "image:build": "run-script-os", "image:build:darwin:win32": "echo 'Image build not supported on Windows and macOS'", @@ -30,7 +31,7 @@ "image:bundle:build:darwin:win32": "echo 'Build Operator bundle image not supported on Windows and macOS'", "image:bundle:build:linux": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && run-script-if --bool \"$(build-env containerImages.build)\" --then \"make bundle bundle-build\"", "install": "run-script-os", - "install:darwin:linux": "rimraf bin && go work sync && go mod tidy && node install.js && pnpm bump-version && pnpm format", + "install:darwin:linux": "rimraf bin && go work sync && go mod tidy && pnpm controllers:update:cfg && pnpm bump-version && pnpm format", "install:win32": "echo 'Install not supported on Windows'", "test": "run-script-os", "test:darwin:linux": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && run-script-if --ignore-errors \"$(build-env tests.ignoreFailures)\" --bool \"$(build-env tests.run)\" --then \"make test\"", diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml index ec547059f9f..066fb9e3615 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml @@ -30,7 +30,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml index 3c1ede7bd34..49c82e2103e 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml index b5a5baae84a..22b909957d7 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSIONS - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing services: dataIndex: enabled: false diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml index df922c072f9..76de2a4fac0 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml index 9274169d2c1..0377ef62717 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml index 45f60eb9597..1784c72a431 100644 --- a/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml +++ b/packages/sonataflow-operator/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml @@ -24,7 +24,7 @@ spec: template: buildArgs: - name: QUARKUS_EXTENSION - value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:999-20241208-SNAPSHOT + value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing config: strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml index 9b018ec72a1..bd07aba6733 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowbuild.yaml @@ -24,7 +24,7 @@ spec: timeout: 0s status: buildPhase: Succeeded - imageTag: 10.100.163.129/greeting:0.0.1 + imageTag: host/namespace/image:latest innerBuild: metadata: name: greeting diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml index 6d38cb2e4d4..93498cd04ac 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform.yaml @@ -28,5 +28,5 @@ spec: config: strategy: operator registry: - address: docker.io/apache + address: host/namespace secret: regcred diff --git a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml index 9d93ca147f9..73688a31931 100644 --- a/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml +++ b/packages/sonataflow-operator/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml @@ -28,7 +28,7 @@ spec: config: strategy: operator registry: - address: docker.io/apache + address: host/namespace secret: regcred eventing: broker: diff --git a/packages/sonataflow-operator/test/yaml.go b/packages/sonataflow-operator/test/yaml.go index 1793153ff5d..56139718a21 100644 --- a/packages/sonataflow-operator/test/yaml.go +++ b/packages/sonataflow-operator/test/yaml.go @@ -45,24 +45,22 @@ import ( ) const ( - sonataFlowOrderProcessingFolder = "order-processing" - sonataFlowSampleYamlCR = "sonataflow.org_v1alpha08_sonataflow.yaml" - SonataFlowGreetingsWithDataInputSchemaCR = "sonataflow.org_v1alpha08_sonataflow_greetings_datainput.yaml" - SonataFlowGreetingsWithStaticResourcesCR = "sonataflow.org_v1alpha08_sonataflow-metainf.yaml" - SonataFlowSimpleOpsYamlCR = "sonataflow.org_v1alpha08_sonataflow-simpleops.yaml" - SonataFlowVetWithEventCR = "sonataflow.org_v1alpha08_sonataflow_vet_event.yaml" - SonataFlowGreetingsDataInputSchemaConfig = "v1_configmap_greetings_datainput.yaml" - SonataFlowGreetingsStaticFilesConfig = "v1_configmap_greetings_staticfiles.yaml" - sonataFlowPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform.yaml" - sonataFlowPlatformWithBrokerYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml" - sonataFlowPlatformWithCacheMinikubeYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml" - sonataFlowPlatformForOpenshift = "sonataflow.org_v1alpha08_sonataflowplatform_openshift.yaml" - sonataFlowClusterPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowclusterplatform.yaml" - sonataFlowBuilderConfig = "sonataflow-operator-builder-config_v1_configmap.yaml" - sonataFlowBuildSucceed = "sonataflow.org_v1alpha08_sonataflowbuild.yaml" - knativeDefaultBrokerCR = "knative_default_broker.yaml" - e2eSamples = "test/testdata/" - manifestsPath = "bundle/manifests/" + CommonImageRegistryAccount = "host/namespace" + CommonImageTag = CommonImageRegistryAccount + "/image:latest" + sonataFlowSampleYamlCR = "sonataflow.org_v1alpha08_sonataflow.yaml" + SonataFlowGreetingsWithDataInputSchemaCR = "sonataflow.org_v1alpha08_sonataflow_greetings_datainput.yaml" + SonataFlowGreetingsWithStaticResourcesCR = "sonataflow.org_v1alpha08_sonataflow-metainf.yaml" + SonataFlowSimpleOpsYamlCR = "sonataflow.org_v1alpha08_sonataflow-simpleops.yaml" + SonataFlowVetWithEventCR = "sonataflow.org_v1alpha08_sonataflow_vet_event.yaml" + SonataFlowGreetingsDataInputSchemaConfig = "v1_configmap_greetings_datainput.yaml" + SonataFlowGreetingsStaticFilesConfig = "v1_configmap_greetings_staticfiles.yaml" + sonataFlowPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform.yaml" + sonataFlowPlatformWithBrokerYamlCR = "sonataflow.org_v1alpha08_sonataflowplatform_withBroker.yaml" + sonataFlowClusterPlatformYamlCR = "sonataflow.org_v1alpha08_sonataflowclusterplatform.yaml" + sonataFlowBuilderConfig = "sonataflow-operator-builder-config_v1_configmap.yaml" + sonataFlowBuildSucceed = "sonataflow.org_v1alpha08_sonataflowbuild.yaml" + knativeDefaultBrokerCR = "knative_default_broker.yaml" + manifestsPath = "bundle/manifests/" ) var projectDir = "" @@ -248,7 +246,7 @@ func GetBasePlatformWithBaseImageInReadyPhase(namespace string) *operatorapi.Son platform := GetBasePlatform() platform.Namespace = namespace platform.Status.Manager().MarkTrue(api.SucceedConditionType) - platform.Spec.Build.Config.BaseImage = "docker.io/customx/custom-swf-builder:24.8.17" + platform.Spec.Build.Config.BaseImage = CommonImageTag return platform } @@ -256,7 +254,7 @@ func GetBasePlatformWithDevBaseImageInReadyPhase(namespace string) *operatorapi. platform := GetBasePlatform() platform.Namespace = namespace platform.Status.Manager().MarkTrue(api.SucceedConditionType) - platform.Spec.DevMode.BaseImage = "docker.io/customgroup/custom-swf-builder-nightly:42.43.7" + platform.Spec.DevMode.BaseImage = CommonImageTag return platform } @@ -272,18 +270,6 @@ func GetBasePlatformWithBrokerInReadyPhase(namespace string) *operatorapi.Sonata return GetSonataFlowPlatformInReadyPhase(sonataFlowPlatformWithBrokerYamlCR, namespace) } -func GetPlatformMinikubeE2eTest() string { - return e2eSamples + sonataFlowPlatformWithCacheMinikubeYamlCR -} - -func GetPlatformOpenshiftE2eTest() string { - return e2eSamples + sonataFlowPlatformForOpenshift -} - -func GetSonataFlowE2eOrderProcessingFolder() string { - return GetPathFromE2EDirectory("order-processing") -} - func GetPathFromDataDirectory(join ...string) string { return filepath.Join(append([]string{getTestDataDir()}, join...)...) } From c59b38905f424993cb56e353fd27c5f8757486c3 Mon Sep 17 00:00:00 2001 From: Deepak Joseph <159427631+josedee@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:55:06 +0530 Subject: [PATCH 5/5] [kie-issues#1720] Enhance Process Details UI page to show nodeInstanceId each timer belongs to (#2820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pere Fernández --- .rat-excludes | 2 + .../src/main/resources/application.properties | 2 + .../JobsDetailsModal/JobsDetailsModal.tsx | 182 ++++++++++-------- .../ProcessDetailsTimelinePanel.tsx | 30 ++- .../src/graphql/graphql.schema.json | 64 ++++++ .../src/graphql/queries.tsx | 10 + .../src/graphql/types.tsx | 94 ++++++--- .../src/types.ts | 12 +- 8 files changed, 269 insertions(+), 127 deletions(-) diff --git a/.rat-excludes b/.rat-excludes index 5b3703d6da0..b652dffe0dc 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -2036,3 +2036,5 @@ scripts.iml index.test.js # scripts/check-junit-report-results/tests/reports/empty.xml empty.xml +# packages/runtime-tools-process-gateway-api/src/graphql/types.tsx +types.tsx diff --git a/examples/process-compact-architecture/src/main/resources/application.properties b/examples/process-compact-architecture/src/main/resources/application.properties index b8fed9c6a26..41ea3670e65 100644 --- a/examples/process-compact-architecture/src/main/resources/application.properties +++ b/examples/process-compact-architecture/src/main/resources/application.properties @@ -105,3 +105,5 @@ quarkus.http.test-port=0 quarkus.swagger-ui.always-include=true quarkus.kogito.data-index.graphql.ui.always-include=true +# Development tasks users +%dev.jbpm.devui.users.jdoe.groups=admin,HR,IT \ No newline at end of file diff --git a/packages/runtime-tools-process-enveloped-components/src/jobsManagement/envelope/components/JobsDetailsModal/JobsDetailsModal.tsx b/packages/runtime-tools-process-enveloped-components/src/jobsManagement/envelope/components/JobsDetailsModal/JobsDetailsModal.tsx index 180e38997e5..70f0b32f104 100644 --- a/packages/runtime-tools-process-enveloped-components/src/jobsManagement/envelope/components/JobsDetailsModal/JobsDetailsModal.tsx +++ b/packages/runtime-tools-process-enveloped-components/src/jobsManagement/envelope/components/JobsDetailsModal/JobsDetailsModal.tsx @@ -17,7 +17,7 @@ * under the License. */ -import React from "react"; +import React, { useCallback } from "react"; import { TextContent, Text, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; import { Modal } from "@patternfly/react-core/dist/js/components/Modal"; import { Flex, FlexItem } from "@patternfly/react-core/dist/js/layouts/Flex"; @@ -45,28 +45,46 @@ export const JobsDetailsModal: React.FC = ({ ouiaId, ouiaSafe, }) => { - const modalContent = () => { + const checkNumericProperty = useCallback((propertyValue?: number) => { + return propertyValue !== undefined && propertyValue !== null; + }, []); + + const modalContent = useCallback(() => { return (
- - - - Process Id: {" "} - - {job.processId} - - - - - - {" "} - Process Instance Id: {" "} - - {job.processInstanceId} - - + {job.processId && ( + + + + Process Id: {" "} + + {job.processId} + + + )} + {job.processInstanceId && ( + + + + {" "} + Process Instance Id: {" "} + + {job.processInstanceId} + + + )} + {job.nodeInstanceId && ( + + + + Node Instance Id: + + {job.nodeInstanceId} + + + )} @@ -75,83 +93,95 @@ export const JobsDetailsModal: React.FC = ({ {job.status} - - - - Priority: {" "} - - {job.priority} - - - {job.repeatInterval && ( + {checkNumericProperty(job.priority) && ( - RepeatInterval: + Priority: {" "} + + {job.priority} + + + )} + {checkNumericProperty(job.repeatInterval) && ( + + + + Repeat Interval: {job.repeatInterval} )} - {job.repeatLimit && ( + {checkNumericProperty(job.repeatLimit) && ( - RepeatLimit: + Repeat Limit: {job.repeatLimit} )} - - - - ScheduledId: - - {job.scheduledId} - - - - - - Retries: - - {job.retries} - - - - - - Execution counter: - - {job.executionCounter} - - - - - - Last Updated: - - - {new Date(`${job.lastUpdate}`)} - - - - - - - - Callback Endpoint:{" "} - - - {job.callbackEndpoint} - - + {job.scheduledId && ( + + + + Scheduled Id: + + {job.scheduledId} + + + )} + {checkNumericProperty(job.retries) && ( + + + + Retries: + + {job.retries} + + + )} + {checkNumericProperty(job.executionCounter) && ( + + + + Execution counter: + + {job.executionCounter} + + + )} + {job.lastUpdate && ( + + + + Last Updated: + + + {new Date(`${job.lastUpdate}`)} + + + + )} + {job.callbackEndpoint && ( + + + + + Callback Endpoint:{" "} + + + {job.callbackEndpoint} + + + )}
); - }; + }, [job, checkNumericProperty]); return ( = ({ }; const renderTimerIcon = (id: string) => { - return jobs.length > 0 ? ( - jobs.map((job, idx) => { - if (id === job.nodeInstanceId) { - return ( - - handleJobDetails(job)} - /> - - ); - } - })[0] - ) : ( - <> - ); + const job = jobs.find((job) => id === job.nodeInstanceId); + if (job) { + return ( + + handleJobDetails(job)} + /> + + ); + } + return <>; }; const detailsAction: JSX.Element[] = [ diff --git a/packages/runtime-tools-process-gateway-api/src/graphql/graphql.schema.json b/packages/runtime-tools-process-gateway-api/src/graphql/graphql.schema.json index 055cce17b9d..09ccfdeecc4 100644 --- a/packages/runtime-tools-process-gateway-api/src/graphql/graphql.schema.json +++ b/packages/runtime-tools-process-gateway-api/src/graphql/graphql.schema.json @@ -2110,6 +2110,16 @@ "ofType": null }, "defaultValue": null + }, + { + "name": "variables", + "description": null, + "type": { + "kind": "SCALAR", + "name": "JSON", + "ofType": null + }, + "defaultValue": null } ], "interfaces": null, @@ -2827,6 +2837,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "slaDueDate", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "source", "description": null, @@ -3100,6 +3122,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "slaDueDate", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "type", "description": null, @@ -3695,6 +3729,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "externalReferenceId", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "id", "description": null, @@ -3916,6 +3962,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "slaDueDate", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "DateTime", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "started", "description": null, @@ -7300,6 +7358,12 @@ } ] }, + { + "name": "oneOf", + "description": "Indicates an Input Object is a OneOf Input Object.", + "locations": ["INPUT_OBJECT"], + "args": [] + }, { "name": "skip", "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", diff --git a/packages/runtime-tools-process-gateway-api/src/graphql/queries.tsx b/packages/runtime-tools-process-gateway-api/src/graphql/queries.tsx index cae532f1b52..d167e7cd38f 100644 --- a/packages/runtime-tools-process-gateway-api/src/graphql/queries.tsx +++ b/packages/runtime-tools-process-gateway-api/src/graphql/queries.tsx @@ -370,6 +370,7 @@ export const GET_JOBS_WITH_FILTERS = gql` retries lastUpdate endpoint + nodeInstanceId executionCounter } } @@ -400,6 +401,15 @@ export const GET_PROCESS_INSTANCE_SVG = gql` } `; +export const GET_PROCESS_DEFINITIONS = gql` + query getProcessDefinitions { + ProcessDefinitions { + id + endpoint + } + } +`; + export const GET_PROCESS_DEFINITION_NODES = gql` query getProcessDefinitionNodes($processId: String) { ProcessDefinitions(where: { id: { equal: $processId } }) { diff --git a/packages/runtime-tools-process-gateway-api/src/graphql/types.tsx b/packages/runtime-tools-process-gateway-api/src/graphql/types.tsx index 609a31320fa..52788344315 100644 --- a/packages/runtime-tools-process-gateway-api/src/graphql/types.tsx +++ b/packages/runtime-tools-process-gateway-api/src/graphql/types.tsx @@ -1,22 +1,3 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - /* eslint-disable */ import gql from "graphql-tag"; import * as ApolloReactCommon from "@apollo/react-common"; @@ -280,6 +261,7 @@ export namespace GraphQL { start?: InputMaybe; state?: InputMaybe; updatedBy?: InputMaybe; + variables?: InputMaybe; }; export type StringArrayArgument = { @@ -360,6 +342,7 @@ export namespace GraphQL { rootProcessId?: Maybe; rootProcessInstanceId?: Maybe; serviceUrl?: Maybe; + slaDueDate?: Maybe; source?: Maybe; start?: Maybe; state?: Maybe; @@ -389,6 +372,7 @@ export namespace GraphQL { id: Scalars["String"]; name: Scalars["String"]; nodeId: Scalars["String"]; + slaDueDate?: Maybe; type: Scalars["String"]; }; @@ -451,6 +435,7 @@ export namespace GraphQL { description?: Maybe; endpoint?: Maybe; excludedUsers?: Maybe>; + externalReferenceId?: Maybe; id: Scalars["String"]; inputs?: Maybe; lastUpdate: Scalars["DateTime"]; @@ -465,6 +450,7 @@ export namespace GraphQL { rootProcessId?: Maybe; rootProcessInstanceId?: Maybe; schema?: Maybe; + slaDueDate?: Maybe; started?: Maybe; state?: Maybe; }; @@ -1338,6 +1324,7 @@ export namespace GraphQL { retries?: number | null; lastUpdate?: any | null; endpoint?: string | null; + nodeInstanceId?: string | null; executionCounter?: number | null; } | null> | null; }; @@ -1369,6 +1356,17 @@ export namespace GraphQL { ProcessInstances?: Array<{ __typename?: "ProcessInstance"; diagram?: string | null } | null> | null; }; + export type GetProcessDefinitionsQueryVariables = Exact<{ [key: string]: never }>; + + export type GetProcessDefinitionsQuery = { + __typename?: "Query"; + ProcessDefinitions?: Array<{ + __typename?: "ProcessDefinition"; + id: string; + endpoint?: string | null; + } | null> | null; + }; + export type GetProcessDefinitionNodesQueryVariables = Exact<{ processId?: InputMaybe; }>; @@ -1425,15 +1423,6 @@ export namespace GraphQL { export type HandleJobRescheduleMutation = { __typename?: "Mutation"; JobReschedule?: string | null }; - export const GetProcessDefinitionsDocument = gql` - query getProcessDefinitions { - ProcessDefinitions { - id - endpoint - } - } - `; - export const GetProcessInstancesDocument = gql` query getProcessInstances( $where: ProcessInstanceArgument @@ -2285,6 +2274,7 @@ export namespace GraphQL { retries lastUpdate endpoint + nodeInstanceId executionCounter } } @@ -2516,6 +2506,54 @@ export namespace GraphQL { GetProcessInstanceSvgQuery, GetProcessInstanceSvgQueryVariables >; + export const GetProcessDefinitionsDocument = gql` + query getProcessDefinitions { + ProcessDefinitions { + id + endpoint + } + } + `; + + /** + * __useGetProcessDefinitionsQuery__ + * + * To run a query within a React component, call `useGetProcessDefinitionsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetProcessDefinitionsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetProcessDefinitionsQuery({ + * variables: { + * }, + * }); + */ + export function useGetProcessDefinitionsQuery( + baseOptions?: ApolloReactHooks.QueryHookOptions + ) { + const options = { ...defaultOptions, ...baseOptions }; + return ApolloReactHooks.useQuery( + GetProcessDefinitionsDocument, + options + ); + } + export function useGetProcessDefinitionsLazyQuery( + baseOptions?: ApolloReactHooks.LazyQueryHookOptions + ) { + const options = { ...defaultOptions, ...baseOptions }; + return ApolloReactHooks.useLazyQuery( + GetProcessDefinitionsDocument, + options + ); + } + export type GetProcessDefinitionsQueryHookResult = ReturnType; + export type GetProcessDefinitionsLazyQueryHookResult = ReturnType; + export type GetProcessDefinitionsQueryResult = ApolloReactCommon.QueryResult< + GetProcessDefinitionsQuery, + GetProcessDefinitionsQueryVariables + >; export const GetProcessDefinitionNodesDocument = gql` query getProcessDefinitionNodes($processId: String) { ProcessDefinitions(where: { id: { equal: $processId } }) { diff --git a/packages/runtime-tools-process-gateway-api/src/types.ts b/packages/runtime-tools-process-gateway-api/src/types.ts index ec6c175bc55..fac95adaf18 100644 --- a/packages/runtime-tools-process-gateway-api/src/types.ts +++ b/packages/runtime-tools-process-gateway-api/src/types.ts @@ -37,15 +37,15 @@ export interface Job { id: string; status: JobStatus; expirationTime: Date; - priority: number; - callbackEndpoint: string; + priority?: number; + callbackEndpoint?: string; repeatInterval: number; repeatLimit: number; - scheduledId: string; - retries: number; - lastUpdate: Date; + scheduledId?: string; + retries?: number; + lastUpdate?: Date; executionCounter?: number; - endpoint: string; + endpoint?: string; nodeInstanceId?: string; processId?: string; processInstanceId?: string;