Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs platform/#2862: add variable to change the image configuration for the default image and for the docker mirror image #255

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

Monska85
Copy link
Contributor

@Monska85 Monska85 commented Dec 5, 2024

PR Type

Enhancement, Configuration changes


Description

  • Introduced configurable variables for both default and docker-mirror images in GitLab CI template
  • Added ability to override image configuration through project-specific .gitlab-ci.yml files
  • Replaced hardcoded image references with variable interpolation:
    • Default image: ${DEFAULT_IMAGE_REGISTRY}/${DEFAULT_IMAGE_REPOSITORY}:${DEFAULT_IMAGE_TAG}
    • Docker mirror: ${DOCKER_MIRROR_IMAGE_REGISTRY}/${DOCKER_MIRROR_IMAGE_REPOSITORY}:${DOCKER_MIRROR_IMAGE_TAG}
  • Default values maintain current behavior using ghcr.io registry

Changes walkthrough 📝

Relevant files
Configuration changes
.gitlab-ci-template.yml
Configurable Docker image variables for CI template           

templates/.gitlab-ci-template.yml

  • Replaced hardcoded image references with configurable variables
  • Added variables for default image configuration (registry, repository,
    tag)
  • Added variables for docker-mirror image configuration (registry,
    repository, tag)
  • +14/-2   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    …or the default image and for the docker mirror image
    @sparkfabrik-ai-bot
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    Container Registry Access:
    The PR introduces configurable image registries through variables. While this provides flexibility, it's important to ensure that only trusted registries are used and that proper access controls are in place to prevent pulling malicious images. Consider adding registry URL validation or restricting to allowed registries.

    ⚡ Recommended focus areas for review

    Configuration Validation
    Verify that the default values for the new image configuration variables match the previously hardcoded values to maintain backward compatibility

    Documentation
    Consider adding documentation about the required format and examples for overriding these variables in project-specific gitlab-ci.yml files

    @sparkfabrik-ai-bot
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Use specific version tags instead of 'latest' to ensure reproducible builds and avoid unexpected changes

    Add version pinning to avoid potential breaking changes from 'latest' tag

    templates/.gitlab-ci-template.yml [31-37]

    -DEFAULT_IMAGE_TAG: latest
    -DOCKER_MIRROR_IMAGE_TAG: latest
    +DEFAULT_IMAGE_TAG: "1.0.0"
    +DOCKER_MIRROR_IMAGE_TAG: "1.0.0"
    Suggestion importance[1-10]: 9

    Why: Version pinning is critical for build reproducibility and stability, preventing unexpected breaking changes that could occur with 'latest' tags.

    9
    Add fallback values for environment variables to improve pipeline reliability when variables are not set

    Add default fallback values using YAML anchors to ensure the pipeline doesn't fail
    if variables are unset

    templates/.gitlab-ci-template.yml [1]

    -image: ${DEFAULT_IMAGE_REGISTRY}/${DEFAULT_IMAGE_REPOSITORY}:${DEFAULT_IMAGE_TAG}
    +image: ${DEFAULT_IMAGE_REGISTRY:-ghcr.io}/${DEFAULT_IMAGE_REPOSITORY:-sparkfabrik/spark-k8s-deployer}:${DEFAULT_IMAGE_TAG:-latest}
    Suggestion importance[1-10]: 8

    Why: Adding default fallback values is a crucial improvement for pipeline stability, preventing failures when variables are unset and maintaining backward compatibility.

    8
    Possible issue
    Add validation rules for registry URLs to prevent pipeline failures due to invalid configurations

    Add validation for required registry URLs using CI/CD variable rules to catch
    configuration errors early

    templates/.gitlab-ci-template.yml [29-30]

     variables:
       DEFAULT_IMAGE_REGISTRY: ghcr.io
       DOCKER_MIRROR_IMAGE_REGISTRY: ghcr.io
    +rules:
    +  - if: $DEFAULT_IMAGE_REGISTRY =~ /^[a-zA-Z0-9][a-zA-Z0-9-_.]+[a-zA-Z0-9]$/
    +  - if: $DOCKER_MIRROR_IMAGE_REGISTRY =~ /^[a-zA-Z0-9][a-zA-Z0-9-_.]+[a-zA-Z0-9]$/
    Suggestion importance[1-10]: 7

    Why: Adding validation rules for registry URLs helps catch configuration errors early in the pipeline, preventing runtime failures due to invalid registry specifications.

    7

    @andypanix andypanix merged commit a7f25aa into master Dec 5, 2024
    2 checks passed
    @andypanix andypanix deleted the feat/2862_default_image_variables branch December 5, 2024 15:35
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants