This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 6622c5ad [operator] Supplementing helm logic and organizing project
logic
6622c5ad is described below
commit 6622c5adfe04cdc86a27da339e2f1db87ee1eb9e
Author: mfordjody <[email protected]>
AuthorDate: Fri Dec 13 18:38:42 2024 +0800
[operator] Supplementing helm logic and organizing project logic
---
operator/cmd/validation/validation.go | 1 +
operator/pkg/apis/{gvk.go => register.go} | 0
operator/pkg/apis/types.go | 8 +-
operator/pkg/apis/value_types_json.go | 88 ------
operator/pkg/apis/values_types.pb.go | 486 ------------------------------
operator/pkg/helm/helm.go | 99 +++++-
operator/pkg/helm/path.go | 11 +
7 files changed, 103 insertions(+), 590 deletions(-)
diff --git a/operator/cmd/validation/validation.go
b/operator/cmd/validation/validation.go
index f0d30cf4..e9d9848a 100644
--- a/operator/cmd/validation/validation.go
+++ b/operator/cmd/validation/validation.go
@@ -3,6 +3,7 @@ package validation
import (
"bytes"
"encoding/json"
+ "fmt"
"github.com/apache/dubbo-kubernetes/operator/pkg/apis"
"github.com/apache/dubbo-kubernetes/operator/pkg/util"
"github.com/apache/dubbo-kubernetes/operator/pkg/values"
diff --git a/operator/pkg/apis/gvk.go b/operator/pkg/apis/register.go
similarity index 100%
rename from operator/pkg/apis/gvk.go
rename to operator/pkg/apis/register.go
diff --git a/operator/pkg/apis/types.go b/operator/pkg/apis/types.go
index bee0963e..ee72de17 100644
--- a/operator/pkg/apis/types.go
+++ b/operator/pkg/apis/types.go
@@ -36,12 +36,12 @@ type DubboOperator struct {
type DubboOperatorSpec struct {
Profile string `json:"profile,omitempty"`
Namespace string `json:"namespace,omitempty"`
- Revision string `json:"revision,omitempty"`
- Components *DubboCompSpec `json:"components,omitempty"`
- Values json.RawMessage `json:"values,omitempty"`
+ Revision string `json:"revision,omitempty"`
+ Components *DubboComponentSpec `json:"components,omitempty"`
+ Values json.RawMessage `json:"values,omitempty"`
}
-type DubboCompSpec struct {
+type DubboComponentSpec struct {
Base *BaseComponentSpec `json:"base,omitempty"`
}
diff --git a/operator/pkg/apis/value_types_json.go
b/operator/pkg/apis/value_types_json.go
deleted file mode 100644
index 2adb1763..00000000
--- a/operator/pkg/apis/value_types_json.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright Istio Authors
-//
-// 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.
-
-// Configuration affecting Istio control plane installation version and shape.
-
-package apis
-
-import (
- "bytes"
- "encoding/json"
-
- github_com_golang_protobuf_jsonpb "github.com/golang/protobuf/jsonpb"
// nolint: depguard
- "google.golang.org/protobuf/types/known/wrapperspb"
- "k8s.io/apimachinery/pkg/util/intstr"
-)
-
-// nolint
-var _ github_com_golang_protobuf_jsonpb.JSONPBUnmarshaler = &IntOrString{}
-
-func (i *IntOrString) UnmarshalJSON(value []byte) error {
- if value[0] == '"' {
- i.Type = int64(intstr.String)
- var s string
- err := json.Unmarshal(value, &s)
- if err != nil {
- return err
- }
- i.StrVal = &wrapperspb.StringValue{Value: s}
- return nil
- }
- i.Type = int64(intstr.Int)
- var s int32
- err := json.Unmarshal(value, &s)
- if err != nil {
- return err
- }
- i.IntVal = &wrapperspb.Int32Value{Value: s}
- return nil
-}
-
-func (i *IntOrString) MarshalJSONPB(_
*github_com_golang_protobuf_jsonpb.Marshaler) ([]byte, error) {
- return i.MarshalJSON()
-}
-
-func (i *IntOrString) MarshalJSON() ([]byte, error) {
- if i.IntVal != nil {
- return json.Marshal(i.IntVal.GetValue())
- }
- return json.Marshal(i.StrVal.GetValue())
-}
-
-func (i *IntOrString) UnmarshalJSONPB(_
*github_com_golang_protobuf_jsonpb.Unmarshaler, value []byte) error {
- return i.UnmarshalJSON(value)
-}
-
-func (i *IntOrString) ToKubernetes() intstr.IntOrString {
- if i.IntVal != nil {
- return intstr.FromInt32(i.GetIntVal().GetValue())
- }
- return intstr.FromString(i.GetStrVal().GetValue())
-}
-
-// MarshalJSON is a custom marshaler for Values
-func (in *Values) MarshalJSON() ([]byte, error) {
- str, err := OperatorMarshaler.MarshalToString(in)
- return []byte(str), err
-}
-
-// UnmarshalJSON is a custom unmarshaler for Values
-func (in *Values) UnmarshalJSON(b []byte) error {
- return OperatorUnmarshaler.Unmarshal(bytes.NewReader(b), in)
-}
-
-var (
- OperatorMarshaler = &github_com_golang_protobuf_jsonpb.Marshaler{}
- OperatorUnmarshaler = &github_com_golang_protobuf_jsonpb.Unmarshaler{}
-)
diff --git a/operator/pkg/apis/values_types.pb.go
b/operator/pkg/apis/values_types.pb.go
deleted file mode 100644
index 75dd972d..00000000
--- a/operator/pkg/apis/values_types.pb.go
+++ /dev/null
@@ -1,486 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.31.0
-// protoc v5.28.3
-// source: values_types.proto
-
-package apis
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- _ "google.golang.org/protobuf/types/known/anypb"
- _ "google.golang.org/protobuf/types/known/durationpb"
- _ "google.golang.org/protobuf/types/known/structpb"
- wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
- reflect "reflect"
- sync "sync"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type ArchConfig struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Amd64 uint32 `protobuf:"varint,1,opt,name=amd64,proto3"
json:"amd64,omitempty"`
- Ppc64Le uint32 `protobuf:"varint,2,opt,name=ppc64le,proto3"
json:"ppc64le,omitempty"`
- S390X uint32 `protobuf:"varint,3,opt,name=s390x,proto3"
json:"s390x,omitempty"`
- Arm64 uint32 `protobuf:"varint,4,opt,name=arm64,proto3"
json:"arm64,omitempty"`
-}
-
-func (x *ArchConfig) Reset() {
- *x = ArchConfig{}
- if protoimpl.UnsafeEnabled {
- mi := &file_values_types_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *ArchConfig) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ArchConfig) ProtoMessage() {}
-
-func (x *ArchConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[0]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ArchConfig.ProtoReflect.Descriptor instead.
-func (*ArchConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *ArchConfig) GetAmd64() uint32 {
- if x != nil {
- return x.Amd64
- }
- return 0
-}
-
-func (x *ArchConfig) GetPpc64Le() uint32 {
- if x != nil {
- return x.Ppc64Le
- }
- return 0
-}
-
-func (x *ArchConfig) GetS390X() uint32 {
- if x != nil {
- return x.S390X
- }
- return 0
-}
-
-func (x *ArchConfig) GetArm64() uint32 {
- if x != nil {
- return x.Arm64
- }
- return 0
-}
-
-type GlobalConfig struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- // Deprecated: Marked as deprecated in values_types.proto.
- Arch *ArchConfig `protobuf:"bytes,1,opt,name=arch,proto3"
json:"arch,omitempty"`
- DubboNamespace string
`protobuf:"bytes,2,opt,name=dubboNamespace,proto3"
json:"dubboNamespace,omitempty"`
-}
-
-func (x *GlobalConfig) Reset() {
- *x = GlobalConfig{}
- if protoimpl.UnsafeEnabled {
- mi := &file_values_types_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *GlobalConfig) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*GlobalConfig) ProtoMessage() {}
-
-func (x *GlobalConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[1]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use GlobalConfig.ProtoReflect.Descriptor instead.
-func (*GlobalConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{1}
-}
-
-// Deprecated: Marked as deprecated in values_types.proto.
-func (x *GlobalConfig) GetArch() *ArchConfig {
- if x != nil {
- return x.Arch
- }
- return nil
-}
-
-func (x *GlobalConfig) GetDubboNamespace() string {
- if x != nil {
- return x.DubboNamespace
- }
- return ""
-}
-
-type BaseConfig struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- EnableDubboConfigCRDs *wrapperspb.BoolValue
`protobuf:"bytes,1,opt,name=enableDubboConfigCRDs,proto3"
json:"enableDubboConfigCRDs,omitempty"`
-}
-
-func (x *BaseConfig) Reset() {
- *x = BaseConfig{}
- if protoimpl.UnsafeEnabled {
- mi := &file_values_types_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *BaseConfig) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*BaseConfig) ProtoMessage() {}
-
-func (x *BaseConfig) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[2]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use BaseConfig.ProtoReflect.Descriptor instead.
-func (*BaseConfig) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *BaseConfig) GetEnableDubboConfigCRDs() *wrapperspb.BoolValue {
- if x != nil {
- return x.EnableDubboConfigCRDs
- }
- return nil
-}
-
-type Values struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Global *GlobalConfig `protobuf:"bytes,1,opt,name=global,proto3"
json:"global,omitempty"`
-}
-
-func (x *Values) Reset() {
- *x = Values{}
- if protoimpl.UnsafeEnabled {
- mi := &file_values_types_proto_msgTypes[3]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Values) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Values) ProtoMessage() {}
-
-func (x *Values) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[3]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Values.ProtoReflect.Descriptor instead.
-func (*Values) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *Values) GetGlobal() *GlobalConfig {
- if x != nil {
- return x.Global
- }
- return nil
-}
-
-// +protobuf=true
-// +protobuf.options.(gogoproto.goproto_stringer)=false
-// +k8s:openapi-gen=true
-type IntOrString struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Type int64
`protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"`
- IntVal *wrapperspb.Int32Value
`protobuf:"bytes,2,opt,name=intVal,proto3" json:"intVal,omitempty"`
- StrVal *wrapperspb.StringValue
`protobuf:"bytes,3,opt,name=strVal,proto3" json:"strVal,omitempty"`
-}
-
-func (x *IntOrString) Reset() {
- *x = IntOrString{}
- if protoimpl.UnsafeEnabled {
- mi := &file_values_types_proto_msgTypes[4]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *IntOrString) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*IntOrString) ProtoMessage() {}
-
-func (x *IntOrString) ProtoReflect() protoreflect.Message {
- mi := &file_values_types_proto_msgTypes[4]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use IntOrString.ProtoReflect.Descriptor instead.
-func (*IntOrString) Descriptor() ([]byte, []int) {
- return file_values_types_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *IntOrString) GetType() int64 {
- if x != nil {
- return x.Type
- }
- return 0
-}
-
-func (x *IntOrString) GetIntVal() *wrapperspb.Int32Value {
- if x != nil {
- return x.IntVal
- }
- return nil
-}
-
-func (x *IntOrString) GetStrVal() *wrapperspb.StringValue {
- if x != nil {
- return x.StrVal
- }
- return nil
-}
-
-var File_values_types_proto protoreflect.FileDescriptor
-
-var file_values_types_proto_rawDesc = []byte{
- 0x0a, 0x12, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x73, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e,
0x6f, 0x70, 0x65, 0x72,
- 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
0x31, 0x1a, 0x19, 0x67,
- 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2f, 0x61,
- 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65,
- 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75,
0x72, 0x61, 0x74, 0x69,
- 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65,
- 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74,
0x72, 0x75, 0x63, 0x74,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70,
0x70, 0x65, 0x72, 0x73,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x68, 0x0a, 0x0a, 0x41, 0x72,
0x63, 0x68, 0x43, 0x6f,
- 0x6e, 0x66, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6d, 0x64, 0x36,
0x34, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x6d, 0x64, 0x36, 0x34, 0x12, 0x18,
0x0a, 0x07, 0x70, 0x70,
- 0x63, 0x36, 0x34, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x07, 0x70, 0x70, 0x63,
- 0x36, 0x34, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x33, 0x39, 0x30,
0x78, 0x18, 0x03, 0x20,
- 0x01, 0x28, 0x0d, 0x52, 0x05, 0x73, 0x33, 0x39, 0x30, 0x78, 0x12, 0x14,
0x0a, 0x05, 0x61, 0x72,
- 0x6d, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61,
0x72, 0x6d, 0x36, 0x34,
- 0x22, 0x73, 0x0a, 0x0c, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67,
- 0x12, 0x3b, 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x23,
- 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x72, 0x61,
0x74, 0x6f, 0x72, 0x2e,
- 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x72, 0x63,
0x68, 0x43, 0x6f, 0x6e,
- 0x66, 0x69, 0x67, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x61, 0x72, 0x63,
0x68, 0x12, 0x26, 0x0a,
- 0x0e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70,
0x61, 0x63, 0x65, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x75, 0x62, 0x62, 0x6f,
0x4e, 0x61, 0x6d, 0x65,
- 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x5e, 0x0a, 0x0a, 0x42, 0x61, 0x73,
0x65, 0x43, 0x6f, 0x6e,
- 0x66, 0x69, 0x67, 0x12, 0x50, 0x0a, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x44, 0x75, 0x62,
- 0x62, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x43, 0x52, 0x44, 0x73,
0x18, 0x01, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c,
0x75, 0x65, 0x52, 0x15,
- 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x44, 0x75, 0x62, 0x62, 0x6f, 0x43,
0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x43, 0x52, 0x44, 0x73, 0x22, 0x47, 0x0a, 0x06, 0x56, 0x61, 0x6c,
0x75, 0x65, 0x73, 0x12,
- 0x3d, 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32,
- 0x25, 0x2e, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x6f, 0x72,
- 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6c,
0x6f, 0x62, 0x61, 0x6c,
- 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x06, 0x67, 0x6c, 0x6f, 0x62,
0x61, 0x6c, 0x22, 0x8c,
- 0x01, 0x0a, 0x0b, 0x49, 0x6e, 0x74, 0x4f, 0x72, 0x53, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x12, 0x12,
- 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x04, 0x74, 0x79,
- 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c,
0x18, 0x02, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61,
0x6c, 0x75, 0x65, 0x52,
- 0x06, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x12, 0x34, 0x0a, 0x06, 0x73,
0x74, 0x72, 0x56, 0x61,
- 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74,
0x72, 0x69, 0x6e, 0x67,
- 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x73, 0x74, 0x72, 0x56, 0x61,
0x6c, 0x42, 0x04, 0x5a,
- 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
- file_values_types_proto_rawDescOnce sync.Once
- file_values_types_proto_rawDescData = file_values_types_proto_rawDesc
-)
-
-func file_values_types_proto_rawDescGZIP() []byte {
- file_values_types_proto_rawDescOnce.Do(func() {
- file_values_types_proto_rawDescData =
protoimpl.X.CompressGZIP(file_values_types_proto_rawDescData)
- })
- return file_values_types_proto_rawDescData
-}
-
-var file_values_types_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
-var file_values_types_proto_goTypes = []interface{}{
- (*ArchConfig)(nil), // 0: dubbo.operator.v1alpha1.ArchConfig
- (*GlobalConfig)(nil), // 1:
dubbo.operator.v1alpha1.GlobalConfig
- (*BaseConfig)(nil), // 2: dubbo.operator.v1alpha1.BaseConfig
- (*Values)(nil), // 3: dubbo.operator.v1alpha1.Values
- (*IntOrString)(nil), // 4:
dubbo.operator.v1alpha1.IntOrString
- (*wrapperspb.BoolValue)(nil), // 5: google.protobuf.BoolValue
- (*wrapperspb.Int32Value)(nil), // 6: google.protobuf.Int32Value
- (*wrapperspb.StringValue)(nil), // 7: google.protobuf.StringValue
-}
-var file_values_types_proto_depIdxs = []int32{
- 0, // 0: dubbo.operator.v1alpha1.GlobalConfig.arch:type_name ->
dubbo.operator.v1alpha1.ArchConfig
- 5, // 1:
dubbo.operator.v1alpha1.BaseConfig.enableDubboConfigCRDs:type_name ->
google.protobuf.BoolValue
- 1, // 2: dubbo.operator.v1alpha1.Values.global:type_name ->
dubbo.operator.v1alpha1.GlobalConfig
- 6, // 3: dubbo.operator.v1alpha1.IntOrString.intVal:type_name ->
google.protobuf.Int32Value
- 7, // 4: dubbo.operator.v1alpha1.IntOrString.strVal:type_name ->
google.protobuf.StringValue
- 5, // [5:5] is the sub-list for method output_type
- 5, // [5:5] is the sub-list for method input_type
- 5, // [5:5] is the sub-list for extension type_name
- 5, // [5:5] is the sub-list for extension extendee
- 0, // [0:5] is the sub-list for field type_name
-}
-
-func init() { file_values_types_proto_init() }
-func file_values_types_proto_init() {
- if File_values_types_proto != nil {
- return
- }
- if !protoimpl.UnsafeEnabled {
- file_values_types_proto_msgTypes[0].Exporter = func(v
interface{}, i int) interface{} {
- switch v := v.(*ArchConfig); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_values_types_proto_msgTypes[1].Exporter = func(v
interface{}, i int) interface{} {
- switch v := v.(*GlobalConfig); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_values_types_proto_msgTypes[2].Exporter = func(v
interface{}, i int) interface{} {
- switch v := v.(*BaseConfig); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_values_types_proto_msgTypes[3].Exporter = func(v
interface{}, i int) interface{} {
- switch v := v.(*Values); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_values_types_proto_msgTypes[4].Exporter = func(v
interface{}, i int) interface{} {
- switch v := v.(*IntOrString); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- }
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_values_types_proto_rawDesc,
- NumEnums: 0,
- NumMessages: 5,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_values_types_proto_goTypes,
- DependencyIndexes: file_values_types_proto_depIdxs,
- MessageInfos: file_values_types_proto_msgTypes,
- }.Build()
- File_values_types_proto = out.File
- file_values_types_proto_rawDesc = nil
- file_values_types_proto_goTypes = nil
- file_values_types_proto_depIdxs = nil
-}
diff --git a/operator/pkg/helm/helm.go b/operator/pkg/helm/helm.go
index 0f9a725d..f488c609 100644
--- a/operator/pkg/helm/helm.go
+++ b/operator/pkg/helm/helm.go
@@ -1,10 +1,19 @@
package helm
import (
+ "fmt"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/manifest"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/util"
"github.com/apache/dubbo-kubernetes/operator/pkg/values"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/yml"
+ "github.com/apache/dubbo-kubernetes/pkg/util/slices"
"helm.sh/helm/v3/pkg/chart"
+ "helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/engine"
+ "io/fs"
+ "os"
+ "path/filepath"
"sort"
"strings"
)
@@ -13,22 +22,29 @@ const (
// NotesFileNameSuffix is the file name suffix for helm notes.
// see https://helm.sh/docs/chart_template_guide/notes_files/
NotesFileNameSuffix = ".txt"
+ BaseChartName = "base"
)
-func readerChart(namespace string, chrt *chart.Chart) ([]string, error) {
- var s []string
+type Warnings = util.Errors
+
+func readerChart(namespace string, chrtVals values.Map, chrt *chart.Chart)
([]string, Warnings, error) {
opts := chartutil.ReleaseOptions{
Namespace: namespace,
}
caps := *chartutil.DefaultCapabilities
- helmVals, err := chartutil.ToRenderValues(chrt, nil, opts, &caps)
+ helmVals, err := chartutil.ToRenderValues(chrt, chrtVals, opts, &caps)
if err != nil {
- return nil, nil
+ return nil, nil, fmt.Errorf("converting values: %v", err)
}
files, err := engine.Render(chrt, helmVals)
if err != nil {
- return nil, err
+ return nil, nil, err
+ }
+ crdFiles := chrt.CRDObjects()
+ if chrt.Metadata.Name == BaseChartName {
+ values.GetPathHelper[bool](chrtVals,
"base.enableDubboConfigCRD")
}
+ var warnings Warnings
keys := make([]string, 0, len(files))
for k := range files {
if strings.HasPrefix(k, NotesFileNameSuffix) {
@@ -36,16 +52,75 @@ func readerChart(namespace string, chrt *chart.Chart)
([]string, error) {
keys = append(keys, k)
}
sort.Strings(keys)
- chrt.CRDObjects()
- if chrt.Metadata.Name == "base" {
+ res := make([]string, 0, len(keys))
+ for _, k := range keys {
+ res = append(res, yml.SplitString(files[k])...)
+ }
+ slices.SortBy(crdFiles, func(a chart.CRD) string {
+ return a.Name
+ })
+ for _, crd := range crdFiles {
+ res = append(res, yml.SplitString(string(crd.File.Data))...)
}
+ return res, warnings, nil
+}
- return s, nil
+func loadChart(f fs.FS, root string) (*chart.Chart, error) {
+ fnames, err := getFilesRecursive(f, root)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return nil, fmt.Errorf("component does not exist")
+ }
+ return nil, fmt.Errorf("list files: %v", err)
+ }
+ var bfs []*loader.BufferedFile
+ for _, fn := range fnames {
+ b, err := fs.ReadFile(f, fn)
+ if err != nil {
+ return nil, fmt.Errorf("read file:%v", err)
+ }
+ name := strings.ReplaceAll(stripPrefix(fn, root),
string(filepath.Separator), "/")
+ bf := &loader.BufferedFile{
+ Name: name,
+ Data: b,
+ }
+ bfs = append(bfs, bf)
+ }
+ return loader.LoadFile(bfs)
}
-func Reader(namespace string, dir string, dop values.Map) {
- _, ok := dop.GetPathMap("spec.values")
+func stripPrefix(path, prefix string) string {
+ pl := len(strings.Split(prefix, "/"))
+ pv := strings.Split(path, "/")
+ return strings.Join(pv[pl:], "/")
+}
+
+func Reader(namespace string, directory string, dop values.Map)
([]manifest.Manifest, util.Errors, error) {
+ vals, ok := dop.GetPathMap("spec.values")
if !ok {
- return
+ return nil, nil, fmt.Errorf("failed to get values from dop:
%v", ok)
}
-}
\ No newline at end of file
+ path := pathJoin("charts", directory)
+ chrt, err := loadChart(nil, path)
+ output, warnings, err := readerChart(namespace, vals, chrt)
+ if err != nil {
+ return nil, nil, fmt.Errorf("render chart: %v", err)
+ }
+ mfs, err := manifest.Parse(output)
+ return mfs, warnings, nil
+}
+
+func getFilesRecursive(f fs.FS, root string) ([]string, error) {
+ result := []string{}
+ err := fs.WalkDir(f, root, func(path string, d fs.DirEntry, err error)
error {
+ if err != nil {
+ return err
+ }
+ if d.IsDir() {
+ return nil
+ }
+ result = append(result, path)
+ return nil
+ })
+ return result, err
+}
diff --git a/operator/pkg/helm/path.go b/operator/pkg/helm/path.go
new file mode 100644
index 00000000..0bc9df16
--- /dev/null
+++ b/operator/pkg/helm/path.go
@@ -0,0 +1,11 @@
+//go:build !windows
+
+package helm
+
+import (
+ "path/filepath"
+)
+
+func pathJoin(elem ...string) string {
+ return filepath.Join(elem...)
+}