Skip to content

Commit

Permalink
[feat] add gitea (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
S-hayeon authored Nov 11, 2022
1 parent c34a40a commit 85fde7e
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Current Operator version
VERSION ?= v0.5.5
VERSION ?= v0.5.6
REGISTRY ?= tmaxcloudck

# Image URL to use all building/pushing image targets
Expand Down Expand Up @@ -162,4 +162,4 @@ compare-sha-mod:
$(eval MODSHA_AFTER=$(shell sha512sum go.mod))
$(eval SUMSHA_AFTER=$(shell sha512sum go.sum))
@if [ "${MODSHA_AFTER}" = "${MODSHA}" ]; then echo "go.mod is not changed"; else echo "go.mod file is changed"; exit 1; fi
@if [ "${SUMSHA_AFTER}" = "${SUMSHA}" ]; then echo "go.sum is not changed"; else echo "go.sum file is changed"; exit 1; fi
@if [ "${SUMSHA_AFTER}" = "${SUMSHA}" ]; then echo "go.sum is not changed"; else echo "go.sum file is changed"; exit 1; fi
10 changes: 9 additions & 1 deletion api/v1/git_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ const (

GitlabDefaultAPIUrl = "https://gitlab.com"
GitlabDefaultHost = "https://gitlab.com"

GiteaDefaultAPIUrl = "https://gitea.com"
GiteaDefaultHost = "https://gitea.com/"
)

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

// Repository name of git repository (in <org>/<repo> form, e.g., tmax-cloud/cicd-operator)
Expand All @@ -60,6 +63,8 @@ func (config *GitConfig) GetGitHost() (string, error) {
gitURL = GithubDefaultHost
} else if gitURL == GitlabDefaultAPIUrl {
gitURL = GitlabDefaultHost
} else if gitURL == GiteaDefaultAPIUrl {
gitURL = GiteaDefaultHost
}
gitU, err := url.Parse(gitURL)
if err != nil {
Expand All @@ -75,6 +80,8 @@ func (config *GitConfig) GetAPIUrl() string {
return GithubDefaultAPIUrl
} else if config.Type == GitTypeGitLab && config.APIUrl == "" {
return GitlabDefaultAPIUrl
} else if config.Type == GitTypeGitea && config.APIUrl == "" {
return GiteaDefaultAPIUrl
}
return config.APIUrl
}
Expand All @@ -100,6 +107,7 @@ type GitType string
const (
GitTypeGitHub = GitType("github")
GitTypeGitLab = GitType("gitlab")
GitTypeGitea = GitType("gitea")
GitTypeFake = GitType("fake")
)

Expand Down
1 change: 1 addition & 0 deletions config/crd/cicd.tmax.io_integrationconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ spec:
enum:
- github
- gitlab
- gitea
type: string
required:
- repository
Expand Down
8 changes: 4 additions & 4 deletions config/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spec:
containers:
- command:
- /controller
image: docker.io/tmaxcloudck/cicd-operator:v0.5.5
image: docker.io/tmaxcloudck/cicd-operator:v0.5.6
imagePullPolicy: Always
name: manager
env:
Expand Down Expand Up @@ -171,7 +171,7 @@ spec:
containers:
- command:
- /blocker
image: docker.io/tmaxcloudck/cicd-blocker:v0.5.5
image: docker.io/tmaxcloudck/cicd-blocker:v0.5.6
imagePullPolicy: Always
name: manager
resources:
Expand Down Expand Up @@ -231,7 +231,7 @@ spec:
containers:
- command:
- /webhook
image: docker.io/tmaxcloudck/cicd-webhook:v0.5.5
image: docker.io/tmaxcloudck/cicd-webhook:v0.5.6
imagePullPolicy: Always
name: manager
resources:
Expand Down Expand Up @@ -291,7 +291,7 @@ spec:
containers:
- command:
- /apiserver
image: docker.io/tmaxcloudck/cicd-api-server:v0.5.5
image: docker.io/tmaxcloudck/cicd-api-server:v0.5.6
imagePullPolicy: Always
name: manager
resources:
Expand Down
3 changes: 3 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package utils

import (
"fmt"
"github.com/tmax-cloud/cicd-operator/pkg/git/gitea"
"regexp"
"strings"

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

0 comments on commit 85fde7e

Please sign in to comment.