components

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package components provides typed Go wrappers for GitLab CI/CD components.

These wrappers make it easy to include official GitLab components in your pipeline definitions with typed inputs.

Example usage:

import (
	"github.com/lex00/wetwire-gitlab-go/components"
	"github.com/lex00/wetwire-gitlab-go/pipeline"
)

var Pipeline = pipeline.Pipeline{
	Include: []pipeline.Include{
		components.Sast(components.SastConfig{
			Stage: "test",
		}),
		components.SecretDetection(components.SecretDetectionConfig{}),
	},
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accessibility

func Accessibility(cfg AccessibilityConfig) pipeline.Include

Accessibility creates an include directive for the Accessibility component.

func ApiSecurity

func ApiSecurity(cfg ApiSecurityConfig) pipeline.Include

ApiSecurity creates an include directive for the API Security component.

func Aws

func Aws(cfg AwsConfig) pipeline.Include

Aws creates an include directive for the AWS deployment component.

func BrowserPerformance

func BrowserPerformance(cfg BrowserPerformanceConfig) pipeline.Include

BrowserPerformance creates an include directive for the Browser Performance component.

func CodeQuality

func CodeQuality(cfg CodeQualityConfig) pipeline.Include

CodeQuality creates an include directive for the GitLab Code Quality component.

func ContainerScanning

func ContainerScanning(cfg ContainerScanningConfig) pipeline.Include

ContainerScanning creates an include directive for the GitLab Container Scanning component.

func CoverageReport

func CoverageReport(cfg CoverageReportConfig) pipeline.Include

CoverageReport creates an include directive for the GitLab Coverage Report component.

func Dast

func Dast(cfg DastConfig) pipeline.Include

Dast creates an include directive for the GitLab DAST component.

func DependencyScanning

func DependencyScanning(cfg DependencyScanningConfig) pipeline.Include

DependencyScanning creates an include directive for the GitLab Dependency Scanning component.

func DockerBuild

func DockerBuild(cfg DockerBuildConfig) pipeline.Include

DockerBuild creates an include directive for the GitLab Docker Build component.

Example

ExampleDockerBuild demonstrates using the Docker Build component to build and push container images.

// Configure Docker build with custom tags
dockerInclude := components.DockerBuild(components.DockerBuildConfig{
	Stage:       "build",
	DockerImage: "myapp",
	Context:     ".",
	Dockerfile:  "Dockerfile",
	Tags:        "latest,$CI_COMMIT_SHA",
})

// Create a minimal pipeline
buildJob := pipeline.Job{
	Name:   "prepare",
	Stage:  "build",
	Script: List("echo Preparing build environment"),
}

p := map[string]any{
	"stages":      List("build", "test"),
	"include":     List(dockerInclude),
	buildJob.Name: buildJob,
}

data, _ := yaml.Marshal(p)
fmt.Println(string(data))
Output:

include:
    - component: gitlab.com/components/docker-build@1
      inputs:
        CONTEXT: .
        DOCKER_IMAGE: myapp
        DOCKERFILE: Dockerfile
        TAGS: latest,$CI_COMMIT_SHA
        stage: build
prepare:
    stage: build
    script:
        - echo Preparing build environment
stages:
    - build
    - test

func Helm

func Helm(cfg HelmConfig) pipeline.Include

Helm creates an include directive for the Helm deployment component.

func Kubernetes

func Kubernetes(cfg KubernetesConfig) pipeline.Include

Kubernetes creates an include directive for the Kubernetes deployment component.

func LicenseScanning

func LicenseScanning(cfg LicenseScanningConfig) pipeline.Include

LicenseScanning creates an include directive for the GitLab License Scanning component.

func LoadPerformance

func LoadPerformance(cfg LoadPerformanceConfig) pipeline.Include

LoadPerformance creates an include directive for the Load Performance component.

func NpmPublish

func NpmPublish(cfg NpmPublishConfig) pipeline.Include

NpmPublish creates an include directive for the npm publish component.

func Pages

func Pages(cfg PagesConfig) pipeline.Include

Pages creates an include directive for the GitLab Pages component.

func Release

func Release(cfg ReleaseConfig) pipeline.Include

Release creates an include directive for the GitLab Release component.

func Sast

func Sast(cfg SastConfig) pipeline.Include

Sast creates an include directive for the GitLab SAST component.

Example

ExampleSast demonstrates using the SAST (Static Application Security Testing) component.

// Basic SAST configuration
sastInclude := components.Sast(components.SastConfig{
	Stage: "test",
})

// Create a pipeline with SAST
p := map[string]any{
	"stages":  List("build", "test"),
	"include": List(sastInclude),
}

data, _ := yaml.Marshal(p)
fmt.Println(string(data))
Output:

include:
    - component: gitlab.com/components/sast@1
      inputs:
        stage: test
stages:
    - build
    - test

func SecretDetection

func SecretDetection(cfg SecretDetectionConfig) pipeline.Include

SecretDetection creates an include directive for the GitLab Secret Detection component.

Example

ExampleSecretDetection demonstrates using the Secret Detection component to scan for secrets in code.

// Configure secret detection with excluded paths
secretDetectionInclude := components.SecretDetection(components.SecretDetectionConfig{
	Stage:                        "security",
	SecretDetectionExcludedPaths: "tests/,docs/",
})

// Create a pipeline with secret detection
p := map[string]any{
	"stages":  List("build", "security", "deploy"),
	"include": List(secretDetectionInclude),
}

data, _ := yaml.Marshal(p)
fmt.Println(string(data))
Output:

include:
    - component: gitlab.com/components/secret-detection@1
      inputs:
        SECRET_DETECTION_EXCLUDED_PATHS: tests/,docs/
        stage: security
stages:
    - build
    - security
    - deploy

func Terraform

func Terraform(cfg TerraformConfig) pipeline.Include

Terraform creates an include directive for the GitLab Terraform component.

Types

type AccessibilityConfig

type AccessibilityConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// A11yUrl is the URL to test for accessibility
	A11yUrl string `json:"a11y_url,omitempty"`
	// Standard is the accessibility standard (e.g., WCAG2A, WCAG2AA, WCAG2AAA)
	Standard string `json:"standard,omitempty"`
	// Threshold is the error threshold level
	Threshold string `json:"threshold,omitempty"`
	// Reporter is the output format (e.g., json, cli)
	Reporter string `json:"reporter,omitempty"`
}

