config(server): add token field to Forge
This commit is contained in:
parent
aaaa975911
commit
a1484939ab
2 changed files with 11 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
||||||
forge_type = "ForgeJo"
|
forge_type = "ForgeJo"
|
||||||
hostname = "git.example.net"
|
hostname = "git.example.net"
|
||||||
user = "git-next" # the user to perform actions as
|
user = "git-next" # the user to perform actions as
|
||||||
# API token for user?
|
token = "API-Token"
|
||||||
# path to private SSH key for user?
|
# path to private SSH key for user?
|
||||||
|
|
||||||
[forge.default.repos]
|
[forge.default.repos]
|
||||||
|
|
|
@ -47,6 +47,7 @@ pub struct Forge {
|
||||||
forge_type: ForgeType,
|
forge_type: ForgeType,
|
||||||
hostname: String,
|
hostname: String,
|
||||||
user: String,
|
user: String,
|
||||||
|
token: String,
|
||||||
// API Token
|
// API Token
|
||||||
// Private SSH Key Path
|
// Private SSH Key Path
|
||||||
repos: HashMap<String, Repo>,
|
repos: HashMap<String, Repo>,
|
||||||
|
@ -64,6 +65,10 @@ impl Forge {
|
||||||
User(self.user.clone())
|
User(self.user.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn token(&self) -> ApiToken {
|
||||||
|
ApiToken(self.token.clone())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn repos(&self) -> impl Iterator<Item = (RepoName, &Repo)> {
|
pub fn repos(&self) -> impl Iterator<Item = (RepoName, &Repo)> {
|
||||||
self.repos
|
self.repos
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -132,6 +137,7 @@ pub struct ForgeDetails {
|
||||||
pub forge_type: ForgeType,
|
pub forge_type: ForgeType,
|
||||||
pub hostname: Hostname,
|
pub hostname: Hostname,
|
||||||
pub user: User,
|
pub user: User,
|
||||||
|
pub token: ApiToken,
|
||||||
// API Token
|
// API Token
|
||||||
// Private SSH Key Path
|
// Private SSH Key Path
|
||||||
}
|
}
|
||||||
|
@ -142,6 +148,7 @@ impl From<(&ForgeName, &Forge)> for ForgeDetails {
|
||||||
forge_type: forge.1.forge_type.clone(),
|
forge_type: forge.1.forge_type.clone(),
|
||||||
hostname: forge.1.hostname(),
|
hostname: forge.1.hostname(),
|
||||||
user: forge.1.user(),
|
user: forge.1.user(),
|
||||||
|
token: forge.1.token(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,6 +191,7 @@ impl RepoDetails {
|
||||||
forge_type: forge.forge_type.clone(),
|
forge_type: forge.forge_type.clone(),
|
||||||
hostname: forge.hostname(),
|
hostname: forge.hostname(),
|
||||||
user: forge.user(),
|
user: forge.user(),
|
||||||
|
token: forge.token(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,6 +243,7 @@ mod tests {
|
||||||
forge_type = "ForgeJo"
|
forge_type = "ForgeJo"
|
||||||
hostname = "git.example.net"
|
hostname = "git.example.net"
|
||||||
user = "Bob"
|
user = "Bob"
|
||||||
|
token = "API-Token"
|
||||||
|
|
||||||
[forge.default.repos]
|
[forge.default.repos]
|
||||||
hello = { repo = "user/hello", branch = "main" }
|
hello = { repo = "user/hello", branch = "main" }
|
||||||
|
@ -250,6 +259,7 @@ mod tests {
|
||||||
forge_type: ForgeType::ForgeJo,
|
forge_type: ForgeType::ForgeJo,
|
||||||
hostname: "git.example.net".to_string(),
|
hostname: "git.example.net".to_string(),
|
||||||
user: "Bob".to_string(),
|
user: "Bob".to_string(),
|
||||||
|
token: "API-Token".to_string(),
|
||||||
repos: HashMap::from([
|
repos: HashMap::from([
|
||||||
(
|
(
|
||||||
"hello".to_string(),
|
"hello".to_string(),
|
||||||
|
|
Loading…
Reference in a new issue