File tree Expand file tree Collapse file tree 7 files changed +67
-1
lines changed
buildbot_nix/buildbot_nix Expand file tree Collapse file tree 7 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -1060,6 +1060,8 @@ def nix_eval_config(
1060
1060
submodules = True ,
1061
1061
haltOnFailure = True ,
1062
1062
logEnviron = False ,
1063
+ sshPrivateKey = project .private_key_path .read_text () if project .private_key_path else None ,
1064
+ sshKnownHosts = project .known_hosts_path .read_text () if project .known_hosts_path else None ,
1063
1065
),
1064
1066
)
1065
1067
drv_gcroots_dir = util .Interpolate (
@@ -1417,6 +1419,8 @@ def buildbot_effects_config(
1417
1419
method = "clean" ,
1418
1420
submodules = True ,
1419
1421
haltOnFailure = True ,
1422
+ sshPrivateKey = project .private_key_path .read_text () if project .private_key_path else None ,
1423
+ sshKnownHosts = project .known_hosts_path .read_text () if project .known_hosts_path else None ,
1420
1424
),
1421
1425
)
1422
1426
secrets_list = []
Original file line number Diff line number Diff line change @@ -61,7 +61,10 @@ def __init__(
61
61
62
62
def get_project_url (self ) -> str :
63
63
url = urlparse (self .config .instance_url )
64
- return f"{ url .scheme } ://git:%(secret:{ self .config .token_file } )s@{ url .hostname } /{ self .name } "
64
+ if self .config .ssh_private_key_file :
65
+ return self .data .ssh_url
66
+ else :
67
+ return f"{ url .scheme } ://git:%(secret:{ self .config .token_file } )s@{ url .hostname } /{ self .name } "
65
68
66
69
def create_change_source (self ) -> ChangeSource | None :
67
70
return None
@@ -113,6 +116,15 @@ def belongs_to_org(self) -> bool:
113
116
# TODO Gitea doesn't include this information
114
117
return False # self.data["owner"]["type"] == "Organization"
115
118
119
+ @property
120
+ def private_key_path (self ) -> Path | None :
121
+ return self .config .ssh_private_key_file
122
+
123
+ @property
124
+ def known_hosts_path (self ) -> Path | None :
125
+ return self .config .ssh_known_hosts_file
126
+
127
+
116
128
117
129
class GiteaBackend (GitBackend ):
118
130
config : GiteaConfig
Original file line number Diff line number Diff line change @@ -770,6 +770,14 @@ def topics(self) -> list[str]:
770
770
def belongs_to_org (self ) -> bool :
771
771
return self .data .owner .ttype == "Organization"
772
772
773
+ @property
774
+ def private_key_path (self ) -> Path | None :
775
+ return None
776
+
777
+ @property
778
+ def known_hosts_path (self ) -> Path | None :
779
+ return None
780
+
773
781
774
782
def refresh_projects (
775
783
github_token : str ,
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ class GiteaConfig(BaseModel):
67
67
oauth_id : str | None
68
68
oauth_secret_file : Path | None
69
69
70
+ ssh_private_key_file : Path | None
71
+ ssh_known_hosts_file : Path | None
72
+
70
73
@property
71
74
def token (self ) -> str :
72
75
return read_secret_file (self .token_file )
Original file line number Diff line number Diff line change 1
1
from abc import ABC , abstractmethod
2
2
from typing import Any
3
+ from pathlib import Path
3
4
4
5
from buildbot .changes .base import ChangeSource
5
6
from buildbot .config .builder import BuilderConfig
@@ -125,3 +126,13 @@ def topics(self) -> list[str]:
125
126
@abstractmethod
126
127
def belongs_to_org (self ) -> bool :
127
128
pass
129
+
130
+ @property
131
+ @abstractmethod
132
+ def private_key_path (self ) -> Path | None :
133
+ pass
134
+
135
+ @property
136
+ @abstractmethod
137
+ def known_hosts_path (self ) -> Path | None :
138
+ pass
Original file line number Diff line number Diff line change 1
1
from typing import Any
2
2
from urllib .parse import ParseResult , urlparse
3
+ from pathlib import Path
3
4
4
5
from buildbot .changes .base import ChangeSource
5
6
from buildbot .changes .gitpoller import GitPoller
@@ -99,3 +100,11 @@ def topics(self) -> list[str]:
99
100
@property
100
101
def belongs_to_org (self ) -> bool :
101
102
return False
103
+
104
+ @property
105
+ def private_key_path (self ) -> Path | None :
106
+ return None
107
+
108
+ @property
109
+ def known_hosts_path (self ) -> Path | None :
110
+ return None
Original file line number Diff line number Diff line change 313
313
If null, all projects that the buildbot Gitea user has access to, are built.
314
314
'' ;
315
315
} ;
316
+
317
+ sshPrivateKeyFile = lib . mkOption {
318
+ type = lib . types . nullOr lib . types . path ;
319
+ default = null ;
320
+ description = ''
321
+ If non-null the specified SSH key will be used to fetch all configured repositories.
322
+ '' ;
323
+ } ;
324
+
325
+ sshKnownHostsFile = lib . mkOption {
326
+ type = lib . types . nullOr lib . types . path ;
327
+ default = null ;
328
+ description = ''
329
+ If non-null the specified known hosts file will be matched against when connecting to
330
+ repositories over SSH.
331
+ '' ;
332
+ } ;
316
333
} ;
317
334
github = {
318
335
enable = lib . mkEnableOption "Enable GitHub integration" // {
702
719
instance_url = cfg . gitea . instanceUrl ;
703
720
oauth_id = cfg . gitea . oauthId ;
704
721
topic = cfg . gitea . topic ;
722
+ ssh_private_key_file = cfg . gitea . sshPrivateKeyFile ;
723
+ ssh_known_hosts_file = cfg . gitea . sshKnownHostsFile ;
705
724
} ;
706
725
github =
707
726
if ! cfg . github . enable then
You can’t perform that action at this time.
0 commit comments