Skip to main content

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.

  1. Edit habaform.hf under the project root directory.
  2. Run habaform plan and make sure the changes are correctly reflecting your changes.
  3. Run habaform apply to apply those changes to your Harbor.

Workflow with GitHub Actions

Create two GitHub Actions workflow files as follows:

  1. 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 }}`
            })
  1. 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.

Metadata

Release files for habaform 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for habaform 0.0.1
File Interpreter ABI Platform Actions
habaform-0.0.1-py3-none-any.whl Python 3 none any Details for habaform-0.0.1-py3-none-any.whl

Release files / habaform-0.0.1-py3-none-any.whl

Download URL habaform-0.0.1-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee3730110865e81c64e0b9c9258fd06a8cefb87b52c7f9679ea54c9ef033a0bd
BLAKE2b-256 checksum
How to use checksums
68491530fb968b5dbd202abb3b608c1cc26a05e050abb6fbcc825db1d64f16a7
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for habaform 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page