Skip to content

feat(config): initial config package v1beta1

This is an experimental feature.

This change set introduces a new gitlab.com/gitlab-org/api/client-go/config package. It defines a configuration format for GitLab clients and comes with an implementation of how to use it in Go. The config package has a simple API to create a new configuration from various sources and eventually create a GitLab client. The configuration works similar to Kubernetes where you have three main "objects": instances, auths and contexts, where a context combines an instance and an auth. There are also preferences and custom data in the configuration. A simple example of a configuration may look like this:

    api-version: gitlab.com/config/v1

    instances:
        - name: gitlab-com
          server: https://gitlab.com
        - name: gdk-test
          server: https://gdk.test:3443
    auths:
        - name: gitlab-com-oauth
          auth-info:
            oauth2: {}
        - name: gitlab-token-env
          auth-info:
            personal-access-token:
                token-source:
                    env-var: GITLAB_TOKEN
        - name: root-gdk
          auth-info:
            personal-access-token:
                token-source:
                    env-var: GDK_GITLAB_TOKEN
    contexts:
        - name: gitlab-com
          instance: gitlab-com
          auth: gitlab-com-oauth
        - name: root-gdk
          instance: gdk-test
          auth: root-gdk

    current-context: gitlab-com

The current config implementation also supports automatic setup of a config / client combination when running in CI.

It also has OAuth2 support including the authorization flow and refreshing tokens.

Edited by Timo Furrer

Merge request reports

Loading