Skip to content

Commit

Permalink
Tenant variables (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star authored Nov 15, 2024
1 parent c6fae07 commit 88e7a83
Show file tree
Hide file tree
Showing 46 changed files with 2,061 additions and 44 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,13 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: oceanbase.com
group: oceanbase
kind: OBTenantVariable
path: github.com/oceanbase/ob-operator/api/v1alpha1
version: v1alpha1
version: "3"
18 changes: 18 additions & 0 deletions api/types/variable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright (c) 2023 OceanBase
ob-operator is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/

package types

type Variable struct {
Name string `json:"name"`
Value string `json:"value"`
}
2 changes: 2 additions & 0 deletions api/v1alpha1/obtenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type OBTenantSpec struct {
Credentials TenantCredentials `json:"credentials,omitempty"`
Scenario string `json:"scenario,omitempty"`
Parameters []apitypes.Parameter `json:"parameters,omitempty"`
Variables []apitypes.Variable `json:"variables,omitempty"`
}

type TenantCredentials struct {
Expand Down Expand Up @@ -106,6 +107,7 @@ type OBTenantStatus struct {
Source *TenantSourceStatus `json:"source,omitempty"`
Credentials TenantCredentials `json:"credentials,omitempty"`
Parameters []apitypes.Parameter `json:"parameters,omitempty"`
Variables []apitypes.Variable `json:"variables,omitempty"`
}

type TenantSourceStatus struct {
Expand Down
76 changes: 76 additions & 0 deletions api/v1alpha1/obtenantvariable_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
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"

apitypes "github.com/oceanbase/ob-operator/api/types"
tasktypes "github.com/oceanbase/ob-operator/pkg/task/types"
)

// 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.

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

// Foo is an example field of OBTenantVariable. Edit obtenantvariable_types.go to remove/update
OBTenant string `json:"obtenant"`
Variable *apitypes.Variable `json:"variable"`
}

// OBTenantVariableStatus defines the observed state of OBTenantVariable.
type OBTenantVariableStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
OperationContext *tasktypes.OperationContext `json:"operationContext,omitempty"`
Status string `json:"status"`
Variable apitypes.Variable `json:"variable"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Tenant",type="string",JSONPath=".spec.obtenant"
//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
//+kubebuilder:printcolumn:name="Key",type="string",JSONPath=".spec.variable.name"
//+kubebuilder:printcolumn:name="WantedValue",type="string",JSONPath=".spec.variable.value"

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

Spec OBTenantVariableSpec `json:"spec,omitempty"`
Status OBTenantVariableStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&OBTenantVariable{}, &OBTenantVariableList{})
}
104 changes: 104 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 88e7a83

Please sign in to comment.