Skip to content

types module (v1)

API provided in types.py module. This module contains classes for easy interaction. You can also use them as type hints in your code.

Usage in package API

from git_system_follower.develop.api.types import (
   Parameters, System, ExtraParam, ExtraParams, 
   CICDVariable, CICDVariables
)

Note

For backward compatibility, v1 packages can import from the legacy unversioned path (git_system_follower.develop.api.*). The explicit versioned path (git_system_follower.develop.api.v1.*) is equivalent and is preferred for new packages.

Classes description

Parameters class

@dataclass(frozen=True)
class Parameters:
    system: System
    workdir: Path
    extras: ExtraParams
    cicd_variables: CICDVariables
    all_cicd_variables: CICDVariables
    used_template: str
Parameters which git-system-follower passed to package API

Warning

This class is only used to transfer information. Don't create your own instances

Fields

Name Type Description
system System system information
workdir Path from pathlib library current work directory
extras ExtraParams extra parameters which have been passed in git-system-follower
cicd_variables CICDVariables CI/CD variables that were created by previous gear version
all_cicd_variables CICDVariables all CI/CD variables that exist in repository
used_template str last used template. If used_template=None then no template has been used. If template has been deleted, it will be None

The workdir path can be used to maintain file integrity by allowing preemptive cleanup of existing files before new versions are installed. This is critical for scenarios where gear install/updates must guarantee that only the latest files are present in the system.

System class

@dataclass(frozen=True)
class System:
    host_domain: str
System information about instance in which gear installed/uninstalled

Warning

This class is only used to transfer information. Don't create your own instances

Fields

Name Type Description
host_domain str host domain, e.g. your.company.com

ExtraParam class

class ExtraParam(NamedTuple):
    name: str
    value: str
    masked: bool
    expanded: bool
    managed_by: str
Extra parameter information

Fields

Name Type Description
name str extra parameter name
value str extra parameter value
masked bool whether to mask a extra parameter in logs
expanded bool whether variable references are expanded
managed_by str managed by gsf or external like CI token

Default behavior across GitLab versions

expanded is optional. If it is not passed (--extra NAME VALUE MASKED without expanded/no-expanded), git-system-follower checks the GitLab version and uses the same default as the GitLab server for the raw field:

GitLab version Default when expanded is not passed Sent to GitLab
Pre-18.6 expanded raw=false
18.6+ not expanded raw=true

If the GitLab version can't be determined, raw is not sent and the server default is used.

To force the behavior regardless of GitLab version, pass it explicitly:

--extra MY_VAR my_value masked expanded
--extra MY_VAR my_value masked no-expanded

ExtraParams class

ExtraParamName = str
ExtraParams = dict[ExtraParamName, ExtraParam]
Extra parameters which have been passed in git-system-follower as --extra <name> <value> <masked/no-masked> <expanded/no-expanded> Extra external parameters which have been passed in git-system-follower as --extra-external <name> <value> <masked/no-masked> <expanded/no-expanded>

This is dict where key is parameter name, value is ExtraParam

CICDVariable class

class CICDVariable(TypedDict):
    name: str
    value: str
    env: str
    masked: bool
CI/CD variable information

Fields

Name Type Description
name str CI/CD variable name
value str CI/CD variable value
env str GitLab environment (see GitLab Environments documentation)
masked bool whether to mask a CI/CD variable in logs and in GitLab

CICDVariables class

CICDVariableName = str
CICDVariables = dict[CICDVariableName, CICDVariable]
CI/CD variables information

This is dict where key is CI/CD variable name, value is CICDVariable