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

DUPLO-16826 Add amazon-ecr-credential-helper #40

Merged
merged 2 commits into from
May 13, 2024

Conversation

duplodavid
Copy link
Contributor

@duplodavid duplodavid commented Apr 18, 2024

User description

This adds the credential helper to Ubuntu 20, 22 and AmazonLinux2 flavor builds. It does include this in the GCP images as well.


Type

enhancement, bug_fix


Description

  • Added amazon-ecr-credential-helper installation and Docker configuration across multiple setup scripts for different OS versions.
  • Corrected the function name typo from installDependancies to installDependencies in several setup scripts.
  • Updated GitHub Actions in the workflow file to use newer versions for better performance and features.

Changes walkthrough

Relevant files
Enhancement
Setup.sh
Install Amazon ECR Credential Helper and Fix Typo               

AgentAmazonLinux2/Setup.sh

  • Corrected function name from installDependancies to
    installDependencies.
  • Added installation of amazon-ecr-credential-helper and configuration
    for Docker to use it.
  • +6/-2     
    Setup.sh
    Install Amazon ECR Credential Helper and Fix Typo               

    AgentUbuntu20/Setup.sh

  • Corrected function name from installDependancies to
    installDependencies.
  • Added installation of amazon-ecr-credential-helper and configuration
    for Docker to use it.
  • +4/-2     
    Setup.sh
    Install Amazon ECR Credential Helper and Fix Typo               

    AgentUbuntu22/Setup.sh

  • Corrected function name from installDependancies to
    installDependencies.
  • Added installation of amazon-ecr-credential-helper and configuration
    for Docker to use it.
  • +6/-2     
    SetupPython3.sh
    Install Amazon ECR Credential Helper and Fix Typo               

    AgentUbuntu22/SetupPython3.sh

  • Corrected function name from installDependancies to
    installDependencies.
  • Added installation of amazon-ecr-credential-helper and configuration
    for Docker to use it.
  • +6/-2     
    Configuration changes
    build-image.yaml
    Update GitHub Actions to Newer Versions                                   

    .github/workflows/build-image.yaml

  • Updated GitHub Actions to newer versions for artifact upload, AWS
    credentials configuration, and repository checkout.
  • +4/-4     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    This adds the credential helper to Ubuntu 20, 22 and AmazonLinux2
    flavor builds. It does include this in the GCP images as well.
    Copy link
    Contributor

    PR Description updated to latest commit (db1bbda)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves multiple script updates across different operating systems and also includes changes in GitHub Actions workflows. The changes are not overly complex but require careful validation to ensure compatibility and correctness across different environments.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Hardcoded Paths: The use of hardcoded paths like ~/.docker/config.json might not be suitable for all deployment scenarios or user configurations. This could lead to issues where the Docker configuration is not applied correctly for different users or in environments where the home directory is not standard.

    Permissions Issue: The scripts do not handle potential permissions issues that might arise when creating directories or files (e.g., mkdir -p ~/.docker). This could lead to failures in environments with restricted permissions.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileAgentAmazonLinux2/Setup.sh
    suggestion      

    Consider checking if the ~/.docker directory already exists and if the user has the necessary permissions to write to it before attempting to create it and write the config file. This can prevent runtime errors in environments with restricted permissions. [important]

    relevant linemkdir -p ~/.docker && echo '{ "credsStore": "ecr-login" }' > ~/.docker/config.json

    relevant fileAgentUbuntu20/Setup.sh
    suggestion      

    To enhance the robustness of the script, add error handling around critical operations like installing packages and modifying system configurations. This could include checking the return status of commands like sudo apt install and providing appropriate error messages. [important]

    relevant linesudo apt install -q -y amazon-ecr-credential-helper

    relevant fileAgentUbuntu22/Setup.sh
    suggestion      

    Instead of directly echoing configuration into files, consider using a safer method like a here-document or a configuration management tool to avoid issues with special characters and to improve readability and maintainability of the script. [medium]

    relevant linemkdir -p ~/.docker && echo '{ "credsStore": "ecr-login" }' > ~/.docker/config.json

    relevant file.github/workflows/build-image.yaml
    suggestion      

    Ensure that the version updates of GitHub Actions like aws-actions/configure-aws-credentials@v4 are compatible with the rest of your workflow and that all new features or changes are required for your use case. This helps in avoiding unnecessary complications from version changes. [medium]

    relevant lineuses: aws-actions/configure-aws-credentials@v4


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    Comment on lines +1 to +8
    ## 2024-04-18

    ### Added
    - Installed `amazon-ecr-credential-helper` and configured Docker to use it across Ubuntu 20, Ubuntu 22, and AmazonLinux2 setups.

    ### Changed
    - Corrected function name typo from `installDependancies` to `installDependencies` in setup scripts.
    - Updated GitHub Actions in the workflow file to use newer versions (v4) for better performance and features.
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    CHANGELOG.md update

    Copy link

    sonarcloud bot commented Apr 18, 2024

    Quality Gate Passed Quality Gate passed

    Issues
    0 New issues
    0 Accepted issues

    Measures
    0 Security Hotspots
    No data about Coverage
    No data about Duplication

    See analysis details on SonarCloud

    @duplodavid duplodavid merged commit 7e0604c into master May 13, 2024
    2 checks passed
    @duplodavid duplodavid deleted the DUPLO-16826-amazon-ecr-credential-helper branch May 13, 2024 20:34
    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