@@ -11,6 +11,7 @@ import (
11
11
12
12
"code.gitea.io/gitea/models/db"
13
13
repo_model "code.gitea.io/gitea/models/repo"
14
+ "code.gitea.io/gitea/models/shared/types"
14
15
user_model "code.gitea.io/gitea/models/user"
15
16
"code.gitea.io/gitea/modules/timeutil"
16
17
"code.gitea.io/gitea/modules/translation"
@@ -28,7 +29,7 @@ type ActionRunner struct {
28
29
Version string `xorm:"VARCHAR(64)"`
29
30
OwnerID int64 `xorm:"index"` // org level runner, 0 means system
30
31
Owner * user_model.User `xorm:"-"`
31
- RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
32
+ RepoID int64 `xorm:"index"` // repo level runner, if OwnerID also is zero, then it's a global
32
33
Repo * repo_model.Repository `xorm:"-"`
33
34
Description string `xorm:"TEXT"`
34
35
Base int // 0 native 1 docker 2 virtual machine
@@ -52,14 +53,25 @@ type ActionRunner struct {
52
53
Deleted timeutil.TimeStamp `xorm:"deleted"`
53
54
}
54
55
55
- func (r * ActionRunner ) OwnType () string {
56
+ // BelongsToOwnerName before calling, should guarantee that all attributes are loaded
57
+ func (r * ActionRunner ) BelongsToOwnerName () string {
56
58
if r .RepoID != 0 {
57
- return fmt . Sprintf ( "Repo(%s)" , r .Repo .FullName () )
59
+ return r .Repo .FullName ()
58
60
}
59
61
if r .OwnerID != 0 {
60
- return fmt . Sprintf ( "Org(%s)" , r .Owner .Name )
62
+ return r .Owner .Name
61
63
}
62
- return "Global"
64
+ return ""
65
+ }
66
+
67
+ func (r * ActionRunner ) BelongsToOwnerType () types.OwnerType {
68
+ if r .RepoID != 0 {
69
+ return types .OwnerTypeRepository
70
+ }
71
+ if r .OwnerID != 0 {
72
+ return types .OwnerTypeOrganization
73
+ }
74
+ return types .OwnerTypeSystemGlobal
63
75
}
64
76
65
77
func (r * ActionRunner ) Status () runnerv1.RunnerStatus {
0 commit comments