Skip to content

Commit 1098d3c

Browse files
authored
Added Git Service (#3)
* Added Git Service Signed-off-by: Lucifergene <[email protected]>
1 parent 54685bb commit 1098d3c

27 files changed

+1114
-169
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ go.work
3131
go.work.sum
3232

3333
# Output directory for tests
34-
_output/
34+
_output/
35+
36+
# Binary for packages
37+
pkg/**/output
38+
39+
# Environment variables file
40+
.env

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ issues:
1212
- path: "api/*"
1313
linters:
1414
- lll
15-
- path: "internal/*"
15+
- path: "controller/*"
1616
linters:
1717
- dupl
1818
- lll

Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.1
6+
VERSION ?= 0.0.4
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -159,11 +159,11 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
159159

160160
.PHONY: build
161161
build: manifests generate fmt vet ## Build manager binary.
162-
go build -o bin/manager cmd/main.go
162+
go build -o bin/manager main.go
163163

164164
.PHONY: run
165165
run: manifests generate fmt vet ## Run a controller from your host.
166-
go run ./cmd/main.go
166+
go run main.go
167167

168168
.PHONY: container-build
169169
container-build: test ko ## Build the container image with the operator.
@@ -216,9 +216,8 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
216216
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
217217

218218
.PHONY: deploy
219-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
220-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
221-
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
219+
deploy: manifests kustomize ko ## Deploy controller to the K8s cluster specified in ~/.kube/config. This will also build and push the operator image.
220+
$(KUSTOMIZE) build config/default | KO_DOCKER_REPO=${IMAGE_REPO} $(KO) apply ${KO_OPTS} -f -
222221

223222
.PHONY: undeploy
224223
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.

api/v1alpha1/common_types.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package v1alpha1
2+
3+
type (
4+
// ConditionType defines what condition type this is.
5+
ConditionType string
6+
7+
// ConditionReason is a static/programmatic representation of the cause of a status condition.
8+
ConditionReason string
9+
)
10+
11+
const (
12+
13+
// ConditionProgressing is True when the operator is progressing
14+
ConditionProgressing ConditionType = "Progressing"
15+
16+
// ConditionReady is True when the application is ready
17+
ConditionReady ConditionType = "Ready"
18+
19+
// ConditionGitRepoReachable is True if the Git repository is reachable
20+
ConditionGitRepoReachable ConditionType = "GitRepoReachable"
21+
22+
// ConditionOperatorDegraded is True if the operator is in a degraded state
23+
ConditionOperatorDegraded ConditionType = "OperatorDegraded"
24+
25+
// ConditionResourceNotFound is True if the resource is not found
26+
ConditionResourceNotFound ConditionType = "ResourceNotFound"
27+
28+
// ReasonOperatorResourceNotAvailable indicates the operator resource is not available
29+
ReasonOperatorResourceNotAvailable ConditionReason = "OperatorResourceNotAvailable"
30+
31+
// ReasonSecretResourceNotFound indicates the secret resource is not found
32+
ReasonSecretResourceNotFound ConditionReason = "SecretResourceNotFound"
33+
34+
// ReasonInit indicates the resource is initializing
35+
ReasonInit ConditionReason = "Init"
36+
37+
// ReasonAllResourcesReady indicates all resources are ready
38+
ReasonAllResourcesReady ConditionReason = "AllResourcesReady"
39+
40+
// ReasonReconcileFailed indicates the reconciliation failed
41+
ReasonReconcileFailed ConditionReason = "ReconcileFailed"
42+
43+
// ReasonReconcileCompleted indicates the reconciliation completed
44+
ReasonReconcileCompleted ConditionReason = "ReconcileCompleted"
45+
)
46+
47+
// String casts the value to string.
48+
// "c.String()" and "string(c)" are equivalent.
49+
func (c ConditionType) String() string {
50+
return string(c)
51+
}
52+
53+
// String casts the value to string.
54+
// "r.String()" and "string(r)" are equivalent.
55+
func (r ConditionReason) String() string {
56+
return string(r)
57+
}

api/v1alpha1/consoleapplication_types.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,58 @@ import (
2323
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26+
type Git struct {
27+
Url string `json:"url,omitempty"`
28+
ContextDir string `json:"contextDir,omitempty"`
29+
Reference string `json:"reference,omitempty"`
30+
SourceSecretRef string `json:"sourceSecretRef,omitempty"`
31+
}
32+
33+
type BuildConfiguration struct {
34+
BuilderImage BuilderImage `json:"builderImage,omitempty"`
35+
BuildOption string `json:"buildOption,omitempty"`
36+
Env []Env `json:"env,omitempty"`
37+
}
38+
39+
type BuilderImage struct {
40+
Name string `json:"name,omitempty"`
41+
Image string `json:"image,omitempty"`
42+
}
43+
44+
type Env struct {
45+
Name string `json:"name,omitempty"`
46+
Value string `json:"value,omitempty"`
47+
}
48+
49+
type Expose struct {
50+
TargetPort *int32 `json:"targetPort,omitempty"`
51+
CreateRoute bool `json:"createRoute,omitempty"`
52+
}
53+
54+
type DeploymentConfiguration struct {
55+
ResourceType string `json:"resourceType,omitempty"`
56+
Env []Env `json:"env,omitempty"`
57+
Expose Expose `json:"expose,omitempty"`
58+
}
59+
2660
// ConsoleApplicationSpec defines the desired state of ConsoleApplication
2761
type ConsoleApplicationSpec struct {
2862
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2963
// Important: Run "make" to regenerate code after modifying this file
3064

3165
// Foo is an example field of ConsoleApplication. Edit consoleapplication_types.go to remove/update
32-
Foo string `json:"foo,omitempty"`
66+
ApplicationName string `json:"applicationName,omitempty"`
67+
Git Git `json:"git,omitempty"`
68+
ImportStrategy string `json:"importStrategy,omitempty"`
69+
BuildConfiguration BuildConfiguration `json:"buildConfiguration,omitempty"`
70+
DeploymentConfiguration DeploymentConfiguration `json:"deploymentConfiguration,omitempty"`
3371
}
3472

3573
// ConsoleApplicationStatus defines the observed state of ConsoleApplication
3674
type ConsoleApplicationStatus struct {
3775
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
3876
// Important: Run "make" to regenerate code after modifying this file
77+
Conditions []metav1.Condition `json:"conditions,omitempty"`
3978
}
4079

4180
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 120 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)