AccessibilityConfig contains inputs for the Accessibility scanning component. Accessibility scanning component using tools like pa11y.

See: https://docs.gitlab.com/ee/ci/testing/accessibility_testing.html

type ApiSecurityConfig

type ApiSecurityConfig struct {
	// Stage is the pipeline stage (default: security)
	Stage string `json:"stage,omitempty"`
	// ApiSpec is the path to the API specification (OpenAPI/Swagger)
	ApiSpec string `json:"api_spec,omitempty"`
	// ApiUrl is the base URL of the API to test
	ApiUrl string `json:"api_url,omitempty"`
	// AuthToken is the authentication token for API access
	AuthToken string `json:"auth_token,omitempty"`
	// SecurityLevel is the security testing level (e.g., low, medium, high)
	SecurityLevel string `json:"security_level,omitempty"`
}

ApiSecurityConfig contains inputs for the API Security scanning component. API security scanning component for testing API endpoints.

See: https://docs.gitlab.com/ee/user/application_security/api_fuzzing/

type AwsConfig

type AwsConfig struct {
	// Stage is the pipeline stage (default: deploy)
	Stage string `json:"stage,omitempty"`
	// AwsRegion is the AWS region
	AwsRegion string `json:"aws_region,omitempty"`
	// AwsAccessKeyId is the AWS access key ID
	AwsAccessKeyId string `json:"aws_access_key_id,omitempty"`
	// AwsSecretAccessKey is the AWS secret access key
	AwsSecretAccessKey string `json:"aws_secret_access_key,omitempty"`
	// Service is the AWS service to deploy to (e.g., ecs, lambda, s3)
	Service string `json:"service,omitempty"`
	// ClusterName is the ECS cluster name (for ECS deployments)
	ClusterName string `json:"cluster_name,omitempty"`
}

AwsConfig contains inputs for the AWS deployment component. AWS deployment component for deploying to AWS services.

See: https://aws.amazon.com/

type BrowserPerformanceConfig

type BrowserPerformanceConfig struct {
	// Stage is the pipeline stage (default: performance)
	Stage string `json:"stage,omitempty"`
	// PerformanceUrl is the URL to test
	PerformanceUrl string `json:"performance_url,omitempty"`
	// Tool is the performance testing tool (e.g., lighthouse, sitespeed)
	Tool string `json:"tool,omitempty"`
	// Runs is the number of test runs to average
	Runs string `json:"runs,omitempty"`
	// ThrottlingPreset is the network throttling preset
	ThrottlingPreset string `json:"throttling_preset,omitempty"`
}

