Manage Harbor projects and members with ease.
Project description
habaform
Manage Harbor projects and members with ease.
Installation
pip3 install habaform
Usage
Init
After installation, you will need to parse the current Harbor Project/User model first, create a new git repository and run the following commands inside it:
export HARBOR_USERNAME="admin"
export HARBOR_PASSWORD="Harbor12345"
export HARBOR_URL="http://hub.nova.moe"
habaform parse
you will find these files inside your directory:
.
├── DO_NOT_TOUCH
│ └── habaform.hf
└── habaform.hf
1 directory, 2 files
Now you can commit and push thoses files to the GitHub repository.
Workflow in local environment
Habaform can be used without GitOps like operation, if you'd like to use habaform in your local environment, here is the common workflow.
- Edit
habaform.hf
under the project root directory. - Run
habaform plan
and make sure the changes are correctly reflecting your changes. - Run
habaform apply
to apply those changes to your Harbor.
Workflow with GitHub Actions
Create two GitHub Actions workflow files as follows:
plan.yml
This will run when PR is made, and will give the preview change on issue.
name: Plan Habaform
on: [pull_request]
jobs:
Plan:
runs-on: [self-hosted,X64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Setup Habaform
run: |
pip3 install habaform
- name: Plan
id: plan
env:
HARBOR_USERNAME: ${{secrets.HARBOR_USERNAME}}
HARBOR_PASSWORD: ${{secrets.HARBOR_PASSWORD}}
HARBOR_URL: ${{secrets.HARBOR_URL}}
run: |
echo 'HABAPLAN<<EOF' >> $GITHUB_ENV
habaform plan >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Preview Plan info
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${{ env.HABAPLAN }}`
})
apply.yml
This will run when PR is merged, will apply the changes to Harbor automatically.
name: Apply Habaform
on:
push:
branches: [ master ]
paths:
- 'habaform.hf'
jobs:
Apply:
runs-on: [self-hosted,X64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Setup Habaform
run: |
pip3 install habaform
- name: Apply
id: apply
env:
HARBOR_USERNAME: ${{secrets.HARBOR_USERNAME}}
HARBOR_PASSWORD: ${{secrets.HARBOR_PASSWORD}}
HARBOR_URL: ${{secrets.HARBOR_URL}}
run: |
habaform apply
- name: Sync config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Sync hf file"
git push
After these files are created, you can use PR to edit habaform.hf
to make changes to your Harbor.
For more info, refer to Habaform——用类似 IaC(Infrastructure as code) + GitOps 的方式管理 Harbor 的 Project 和 User at this moment, through I can promise there will be a better document soon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file habaform-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: habaform-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee3730110865e81c64e0b9c9258fd06a8cefb87b52c7f9679ea54c9ef033a0bd |
|
MD5 | ef33e6619ad3b350d7b3712c710a1790 |
|
BLAKE2b-256 | 68491530fb968b5dbd202abb3b608c1cc26a05e050abb6fbcc825db1d64f16a7 |