Giter Club home page Giter Club logo

Comments (7)

marcuspoehls avatar marcuspoehls commented on June 22, 2024 4

@jorlugaqui @kibertoad @biodrone Iโ€™ve tagged a new release version 1.7.0 that is now available in the GitHub Actions marketplace containing the MongoDB authentication feature ๐Ÿ˜ƒ

from mongodb-github-action.

biodrone avatar biodrone commented on June 22, 2024 2

Just used it in my project, working like a dream :)

from mongodb-github-action.

marcuspoehls avatar marcuspoehls commented on June 22, 2024

@jorlugaqui Hey Jorge, thank you for your feature request!

Can you please help me understand how youโ€™re injecting the MongoDB authentication credentials into your testing environment? Are you reading the values from environment variables and use them to connect to MongoDB? Or do you have hard-coded values in a configuration file in your app?

from mongodb-github-action.

jorlugaqui avatar jorlugaqui commented on June 22, 2024

Hi @marcuspoehls.

I'm not sure if by testing environment you mean the environment created by GitHub Actions or my local testing environment. So, I'll share both.

Local environment

I'm reading the values from environment variables and I use them to connect to the MongoDB server:

DB_HOST = os.environ.get('DB_HOST', 'localhost')
DB_NAME = os.environ.get('DB_NAME', '')
DB_USER = os.environ.get('DB_USER', '')
DB_PASSWORD = os.environ.get('DB_PASSWORD', '')

With values being injected via docker-compose like:

mongo:
    image: mongo
    restart: always
    ...
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
api:
    ...
    environment:
      ...
      DB_NAME: ${DB_NAME}
      DB_HOST: ${DB_HOST}
      DB_USER: ${MONGO_INITDB_ROOT_USERNAME}
      DB_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}

GitHub actions' environment

For now, I'm using hardcoded values, but when the moment comes, I'll switch to secrets.

 name: Run the API and Postman's tests
      ...
      env:
        FLASK_ENV: development
        API_HOST: 0.0.0.0
        FLASK_APP: main.py
        DB_NAME: ahm
        DB_HOST: localhost
        CI: true

How I'm imagining the feature

It will be our responsibility as developers to handle how the values will get into the workflow file. For instance, I could have a step defined like:

- name: Start MongoDB ${{ matrix.mongodb-version }}
   uses: supercharge/[email protected]
   with:
      mongodb-version: ${{ matrix.mongodb-version }}
   env:
      MONGO_INITDB_ROOT_USERNAME: foo
      MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.password }} 

One value hardcoded, one value coming from the secrets. The important thing will be that if these two variables are present, we could start the container with the -e flag like :

docker run -d --network some-network --name some-mongo \
    -e MONGO_INITDB_ROOT_USERNAME=$MONGO_INITDB_ROOT_USERNAME \
    -e MONGO_INITDB_ROOT_PASSWORD=$MONGO_INITDB_ROOT_PASSWORD \
    mongo

And therefore, achieve the "out of the box" authentication mechanism, which should be sufficient for a CI environment.

Let me know your thoughts.

from mongodb-github-action.

kibertoad avatar kibertoad commented on June 22, 2024

@marcuspoehls Are there still plans to implement this? I'm trying to setup Mongo in GA with auth, and there doesn't seem to be an easy way to do so currently :)

from mongodb-github-action.

marcuspoehls avatar marcuspoehls commented on June 22, 2024

@kibertoad Hey Igor, thank you for your patience. Iโ€™m in for this feature. Do you want to PR it?

from mongodb-github-action.

marcuspoehls avatar marcuspoehls commented on June 22, 2024

Awesome!

from mongodb-github-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.