pub struct GitLabConfig {
pub access_token: String,
pub api_url: String,
}Expand description
Configuration for GitLab API integration.
This structure holds the necessary information for connecting to GitLab instances, including both GitLab.com and self-hosted installations.
§Security Notes
- Personal Access Tokens are stored in configuration files
- Tokens should be generated with minimal required scopes (
read_user,read_repository) - Consider using project-specific tokens for enhanced security
- Tokens can be revoked through GitLab’s interface if compromised
§Supported Instances
- GitLab.com: Use
https://gitlab.comas the API URL - Self-hosted: Use your instance URL (e.g.,
https://gitlab.company.com) - GitLab Enterprise: Same as self-hosted with enterprise features
Fields§
§access_token: StringPersonal Access Token for GitLab API authentication.
This token must have the following scopes:
read_user: To fetch user information and user IDread_repository: To access commit data and repository events
Generate tokens at: GitLab → User Settings → Access Tokens
api_url: StringBase URL of the GitLab instance.
Examples:
- GitLab.com:
https://gitlab.com - Self-hosted:
https://gitlab.example.com - Local development:
http://localhost:8080
Do not include the /api/v4 path - it will be added automatically.
Implementations§
Source§impl GitLabConfig
impl GitLabConfig
Sourcepub fn module() -> ConfigModule
pub fn module() -> ConfigModule
Returns the configuration module metadata for GitLab.
Used by the configuration system to identify and manage GitLab-specific settings during interactive setup.
§Returns
A ConfigModule with GitLab identification information.
Sourcepub fn init(config: &Option<GitLabConfig>) -> Result<Self>
pub fn init(config: &Option<GitLabConfig>) -> Result<Self>
Runs an interactive configuration setup for GitLab integration.
Prompts the user for GitLab instance URL and personal access token, using existing configuration values as defaults if available. This method provides a user-friendly way to configure GitLab integration during initial setup or reconfiguration.
§Interactive Prompts
- Personal Access Token: Prompts for GitLab PAT with hidden input
- API URL: Prompts for GitLab instance URL with validation
Both prompts will show existing values as defaults if configuration already exists, making it easy to update only specific values.
§Arguments
config- Existing GitLab configuration to use as defaults (if any)
§Returns
Result<Self>- New GitLab configuration with user input
§Errors
Returns an error if:
- Terminal input/output fails
- User cancels the configuration process
- Input validation fails
§Example
let existing_config = Some(GitLabConfig {
access_token: "glpat-old-token".to_string(),
api_url: "https://gitlab.com".to_string(),
});
let new_config = GitLabConfig::init(&existing_config)?;Trait Implementations§
Source§impl Clone for GitLabConfig
impl Clone for GitLabConfig
Source§fn clone(&self) -> GitLabConfig
fn clone(&self) -> GitLabConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more