Skip to content

Commit 85fde7e

Browse files
authored
[feat] add gitea (#395)
1 parent c34a40a commit 85fde7e

File tree

9 files changed

+1107
-7
lines changed

9 files changed

+1107
-7
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Current Operator version
2-
VERSION ?= v0.5.5
2+
VERSION ?= v0.5.6
33
REGISTRY ?= tmaxcloudck
44

55
# Image URL to use all building/pushing image targets
@@ -162,4 +162,4 @@ compare-sha-mod:
162162
$(eval MODSHA_AFTER=$(shell sha512sum go.mod))
163163
$(eval SUMSHA_AFTER=$(shell sha512sum go.sum))
164164
@if [ "${MODSHA_AFTER}" = "${MODSHA}" ]; then echo "go.mod is not changed"; else echo "go.mod file is changed"; exit 1; fi
165-
@if [ "${SUMSHA_AFTER}" = "${SUMSHA}" ]; then echo "go.sum is not changed"; else echo "go.sum file is changed"; exit 1; fi
165+
@if [ "${SUMSHA_AFTER}" = "${SUMSHA}" ]; then echo "go.sum is not changed"; else echo "go.sum file is changed"; exit 1; fi

api/v1/git_types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ const (
3131

3232
GitlabDefaultAPIUrl = "https://gitlab.com"
3333
GitlabDefaultHost = "https://gitlab.com"
34+
35+
GiteaDefaultAPIUrl = "https://gitea.com"
36+
GiteaDefaultHost = "https://gitea.com/"
3437
)
3538

3639
// GitConfig is a git repository where the IntegrationConfig to be configured
3740
type GitConfig struct {
3841
// Type for git remote server
39-
// +kubebuilder:validation:Enum=github;gitlab
42+
// +kubebuilder:validation:Enum=github;gitlab;gitea
4043
Type GitType `json:"type"`
4144

4245
// Repository name of git repository (in <org>/<repo> form, e.g., tmax-cloud/cicd-operator)
@@ -60,6 +63,8 @@ func (config *GitConfig) GetGitHost() (string, error) {
6063
gitURL = GithubDefaultHost
6164
} else if gitURL == GitlabDefaultAPIUrl {
6265
gitURL = GitlabDefaultHost
66+
} else if gitURL == GiteaDefaultAPIUrl {
67+
gitURL = GiteaDefaultHost
6368
}
6469
gitU, err := url.Parse(gitURL)
6570
if err != nil {
@@ -75,6 +80,8 @@ func (config *GitConfig) GetAPIUrl() string {
7580
return GithubDefaultAPIUrl
7681
} else if config.Type == GitTypeGitLab && config.APIUrl == "" {
7782
return GitlabDefaultAPIUrl
83+
} else if config.Type == GitTypeGitea && config.APIUrl == "" {
84+
return GiteaDefaultAPIUrl
7885
}
7986
return config.APIUrl
8087
}
@@ -100,6 +107,7 @@ type GitType string
100107
const (
101108
GitTypeGitHub = GitType("github")
102109
GitTypeGitLab = GitType("gitlab")
110+
GitTypeGitea = GitType("gitea")
103111
GitTypeFake = GitType("fake")
104112
)
105113

config/crd/cicd.tmax.io_integrationconfigs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ spec:
104104
enum:
105105
- github
106106
- gitlab
107+
- gitea
107108
type: string
108109
required:
109110
- repository

config/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ spec:
8484
containers:
8585
- command:
8686
- /controller
87-
image: docker.io/tmaxcloudck/cicd-operator:v0.5.5
87+
image: docker.io/tmaxcloudck/cicd-operator:v0.5.6
8888
imagePullPolicy: Always
8989
name: manager
9090
env:
@@ -171,7 +171,7 @@ spec:
171171
containers:
172172
- command:
173173
- /blocker
174-
image: docker.io/tmaxcloudck/cicd-blocker:v0.5.5
174+
image: docker.io/tmaxcloudck/cicd-blocker:v0.5.6
175175
imagePullPolicy: Always
176176
name: manager
177177
resources:
@@ -231,7 +231,7 @@ spec:
231231
containers:
232232
- command:
233233
- /webhook
234-
image: docker.io/tmaxcloudck/cicd-webhook:v0.5.5
234+
image: docker.io/tmaxcloudck/cicd-webhook:v0.5.6
235235
imagePullPolicy: Always
236236
name: manager
237237
resources:
@@ -291,7 +291,7 @@ spec:
291291
containers:
292292
- command:
293293
- /apiserver
294-
image: docker.io/tmaxcloudck/cicd-api-server:v0.5.5
294+
image: docker.io/tmaxcloudck/cicd-api-server:v0.5.6
295295
imagePullPolicy: Always
296296
name: manager
297297
resources:

internal/utils/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package utils
1818

1919
import (
2020
"fmt"
21+
"github.com/tmax-cloud/cicd-operator/pkg/git/gitea"
2122
"regexp"
2223
"strings"
2324

@@ -40,6 +41,8 @@ func GetGitCli(cfg *cicdv1.IntegrationConfig, cli client.Client) (git.Client, er
4041
c = &gitlab.Client{IntegrationConfig: cfg, K8sClient: cli}
4142
case cicdv1.GitTypeFake:
4243
c = &fake.Client{IntegrationConfig: cfg, K8sClient: cli}
44+
case cicdv1.GitTypeGitea:
45+
c = &gitea.Client{IntegrationConfig: cfg, K8sClient: cli}
4346
default:
4447
return nil, fmt.Errorf("git type %s is not supported", cfg.Spec.Git.Type)
4548
}

0 commit comments

Comments
 (0)