Skip to content

Commit

Permalink
Allow user to provide custom-manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavjainwiz committed May 14, 2024
1 parent 0b6dfa9 commit 5c71af6
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ods_ci/tasks/Resources/Files/dsc_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ metadata:
spec:
components:
codeflare:
devFlags: <codeflare_devflags>
managementState: <codeflare_value>
dashboard:
devFlags: <dashboard_devflags>
managementState: <dashboard_value>
datasciencepipelines:
devFlags: <datasciencepipelines_devflags>
managementState: <datasciencepipelines_value>
kserve:
devFlags: <kserve_devflags>
defaultDeploymentMode: Serverless
managementState: <kserve_value>
modelmeshserving:
devFlags: <modelmeshserving_devflags>
managementState: <modelmeshserving_value>
ray:
devFlags: <ray_devflags>
managementState: <ray_value>
kueue:
devFlags: <kueue_devflags>
managementState: <kueue_value>
trustyai:
devFlags: <trustyai_devflags>
managementState: <trustyai_value>
workbenches:
devFlags: <workbenches_devflags>
managementState: <workbenches_value>

16 changes: 16 additions & 0 deletions ods_ci/tasks/Resources/RHODS_OLM/install/oc_install.robot
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ Apply DataScienceCluster CustomResource
END
END
Create DataScienceCluster CustomResource Using Test Variables
Apply Custom Manifest in DataScienceCluster CustomResource Using Test Variables

Check warning

Code scanning / Robocop

Keyword name '{{ keyword_name }}' does not follow case convention Warning

Keyword name 'Apply Custom Manifest in DataScienceCluster CustomResource Using Test Variables' does not follow case convention
${yml} = Get File ${file_path}dsc_apply.yml
Log To Console Applying DSC yaml
Log To Console ${yml}
Expand Down Expand Up @@ -307,6 +308,21 @@ Create DataScienceCluster CustomResource Using Test Variables
END
END

Apply Custom Manifest in DataScienceCluster CustomResource Using Test Variables

Check warning

Code scanning / Robocop

Keyword name '{{ keyword_name }}' does not follow case convention Warning

Keyword name 'Apply Custom Manifest in DataScienceCluster CustomResource Using Test Variables' does not follow case convention
[Documentation] Apply custom manifests to a DSC file
Log To Console Applying Custom Manifests

${file_path} = Set Variable tasks/Resources/Files/
FOR ${cmp} IN @{COMPONENT_LIST}
IF $cmp in $CUSTOM_MANIFESTS
${manifest_string}= Convert To String ${CUSTOM_MANIFESTS}[${cmp}]

Check warning

Code scanning / Robocop

The assignment sign is not consistent within the file. Expected '{{ expected_sign }}' but got '{{ actual_sign }}' instead Warning

The assignment sign is not consistent within the file. Expected ' =' but got '=' instead
# Use sed to replace the placeholder with the YAML string
Run sed -i "s|<${cmp}_devflags>|${manifest_string}|g" ${file_path}dsc_apply.yml
ELSE
Run sed -i "s|<${cmp}_devflags>||g" ${file_path}dsc_apply.yml
END
END

Component Should Be Enabled
[Arguments] ${component} ${dsc_name}=${DSC_NAME}
${status} = Is Component Enabled ${component} ${dsc_name}
Expand Down
36 changes: 36 additions & 0 deletions ods_ci/utils/scripts/testconfig/generateTestConfigFile.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ def parse_args():
dest="components",
help="Comma-separated list of components and their states (component1:state1,component2:state2,...)",
)
parser.add_argument(
"--custom_manifests",
type=str,
dest="custom_manifests",
help="Comma-separated list of custom_manifests("
"component1:repo_org:repo_name:branch_name:context_dir:source_path,"
"component2:repo_org:repo_name:branch_name:context_dir:source_path,...)",
)

return parser.parse_args()

Expand All @@ -119,6 +127,27 @@ def change_component_state(components):
return component_states


def initialize_custom_manifest(custom_manifests):
# Parse and convert the custom manifest argument into a dictionary
manifest_details = {}
custom_manifest_list = custom_manifests.split(",")

for custom_manifest in custom_manifest_list:
comp, repo_org, repo_name, branch_name, context_dir, source_path = custom_manifest.split(":")
comp_manifest = {
"uri": f"https://github.com/{repo_org}/{repo_name}/tarball/{branch_name}",
"contextDir": context_dir,
"sourcePath": source_path if len(source_path) > 0 else ""
}

if comp not in manifest_details:
manifest_details[comp] = {"manifests": []}

manifest_details[comp]["manifests"].append(comp_manifest)

return manifest_details


def get_prometheus_token(project):
"""
Get prometheus token for the cluster.
Expand Down Expand Up @@ -156,6 +185,7 @@ def generate_test_config_file(
set_prometheus_config,
set_dashboard_url,
components=None,
custom_manifests=None,
):
"""
Generates test config file dynamically by
Expand Down Expand Up @@ -246,6 +276,11 @@ def generate_test_config_file(
print(components)
data["COMPONENTS"] = change_component_state(components)

if custom_manifests:
print("Setting custom_manifest")
print(custom_manifests)
data["CUSTOM_MANIFESTS"] = initialize_custom_manifest(custom_manifests)

# Login to test cluster using oc command
oc_login(
data["OCP_CONSOLE_URL"],
Expand Down Expand Up @@ -301,6 +336,7 @@ def main():
args.set_prometheus_config,
args.set_dashboard_url,
components=args.components,
custom_manifests=args.custom_manifests,
)
print("Done generating config file")

Expand Down

0 comments on commit 5c71af6

Please sign in to comment.