Skip to content

Commit

Permalink
chore: rename crd group and name and add release charts workflow (#33)
Browse files Browse the repository at this point in the history
* chore: remove unused permissions from chart

Signed-off-by: Xie Wei <[email protected]>

* chore: rename crd group and name

Signed-off-by: Xie Wei <[email protected]>

* ci: add release charts workflow

Signed-off-by: Xie Wei <[email protected]>

---------

Signed-off-by: Xie Wei <[email protected]>
  • Loading branch information
waynerv authored Dec 6, 2023
1 parent f100095 commit bb73f0e
Show file tree
Hide file tree
Showing 38 changed files with 394 additions and 447 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release_charts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
branches:
- main
tags:
- "v*.*.*"

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion Makefile.kube
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ $(HELMIFY): $(LOCALBIN)
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest

helm: manifests kustomize helmify
$(KUSTOMIZE) build config/default | $(HELMIFY) chart
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir charts/operator
2 changes: 1 addition & 1 deletion api/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const (
ServiceMaintainSuffix = "-mt"
ServiceReadWriteSuffix = "-rw"

labelPrefix = "opengemini-operator.opengemini.org/"
labelPrefix = "opengemini.org/"
LabelCluster = labelPrefix + "cluster"
LabelInstance = labelPrefix + "instance"
LabelInstanceSet = labelPrefix + "instance-set"
Expand Down
6 changes: 3 additions & 3 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1 contains API Schema definitions for the opengemini-operator v1 API group
// Package v1 contains API Schema definitions for the v1 API group
// +kubebuilder:object:generate=true
// +groupName=opengemini-operator.opengemini.org
// +groupName=opengemini.org
package v1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "opengemini-operator.opengemini.org", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: "opengemini.org", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
40 changes: 20 additions & 20 deletions api/v1/geminicluster_types.go → api/v1/opengeminicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
// 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.

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

Expand Down Expand Up @@ -153,8 +153,8 @@ type InstanceSetStatus struct {
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
}

// GeminiClusterStatus defines the observed state of GeminiCluster
type GeminiClusterStatus struct {
// OpenGeminiClusterStatus defines the observed state of OpenGeminiCluster
type OpenGeminiClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand Down Expand Up @@ -187,51 +187,51 @@ type GeminiClusterStatus struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:shortName=ogi
//+kubebuilder:resource:shortName=ogc
//+kubebuilder:subresource:status

// GeminiCluster is the Schema for the geminiclusters API
type GeminiCluster struct {
// OpenGeminiCluster is the Schema for the opengeminiclusters API
type OpenGeminiCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GeminiClusterSpec `json:"spec,omitempty"`
Status GeminiClusterStatus `json:"status,omitempty"`
Spec OpenGeminiClusterSpec `json:"spec,omitempty"`
Status OpenGeminiClusterStatus `json:"status,omitempty"`
}

func (cluster *GeminiCluster) GetServiceMaintainName() string {
func (cluster *OpenGeminiCluster) GetServiceMaintainName() string {
return fmt.Sprintf("%v%v", cluster.Name, ServiceMaintainSuffix)
}

func (cluster *GeminiCluster) GetServiceReadWriteName() string {
func (cluster *OpenGeminiCluster) GetServiceReadWriteName() string {
return fmt.Sprintf("%v%v", cluster.Name, ServiceReadWriteSuffix)
}

func (cluster *GeminiCluster) GetEnableHttpAuth() bool {
func (cluster *OpenGeminiCluster) GetEnableHttpAuth() bool {
if cluster.Spec.EnableHttpAuth != nil {
return *cluster.Spec.EnableHttpAuth
}

return false
}

func (cluster *GeminiCluster) GetEnableAffinity() bool {
func (cluster *OpenGeminiCluster) GetEnableAffinity() bool {
return cluster.Spec.Affinity.EnablePodAntiAffinity
}

func (cluster *GeminiCluster) GetAdminUserSecretName() string {
func (cluster *OpenGeminiCluster) GetAdminUserSecretName() string {
return fmt.Sprintf("%v%v", cluster.Name, AdminUserSecretSuffix)
}

func (cluster *GeminiCluster) SetInheritedMetadata(obj *metav1.ObjectMeta) {
func (cluster *OpenGeminiCluster) SetInheritedMetadata(obj *metav1.ObjectMeta) {
obj.Annotations = utils.MergeLabels(cluster.Spec.Metadata.GetAnnotationsOrNil())
obj.Labels = utils.MergeLabels(cluster.Spec.Metadata.GetLabelsOrNil(),
map[string]string{
LabelCluster: cluster.Name,
})
}

func (cluster *GeminiCluster) IsSqlReady() bool {
func (cluster *OpenGeminiCluster) IsSqlReady() bool {
for _, status := range cluster.Status.InstanceSets {
if status.Name == "sql" {
if status.Replicas != 0 && status.ReadyReplicas == status.Replicas {
Expand All @@ -244,13 +244,13 @@ func (cluster *GeminiCluster) IsSqlReady() bool {

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GeminiCluster{}, &GeminiClusterList{})
SchemeBuilder.Register(&OpenGeminiCluster{}, &OpenGeminiClusterList{})
}
Loading

0 comments on commit bb73f0e

Please sign in to comment.