Skip to content

Commit

Permalink
feat: Reconcileは動くようになった goTemplateのExecuteに問題あり
Browse files Browse the repository at this point in the history
  • Loading branch information
unchama committed Sep 16, 2023
1 parent 1267ad4 commit 6e0118c
Show file tree
Hide file tree
Showing 22 changed files with 356 additions and 295 deletions.
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resources:
controller: true
domain: seichi.click
group: seichiclick
kind: DynamicBungeeCordConfigration
kind: BungeeConfigTemplate
path: github.com/GiganticMinecraft/seichi-gateway-operator/api/v1alpha1
version: v1alpha1
version: "3"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ kubebuilder create api --group seichiclick --version v1alpha1 --kind SeichiRevie
imagePullPolicy: IfNotPresent -> config/crd/manager/manager.yml

```sh
kubebuilder create api --group seichiclick --version v1alpha1 --kind DynamicBungeeCordConfigration --controller --resource
kubebuilder create api --group seichiclick --version v1alpha1 --kind BungeeConfigTemplate --controller --resource
```
68 changes: 68 additions & 0 deletions api/v1alpha1/bungeeconfigtemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2023.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// BungeeConfigTemplateSpec defines the desired state of BungeeConfigTemplate
type BungeeConfigTemplateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// BungeeCordのconfig.yamlを含むConfigMapマニフェスト。go-templateで記載されている
BungeeConfigTemplate string `json:"goTemplate"`
}

// BungeeConfigTemplateStatus defines the observed state of BungeeConfigTemplate
// +kubebuilder:validation:Enum=NotReady;Available;Healthy
type BungeeConfigTemplateStatus string

const (
MarkdownViewApplying = BungeeConfigTemplateStatus("Applying")
MarkdownViewApplied = BungeeConfigTemplateStatus("Applied")
MarkdownViewError = BungeeConfigTemplateStatus("Error")
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// BungeeConfigTemplate is the Schema for the BungeeConfigTemplates API
type BungeeConfigTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BungeeConfigTemplateSpec `json:"spec,omitempty"`
Status BungeeConfigTemplateStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// BungeeConfigTemplateList contains a list of BungeeConfigTemplate
type BungeeConfigTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []BungeeConfigTemplate `json:"items"`
}

func init() {
SchemeBuilder.Register(&BungeeConfigTemplate{}, &BungeeConfigTemplateList{})
}
77 changes: 0 additions & 77 deletions api/v1alpha1/dynamicbungeecordconfigration_types.go

This file was deleted.

2 changes: 1 addition & 1 deletion api/v1alpha1/seichireviewgateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SeichiReviewGatewaySpec struct {
// Important: Run "make" to regenerate code after modifying this file

// 稼働環境を生成する時にどのプルリクエスト番号時点のリポジトリデータを参照するかの設定
PullRequestNo int `json:"pull-request-no"`
PullRequestNo int `json:"pullRequestNo"`
}

// SeichiReviewGatewayStatus defines the observed state of SeichiReviewGateway
Expand Down
38 changes: 19 additions & 19 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "SeichiReviewGateway")
os.Exit(1)
}
if err = (&controller.DynamicBungeeCordConfigrationReconciler{
if err = (&controller.BungeeConfigTemplateReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DynamicBungeeCordConfigration")
setupLog.Error(err, "unable to create controller", "controller", "BungeeConfigTemplate")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: dynamicbungeecordconfigrations.seichiclick.seichi.click
name: bungeeconfigtemplates.seichiclick.seichi.click
spec:
group: seichiclick.seichi.click
names:
kind: DynamicBungeeCordConfigration
listKind: DynamicBungeeCordConfigrationList
plural: dynamicbungeecordconfigrations
singular: dynamicbungeecordconfigration
kind: BungeeConfigTemplate
listKind: BungeeConfigTemplateList
plural: bungeeconfigtemplates
singular: bungeeconfigtemplate
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: DynamicBungeeCordConfigration is the Schema for the dynamicbungeecordconfigrations
description: BungeeConfigTemplate is the Schema for the BungeeConfigTemplates
API
properties:
apiVersion:
Expand All @@ -33,30 +33,17 @@ spec:
metadata:
type: object
spec:
description: DynamicBungeeCordConfigrationSpec defines the desired state
of DynamicBungeeCordConfigration
description: BungeeConfigTemplateSpec defines the desired state of BungeeConfigTemplate
properties:
bungeeConfigTemplate:
description: Foo is an example field of DynamicBungeeCordConfigration.
Edit dynamicbungeecordconfigration_types.go to remove/update BungeeCordの設定のテンプレート
type: string
targetToApplyConfigmapKey:
type: string
targetToApplyConfigmapName:
type: string
targetToApplyNamespace:
description: 'apply先のconfigmapの情報 具体的には: - namespace.metadata.name
- configmap.metadata.name - configmap.data.??? <-どこか'
goTemplate:
description: BungeeCordのconfig.yamlを含むConfigMapマニフェスト。go-templateで記載されている
type: string
required:
- bungeeConfigTemplate
- targetToApplyConfigmapKey
- targetToApplyConfigmapName
- targetToApplyNamespace
- goTemplate
type: object
status:
description: DynamicBungeeCordConfigrationStatus defines the observed
state of DynamicBungeeCordConfigration
description: BungeeConfigTemplateStatus defines the observed state of
BungeeConfigTemplate
enum:
- NotReady
- Available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ spec:
spec:
description: SeichiReviewGatewaySpec defines the desired state of SeichiReviewGateway
properties:
pull-request-no:
pullRequestNo:
description: 稼働環境を生成する時にどのプルリクエスト番号時点のリポジトリデータを参照するかの設定
type: integer
required:
- pull-request-no
- pullRequestNo
type: object
status:
description: SeichiReviewGatewayStatus defines the observed state of SeichiReviewGateway
Expand Down
6 changes: 3 additions & 3 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# It should be run by config/default
resources:
- bases/seichiclick.seichi.click_seichireviewgateways.yaml
- bases/seichiclick.seichi.click_dynamicbungeecordconfigrations.yaml
- bases/seichiclick.seichi.click_BungeeConfigTemplates.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- path: patches/webhook_in_seichireviewgateways.yaml
#- path: patches/webhook_in_dynamicbungeecordconfigrations.yaml
#- path: patches/webhook_in_BungeeConfigTemplates.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- path: patches/cainjection_in_seichireviewgateways.yaml
#- path: patches/cainjection_in_dynamicbungeecordconfigrations.yaml
#- path: patches/cainjection_in_BungeeConfigTemplates.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
Loading

0 comments on commit 6e0118c

Please sign in to comment.