BrowserPerformanceConfig contains inputs for the Browser Performance testing component. Browser performance testing component using tools like Lighthouse.

See: https://docs.gitlab.com/ee/ci/testing/browser_performance_testing.html

type CodeQualityConfig

type CodeQualityConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// SourcePath is the path to analyze (default: current directory)
	SourcePath string `json:"source_path,omitempty"`
	// ReportFormat is the output format for the report (e.g., json, html)
	ReportFormat string `json:"report_format,omitempty"`
	// CodeQualityImage is the Docker image to use for code quality analysis
	CodeQualityImage string `json:"code_quality_image,omitempty"`
}

CodeQualityConfig contains inputs for the Code Quality component. GitLab Code Quality component for analyzing code quality issues.

See: https://docs.gitlab.com/user/ci/testing/code_quality.html

type ContainerScanningConfig

type ContainerScanningConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// CsImage is the container image to scan
	CsImage string `json:"cs_image,omitempty"`
	// CsDockerfilePath is the path to the Dockerfile
	CsDockerfilePath string `json:"cs_dockerfile_path,omitempty"`
	// CsSeverityThreshold is the minimum severity to report (UNKNOWN, LOW, MEDIUM, HIGH, CRITICAL)
	CsSeverityThreshold string `json:"cs_severity_threshold,omitempty"`
	// CsDisableLanguageVulns disables language-specific vulnerability scanning
	CsDisableLanguageVulns string `json:"cs_disable_language_vulns,omitempty"`
	// CsDisableSecretDetection disables secret detection in container images
	CsDisableSecretDetection string `json:"cs_disable_secret_detection,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
}

ContainerScanningConfig contains inputs for the Container Scanning component. GitLab Container Scanning component for detecting vulnerabilities in container images.

See: https://docs.gitlab.com/user/application_security/container_scanning/

type CoverageReportConfig

type CoverageReportConfig struct {
	Stage                string `json:"stage,omitempty"`
	CoverageReportPath   string `json:"coverage_report_path,omitempty"`
	CoverageReportFormat string `json:"coverage_report_format,omitempty"`
}

CoverageReportConfig contains inputs for the Coverage Report component. GitLab Coverage Report component.

type DastConfig

type DastConfig struct {
	// Stage is the pipeline stage (default: dast)
	Stage string `json:"stage,omitempty"`
	// DastWebsite is the URL of the website to scan
	DastWebsite string `json:"dast_website,omitempty"`
	// DastFullScanEnabled enables full scan mode
	DastFullScanEnabled string `json:"dast_full_scan_enabled,omitempty"`
	// DastBrowserScan enables browser-based scanning
	DastBrowserScan string `json:"dast_browser_scan,omitempty"`
	// DastExcludeUrls is a comma-separated list of URLs to exclude
	DastExcludeUrls string `json:"dast_exclude_urls,omitempty"`
	// DastAuthUrl is the authentication page URL
	DastAuthUrl string `json:"dast_auth_url,omitempty"`
	// DastUsername is the username for authentication
	DastUsername string `json:"dast_username,omitempty"`
	// DastPassword is the password for authentication
	DastPassword string `json:"dast_password,omitempty"`
	// DastPasswordVariable is the variable name containing the password
	DastPasswordVariable string `json:"dast_password_variable,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
}

DastConfig contains inputs for the DAST component. GitLab Dynamic Application Security Testing (DAST) component.

See: https://docs.gitlab.com/user/application_security/dast/

type DependencyScanningConfig

type DependencyScanningConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// DsExcludedPaths is a comma-separated list of paths to exclude
	DsExcludedPaths string `json:"ds_excluded_paths,omitempty"`
	// DsExcludedAnalyzers is a comma-separated list of analyzers to skip
	DsExcludedAnalyzers string `json:"ds_excluded_analyzers,omitempty"`
	// DsDefaultAnalyzers is a comma-separated list of default analyzers
	DsDefaultAnalyzers string `json:"ds_default_analyzers,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
	// DsImageSuffix is the image suffix (e.g., "-fips")
	DsImageSuffix string `json:"ds_image_suffix,omitempty"`
	// DsAnalyzerImageTag is the image tag for analyzers
	DsAnalyzerImageTag string `json:"ds_analyzer_image_tag,omitempty"`
	// GemnasiumDbRemoteUrl is the URL for the Gemnasium database
	GemnasiumDbRemoteUrl string `json:"gemnasium_db_remote_url,omitempty"`
}

DependencyScanningConfig contains inputs for the Dependency Scanning component. GitLab Dependency Scanning component for detecting vulnerabilities in dependencies.

See: https://docs.gitlab.com/user/application_security/dependency_scanning/

type DockerBuildConfig

type DockerBuildConfig struct {
	// Stage is the pipeline stage (default: build)
	Stage string `json:"stage,omitempty"`
	// DockerImage is the name of the Docker image to build
	DockerImage string `json:"docker_image,omitempty"`
	// Context is the build context directory (default: .)
	Context string `json:"context,omitempty"`
	// Dockerfile is the path to the Dockerfile (default: Dockerfile)
	Dockerfile string `json:"dockerfile,omitempty"`
	// Tags is a comma-separated list of image tags to apply
	Tags string `json:"tags,omitempty"`
}

DockerBuildConfig contains inputs for the Docker Build component. GitLab Docker Build component for building and pushing container images.

See: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

type HelmConfig

type HelmConfig struct {
	// Stage is the pipeline stage (default: deploy)
	Stage string `json:"stage,omitempty"`
	// HelmChart is the path to the Helm chart
	HelmChart string `json:"helm_chart,omitempty"`
	// ReleaseName is the Helm release name
	ReleaseName string `json:"release_name,omitempty"`
	// Namespace is the Kubernetes namespace
	Namespace string `json:"namespace,omitempty"`
	// Values is the path to values file
	Values string `json:"values,omitempty"`
	// HelmVersion is the Helm version to use
	HelmVersion string `json:"helm_version,omitempty"`
}

HelmConfig contains inputs for the Helm deployment component. Helm chart deployment component for deploying Helm charts.

See: https://helm.sh/docs/

type KubernetesConfig

type KubernetesConfig struct {
	// Stage is the pipeline stage (default: deploy)
	Stage string `json:"stage,omitempty"`
	// K8sNamespace is the Kubernetes namespace
	K8sNamespace string `json:"k8s_namespace,omitempty"`
	// K8sManifests is the path to Kubernetes manifests
	K8sManifests string `json:"k8s_manifests,omitempty"`
	// KubeConfig is the kubeconfig content or path
	KubeConfig string `json:"kube_config,omitempty"`
	// K8sContext is the kubectl context to use
	K8sContext string `json:"k8s_context,omitempty"`
}

KubernetesConfig contains inputs for the Kubernetes deployment component. Kubernetes deployment component for deploying to K8s clusters.

See: https://kubernetes.io/docs/home/

type LicenseScanningConfig

type LicenseScanningConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// LicenseFinderCliOpts is additional options for license_finder
	LicenseFinderCliOpts string `json:"license_finder_cli_opts,omitempty"`
	// LicenseManagementSetup is the setup command to run before scanning
	LicenseManagementSetup string `json:"license_management_setup,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
	// LsAnalyzerImageTag is the image tag for the analyzer
	LsAnalyzerImageTag string `json:"ls_analyzer_image_tag,omitempty"`
}

LicenseScanningConfig contains inputs for the License Scanning component. GitLab License Scanning component for detecting licenses in dependencies.

See: https://docs.gitlab.com/user/compliance/license_scanning_of_cyclonedx_files/

type LoadPerformanceConfig

type LoadPerformanceConfig struct {
	// Stage is the pipeline stage (default: performance)
	Stage string `json:"stage,omitempty"`
	// LoadTestUrl is the URL to test
	LoadTestUrl string `json:"load_test_url,omitempty"`
	// Tool is the load testing tool (e.g., k6, locust)
	Tool string `json:"tool,omitempty"`
	// Duration is the test duration
	Duration string `json:"duration,omitempty"`
	// Vus is the number of virtual users
	Vus string `json:"vus,omitempty"`
	// Script is the path to the load test script
	Script string `json:"script,omitempty"`
}

LoadPerformanceConfig contains inputs for the Load Performance testing component. Load performance testing component using tools like k6 or Locust.

See: https://docs.gitlab.com/ee/ci/testing/load_performance_testing.html

type NpmPublishConfig

type NpmPublishConfig struct {
	// Stage is the pipeline stage (default: publish)
	Stage string `json:"stage,omitempty"`
	// NpmRegistry is the npm registry URL
	NpmRegistry string `json:"npm_registry,omitempty"`
	// NpmToken is the npm authentication token
	NpmToken string `json:"npm_token,omitempty"`
	// PackageDir is the directory containing package.json
	PackageDir string `json:"package_dir,omitempty"`
	// Tag is the npm dist-tag for the package
	Tag string `json:"tag,omitempty"`
}

