Package: idem-gitlab
Gitlab provider for idem.AboutManage Gitlab withidem.What is POP?This project is built withpop, a Python-based
implementation ofPlugin Oriented Programming (POP). POP seeks to bring
together concepts and wisdom from the history of computing in new ways to solve
modern computing problems.For more information:Intro to Plugin Oriented Programming (POP)pop-awesomepop-createGetting StartedPrerequisitesPython 3.9+git(if installing from source, or contributing to the project)InstallationNoteIf wanting to contribute to the project, and setup your local development
environment, see theCONTRIBUTING.rstdocument in the source repository
for this project.If wanting to useidem-gitlab, you can do so by either
installing from PyPI or from source.Install from PyPIpipinstallidem-gitlabInstall from source# clone repogitclonegit@gitlab.com/vmware/idem/idem-gitlab.gitcdidem-gitlab# Setup venvpython3-mvenv.venvsource.venv/bin/activatepipinstallpip==21-e.UsagecredentialsThe preferred authentication method to idem-gitlab is with a personal access token.
To create a personal access token, see theGitlab documentation.
Create an acct_file with the following format:gitlab:default:token:<personal_access_token># Optional parametersendpoint_url:https://gitlab.comapi_version:v4sudo:<user>owned:TrueEncrypt the acct_file with:idemencrypt/path/to/acct_fileThe first time this command is run, it will output an ACCT_KEY that can be used to decrypt the file.
Put the ACCT_KEY and the ACCT_FILE in the environment variables and idem will find and use your gitlab profile automatically.exportACCT_KEY="<acct_key>"exportACCT_FILE=/path/to/acct_fileOnce your credentials are in place, you can test them by running any of the following commands:idemexecgitlab.version.getidemexecgitlab.metadata.getidemexecgitlab.avatar.getemail="gitlab_user@example.com"idemexecgitlab.namespace.getidemexecgitlab.project.commit.get"<commit_sha/branch/tag/null>"project_id="<project_id>"Supported ResourcesThe following are REFs for resources that are currently supported by idem-gitlab.gitlab.groupgitlab.group.membergitlab.group.variablegitlab.impersonation_tokengitlab.personal_access_tokengitlab.projectgitlab.project.branchgitlab.project.membergitlab.project.protected_branchgitlab.project.protected_taggitlab.project.taggitlab.project.variablegitlab.runnergitlab.userFor each ref, there are functions for create, list, get, update, and delete operations.Idem-gitlab uses the “auto_state” contract to combine these CRUD operations into present and absent states.ExamplesRun CRUD operations using the idem exec commands:idemexecgitlab.project.createpath=new_projectidemexecgitlab.project.listidemexecgitlab.project.get"<new_project_id>"idemexecgitlab.project.update"<new_project_id>"repository_access_level=privateidemexecgitlab.project.delete"<new_project_id>"Create an SLS files based on existing resource:idemdescribegitlab.group>/srv/idem/gitlab/group.slsidemdescribegitlab.group.member>/srv/idem/gitlab/group_member.slsidemdescribegitlab.group.variable>/srv/idem/gitlab/group_variable.slsidemdescribegitlab.project>/srv/idem/gitlab/project.slsidemdescribegitlab.project.branch>/srv/idem/gitlab/branch.slsidemdescribegitlab.project.member>/srv/idem/gitlab/project_member.slsidemdescribegitlab.project.protected_branch>/srv/idem/gitlab/protected_branch.slsidemdescribegitlab.project.protected_tag>/srv/idem/gitlab/protected_tag.slsidemdescribegitlab.project.tag>/srv/idem/gitlab/tag.slsidemdescribegitlab.project.variable>/srv/idem/gitlab/project_variable.slsidemdescribegitlab.runner>/srv/idem/gitlab/runner.slsidemdescribegitlab.user>/srv/idem/gitlab/user.slsCreate a top-level SLS file that sources all the others:# /srv/idem/gitlab/init.slsinclude:-group-group_member-group_variable-project_member-project-branch-protected_branch-protected_tag-tag-project_variable-runner-userRun “idem state” to idempotently enforce changes to the any of the files created:idemstate/srv/idem/gitlabAnd that’s it! You are now using idem-gitlab to manage your gitlab resources.TestingTo run the tests using a gitlab docker image, first run:dockerrun-d-p80:80--envGITLAB_ROOT_PASSWORD=not_securegitlab/gitlab-ceFor testing you can use the sample credentials file for tests:exportACCT_FILE=$PWD/example/credentials.yamlRun the test suite with nox:pip3installnoxnox-p3.11AutogenerationAutogeneration utilizespop-createto parse the gitlab api and generate modules for new resources.
To perform the autogeneration, first you need to install idem-gitlab with theautogenextras:pip3installidem-gitlab[autogen]Next, run  pop-create to generate the modules in the current directory:pop-creategitlab--directory$PWD--create-pluginauto_statepop-creategitlab--directory$PWD--create-plugintestsThese modules won’t work out-of-the-box, they will likely need manual changes
to conform them to the rest of idem-gitlab and make them functional.
Once you have fully implemented a new resource, submit a PR and we will review it and hopefully
add it to idem-gitlab’s functionality!RoadmapReference theopen issuesfor a list of
proposed features (and known issues).AcknowledgementsImg Shieldsfor making repository badges easy.