Skip to content

Conversation

@yxxhero
Copy link
Member

@yxxhero yxxhero commented Feb 2, 2026

Summary

Add support for reading Terraform state from GitLab using HTTP(S) URLs with GitLab authentication. This allows vals to fetch tfstate from GitLab's Terraform state backend using GITLAB_USER and GITLAB_TOKEN credentials.

Changes

  • Add ProviderTFStateGitLab constant and provider case in vals.go
  • Extend tfstate provider to support GitLab backend with auth
  • Add gitlab_user and gitlab_token config options
  • Support GITLAB_USER and GITLAB_TOKEN environment variables
  • Add tfstategitlab to stringprovider for ref+ syntax support
  • Add unit tests for GitLab provider
  • Add documentation in README

Usage

With environment variables:

export GITLAB_USER="username"
export GITLAB_TOKEN="pat-token"

Or in vals config:

providers:
  - name: tfstategitlab
    gitlab_user: username
    gitlab_token: pat-token

Then reference values:

my_value: ref+tfstategitlab://gitlab.com/api/v4/projects/123/terraform/state/my-state/aws_vpc.main.id

Fixes #661

Add support for reading Terraform state from GitLab using HTTP(S) URLs
with GitLab authentication. This allows vals to fetch tfstate from
GitLab's Terraform state backend using GITLAB_USER and GITLAB_TOKEN
credentials.

- Add ProviderTFStateGitLab constant and provider case
- Extend tfstate provider to support GitLab backend with auth
- Add gitlab_user and gitlab_token config options
- Support GITLAB_USER and GITLAB_TOKEN environment variables
- Add tfstategitlab to stringprovider for ref+ syntax
- Add unit tests for GitLab provider

Fixes #661

Signed-off-by: yxxhero <aiopsclub@163.com>
Add usage examples and documentation for the new GitLab Terraform state
provider in the README.

Signed-off-by: yxxhero <aiopsclub@163.com>
- Reorder struct fields to fix fieldalignment linter
- Reorder imports for gci formatter
- Update struct initializations to match new field order

Signed-off-by: yxxhero <aiopsclub@163.com>
- Store api.StaticConfig instead of individual gitlab_user/token fields
- Read gitlab_user and gitlab_token from config when needed
- Reorder struct fields for better memory alignment

Signed-off-by: yxxhero <aiopsclub@163.com>
- Keep original field names for consistency
- Read config values at initialization time

Signed-off-by: yxxhero <aiopsclub@163.com>
- Read GITLAB_USER and GITLAB_TOKEN directly from environment variables
- Simplifies provider struct without adding new fields

Signed-off-by: yxxhero <aiopsclub@163.com>
@yxxhero yxxhero force-pushed the feature/tfstategitlab-provider branch from d9e7791 to 0755884 Compare February 2, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: read tfstate from gitlab

2 participants