NpmPublishConfig contains inputs for the npm publish component. npm package publishing component for publishing to npm registries.

See: https://docs.npmjs.com/cli/publish

type PagesConfig

type PagesConfig struct {
	// Stage is the pipeline stage (default: deploy)
	Stage string `json:"stage,omitempty"`
	// PublicDir is the directory containing the static site
	PublicDir string `json:"public_dir,omitempty"`
	// CacheKey is the cache key for Pages artifacts
	CacheKey string `json:"cache_key,omitempty"`
}

PagesConfig contains inputs for the GitLab Pages component. GitLab Pages deployment component for hosting static sites.

See: https://docs.gitlab.com/ee/user/project/pages/

type ReleaseConfig

type ReleaseConfig struct {
	// Stage is the pipeline stage (default: release)
	Stage string `json:"stage,omitempty"`
	// TagName is the Git tag for the release
	TagName string `json:"tag_name,omitempty"`
	// Description is the release description/notes
	Description string `json:"description,omitempty"`
	// Assets is a glob pattern for release assets
	Assets string `json:"assets,omitempty"`
	// Ref is the Git ref to create the release from
	Ref string `json:"ref,omitempty"`
}

ReleaseConfig contains inputs for the GitLab Release component. GitLab Release creation component for creating releases.

See: https://docs.gitlab.com/ee/user/project/releases/

type SastConfig

type SastConfig struct {
	// Stage is the pipeline stage for SAST jobs (default: test)
	Stage string `json:"stage,omitempty"`
	// SastExcludedPaths is a comma-separated list of paths to exclude from scanning
	SastExcludedPaths string `json:"sast_excluded_paths,omitempty"`
	// SastExcludedRules is a comma-separated list of rule IDs to exclude
	SastExcludedRules string `json:"sast_excluded_rules,omitempty"`
	// SastExcludedAnalyzers is a comma-separated list of analyzers to skip
	SastExcludedAnalyzers string `json:"sast_excluded_analyzers,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
	// SastAnalyzerImageTag is the image tag for SAST analyzers
	SastAnalyzerImageTag string `json:"sast_analyzer_image_tag,omitempty"`
	// SearchMaxDepth is the maximum search depth for analyzers
	SearchMaxDepth string `json:"search_max_depth,omitempty"`
	// SastImageSuffix is the image suffix for analyzers (e.g., "-fips")
	SastImageSuffix string `json:"sast_image_suffix,omitempty"`
}

SastConfig contains inputs for the SAST component. GitLab Static Application Security Testing (SAST) component.

See: https://docs.gitlab.com/user/application_security/sast/

type SecretDetectionConfig

type SecretDetectionConfig struct {
	// Stage is the pipeline stage (default: test)
	Stage string `json:"stage,omitempty"`
	// SecretDetectionExcludedPaths is a comma-separated list of paths to exclude
	SecretDetectionExcludedPaths string `json:"secret_detection_excluded_paths,omitempty"`
	// SecretDetectionImageSuffix is the image suffix (e.g., "-fips")
	SecretDetectionImageSuffix string `json:"secret_detection_image_suffix,omitempty"`
	// SecureAnalyzersPrefix is the registry path for security analyzers
	SecureAnalyzersPrefix string `json:"secure_analyzers_prefix,omitempty"`
	// SecretDetectionHistoricScan enables scanning of all commits
	SecretDetectionHistoricScan string `json:"secret_detection_historic_scan,omitempty"`
}

SecretDetectionConfig contains inputs for the Secret Detection component. GitLab Secret Detection component for finding secrets in source code.

See: https://docs.gitlab.com/user/application_security/secret_detection/

type TerraformConfig

type TerraformConfig struct {
	// Stage is the pipeline stage (default: deploy)
	Stage string `json:"stage,omitempty"`
	// TerraformImage is the Terraform Docker image to use
	TerraformImage string `json:"terraform_image,omitempty"`
	// TerraformDir is the directory containing Terraform configuration
	TerraformDir string `json:"terraform_dir,omitempty"`
	// PlanFile is the path to save/load the Terraform plan
	PlanFile string `json:"plan_file,omitempty"`
}

TerraformConfig contains inputs for the Terraform component. GitLab Terraform component for infrastructure as code deployments.

See: https://docs.gitlab.com/user/infrastructure/iac/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL