mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2025-12-17 04:14:28 -06:00
small conversion fix
This commit is contained in:
@@ -33,7 +33,7 @@ type TraefikInstance struct {
|
||||
Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Password string `protobuf:"bytes,6,opt,name=password,proto3" json:"password,omitempty"`
|
||||
Tls bool `protobuf:"varint,7,opt,name=tls,proto3" json:"tls,omitempty"`
|
||||
EntryPoints *structpb.Struct `protobuf:"bytes,8,opt,name=entry_points,json=entryPoints,proto3" json:"entry_points,omitempty"`
|
||||
EntryPoints *structpb.ListValue `protobuf:"bytes,8,opt,name=entry_points,json=entryPoints,proto3" json:"entry_points,omitempty"`
|
||||
Overview *structpb.Struct `protobuf:"bytes,9,opt,name=overview,proto3" json:"overview,omitempty"`
|
||||
Config *structpb.Struct `protobuf:"bytes,10,opt,name=config,proto3" json:"config,omitempty"`
|
||||
Version *structpb.Struct `protobuf:"bytes,11,opt,name=version,proto3" json:"version,omitempty"`
|
||||
@@ -122,7 +122,7 @@ func (x *TraefikInstance) GetTls() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *TraefikInstance) GetEntryPoints() *structpb.Struct {
|
||||
func (x *TraefikInstance) GetEntryPoints() *structpb.ListValue {
|
||||
if x != nil {
|
||||
return x.EntryPoints
|
||||
}
|
||||
@@ -449,7 +449,7 @@ var File_mantrae_v1_traefik_instance_proto protoreflect.FileDescriptor
|
||||
const file_mantrae_v1_traefik_instance_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"!mantrae/v1/traefik_instance.proto\x12\n" +
|
||||
"mantrae.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xfb\x03\n" +
|
||||
"mantrae.v1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xfe\x03\n" +
|
||||
"\x0fTraefikInstance\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1d\n" +
|
||||
"\n" +
|
||||
@@ -458,8 +458,8 @@ const file_mantrae_v1_traefik_instance_proto_rawDesc = "" +
|
||||
"\x03url\x18\x04 \x01(\tR\x03url\x12\x1a\n" +
|
||||
"\busername\x18\x05 \x01(\tR\busername\x12\x1a\n" +
|
||||
"\bpassword\x18\x06 \x01(\tR\bpassword\x12\x10\n" +
|
||||
"\x03tls\x18\a \x01(\bR\x03tls\x12:\n" +
|
||||
"\fentry_points\x18\b \x01(\v2\x17.google.protobuf.StructR\ventryPoints\x123\n" +
|
||||
"\x03tls\x18\a \x01(\bR\x03tls\x12=\n" +
|
||||
"\fentry_points\x18\b \x01(\v2\x1a.google.protobuf.ListValueR\ventryPoints\x123\n" +
|
||||
"\boverview\x18\t \x01(\v2\x17.google.protobuf.StructR\boverview\x12/\n" +
|
||||
"\x06config\x18\n" +
|
||||
" \x01(\v2\x17.google.protobuf.StructR\x06config\x121\n" +
|
||||
@@ -516,16 +516,17 @@ var file_mantrae_v1_traefik_instance_proto_goTypes = []any{
|
||||
(*DeleteTraefikInstanceResponse)(nil), // 4: mantrae.v1.DeleteTraefikInstanceResponse
|
||||
(*ListTraefikInstancesRequest)(nil), // 5: mantrae.v1.ListTraefikInstancesRequest
|
||||
(*ListTraefikInstancesResponse)(nil), // 6: mantrae.v1.ListTraefikInstancesResponse
|
||||
(*structpb.Struct)(nil), // 7: google.protobuf.Struct
|
||||
(*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp
|
||||
(*structpb.ListValue)(nil), // 7: google.protobuf.ListValue
|
||||
(*structpb.Struct)(nil), // 8: google.protobuf.Struct
|
||||
(*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp
|
||||
}
|
||||
var file_mantrae_v1_traefik_instance_proto_depIdxs = []int32{
|
||||
7, // 0: mantrae.v1.TraefikInstance.entry_points:type_name -> google.protobuf.Struct
|
||||
7, // 1: mantrae.v1.TraefikInstance.overview:type_name -> google.protobuf.Struct
|
||||
7, // 2: mantrae.v1.TraefikInstance.config:type_name -> google.protobuf.Struct
|
||||
7, // 3: mantrae.v1.TraefikInstance.version:type_name -> google.protobuf.Struct
|
||||
8, // 4: mantrae.v1.TraefikInstance.created_at:type_name -> google.protobuf.Timestamp
|
||||
8, // 5: mantrae.v1.TraefikInstance.updated_at:type_name -> google.protobuf.Timestamp
|
||||
7, // 0: mantrae.v1.TraefikInstance.entry_points:type_name -> google.protobuf.ListValue
|
||||
8, // 1: mantrae.v1.TraefikInstance.overview:type_name -> google.protobuf.Struct
|
||||
8, // 2: mantrae.v1.TraefikInstance.config:type_name -> google.protobuf.Struct
|
||||
8, // 3: mantrae.v1.TraefikInstance.version:type_name -> google.protobuf.Struct
|
||||
9, // 4: mantrae.v1.TraefikInstance.created_at:type_name -> google.protobuf.Timestamp
|
||||
9, // 5: mantrae.v1.TraefikInstance.updated_at:type_name -> google.protobuf.Timestamp
|
||||
0, // 6: mantrae.v1.GetTraefikInstanceResponse.traefik_instance:type_name -> mantrae.v1.TraefikInstance
|
||||
0, // 7: mantrae.v1.ListTraefikInstancesResponse.traefik_instances:type_name -> mantrae.v1.TraefikInstance
|
||||
1, // 8: mantrae.v1.TraefikInstanceService.GetTraefikInstance:input_type -> mantrae.v1.GetTraefikInstanceRequest
|
||||
|
||||
@@ -2283,7 +2283,7 @@ components:
|
||||
title: tls
|
||||
entryPoints:
|
||||
title: entry_points
|
||||
$ref: '#/components/schemas/google.protobuf.Struct'
|
||||
$ref: '#/components/schemas/google.protobuf.ListValue'
|
||||
overview:
|
||||
title: overview
|
||||
$ref: '#/components/schemas/google.protobuf.Struct'
|
||||
|
||||
@@ -24,7 +24,7 @@ message TraefikInstance {
|
||||
string username = 5;
|
||||
string password = 6;
|
||||
bool tls = 7;
|
||||
google.protobuf.Struct entry_points = 8;
|
||||
google.protobuf.ListValue entry_points = 8;
|
||||
google.protobuf.Struct overview = 9;
|
||||
google.protobuf.Struct config = 10;
|
||||
google.protobuf.Struct version = 11;
|
||||
|
||||
@@ -249,7 +249,7 @@ func (t *TraefikInstance) ToProto() *mantraev1.TraefikInstance {
|
||||
Name: t.Name,
|
||||
Url: t.Url,
|
||||
Tls: t.Tls,
|
||||
EntryPoints: MustMarshalStruct(t.Entrypoints),
|
||||
EntryPoints: MustMarshalSlice[schema.EntryPoint](*t.Entrypoints),
|
||||
Overview: MustMarshalStruct(t.Overview),
|
||||
Config: MustMarshalStruct(t.Config),
|
||||
Version: MustMarshalStruct(t.Version),
|
||||
@@ -355,6 +355,8 @@ func TimePtr(t time.Time) *time.Time {
|
||||
return &t
|
||||
}
|
||||
|
||||
// JSON Objects marshalling and unmarshalling helper --------------------------
|
||||
|
||||
func UnmarshalStruct[T any](s *structpb.Struct) (*T, error) {
|
||||
// Marshal the proto Struct to JSON bytes
|
||||
data, err := s.MarshalJSON()
|
||||
@@ -414,3 +416,35 @@ func MustUnmarshalStruct[T any](s *structpb.Struct) *T {
|
||||
}
|
||||
return &out
|
||||
}
|
||||
|
||||
// Slices marshalling and unmarshalling helper --------------------------------
|
||||
|
||||
func MustMarshalSlice[T any](s []T) *structpb.ListValue {
|
||||
data, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
slog.Error("failed to marshal slice", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var lv structpb.ListValue
|
||||
if err := lv.UnmarshalJSON(data); err != nil {
|
||||
slog.Error("failed to unmarshal to ListValue", "error", err)
|
||||
return nil
|
||||
}
|
||||
return &lv
|
||||
}
|
||||
|
||||
func MustUnmarshalSlice[T any](lv *structpb.ListValue) []T {
|
||||
data, err := lv.MarshalJSON()
|
||||
if err != nil {
|
||||
slog.Error("failed to marshal ListValue", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var out []T
|
||||
if err := json.Unmarshal(data, &out); err != nil {
|
||||
slog.Error("failed to unmarshal slice", "error", err)
|
||||
return nil
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
||||
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
||||
import { file_buf_validate_validate } from "../../buf/validate/validate_pb";
|
||||
import type { Timestamp } from "@bufbuild/protobuf/wkt";
|
||||
import type { ListValue, Timestamp } from "@bufbuild/protobuf/wkt";
|
||||
import { file_google_protobuf_struct, file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
|
||||
import type { JsonObject, Message } from "@bufbuild/protobuf";
|
||||
|
||||
@@ -13,7 +13,7 @@ import type { JsonObject, Message } from "@bufbuild/protobuf";
|
||||
* Describes the file mantrae/v1/traefik_instance.proto.
|
||||
*/
|
||||
export const file_mantrae_v1_traefik_instance: GenFile = /*@__PURE__*/
|
||||
fileDesc("CiFtYW50cmFlL3YxL3RyYWVmaWtfaW5zdGFuY2UucHJvdG8SCm1hbnRyYWUudjEiigMKD1RyYWVmaWtJbnN0YW5jZRIKCgJpZBgBIAEoCRISCgpwcm9maWxlX2lkGAIgASgDEgwKBG5hbWUYAyABKAkSCwoDdXJsGAQgASgJEhAKCHVzZXJuYW1lGAUgASgJEhAKCHBhc3N3b3JkGAYgASgJEgsKA3RscxgHIAEoCBItCgxlbnRyeV9wb2ludHMYCCABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EikKCG92ZXJ2aWV3GAkgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBInCgZjb25maWcYCiABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EigKB3ZlcnNpb24YCyABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0Ei4KCmNyZWF0ZWRfYXQYDCABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEi4KCnVwZGF0ZWRfYXQYDSABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wIjAKGUdldFRyYWVmaWtJbnN0YW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TGlzdFRyYWVmaWtJbnN0YW5jZXNSZXF1ZXN0GigubWFudHJhZS52MS5MaXN0VHJhZWZpa0luc3RhbmNlc1Jlc3BvbnNlIgOQAgFCrgEKDmNvbS5tYW50cmFlLnYxQhRUcmFlZmlrSW5zdGFuY2VQcm90b1ABWj1naXRodWIuY29tL21penVjaGlsYWJzL21hbnRyYWUvcHJvdG8vZ2VuL21hbnRyYWUvdjE7bWFudHJhZXYxogIDTVhYqgIKTWFudHJhZS5WMcoCCk1hbnRyYWVcVjHiAhZNYW50cmFlXFYxXEdQQk1ldGFkYXRh6gILTWFudHJhZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_protobuf_struct, file_google_protobuf_timestamp]);
|
||||
fileDesc("CiFtYW50cmFlL3YxL3RyYWVmaWtfaW5zdGFuY2UucHJvdG8SCm1hbnRyYWUudjEijQMKD1RyYWVmaWtJbnN0YW5jZRIKCgJpZBgBIAEoCRISCgpwcm9maWxlX2lkGAIgASgDEgwKBG5hbWUYAyABKAkSCwoDdXJsGAQgASgJEhAKCHVzZXJuYW1lGAUgASgJEhAKCHBhc3N3b3JkGAYgASgJEgsKA3RscxgHIAEoCBIwCgxlbnRyeV9wb2ludHMYCCABKAsyGi5nb29nbGUucHJvdG9idWYuTGlzdFZhbHVlEikKCG92ZXJ2aWV3GAkgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBInCgZjb25maWcYCiABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EigKB3ZlcnNpb24YCyABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0Ei4KCmNyZWF0ZWRfYXQYDCABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEi4KCnVwZGF0ZWRfYXQYDSABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wIjAKGUdldFRyYWVmaWtJbnN0YW5jZVJlcXVlc3QSEwoCaWQYASABKAlCB7pIBHICEAEiUwoaR2V0VHJhZWZpa0luc3Rhb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Zpa0luc3RhbmNlc1Jlc3BvbnNlIgOQAgFCrgEKDmNvbS5tYW50cmFlLnYxQhRUcmFlZmlrSW5zdGFuY2VQcm90b1ABWj1naXRodWIuY29tL21penVjaGlsYWJzL21hbnRyYWUvcHJvdG8vZ2VuL21hbnRyYWUvdjE7bWFudHJhZXYxogIDTVhYqgIKTWFudHJhZS5WMcoCCk1hbnRyYWVcVjHiAhZNYW50cmFlXFYxXEdQQk1ldGFkYXRh6gILTWFudHJhZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_protobuf_struct, file_google_protobuf_timestamp]);
|
||||
|
||||
/**
|
||||
* @generated from message mantrae.v1.TraefikInstance
|
||||
@@ -55,9 +55,9 @@ export type TraefikInstance = Message<"mantrae.v1.TraefikInstance"> & {
|
||||
tls: boolean;
|
||||
|
||||
/**
|
||||
* @generated from field: google.protobuf.Struct entry_points = 8;
|
||||
* @generated from field: google.protobuf.ListValue entry_points = 8;
|
||||
*/
|
||||
entryPoints?: JsonObject;
|
||||
entryPoints?: ListValue;
|
||||
|
||||
/**
|
||||
* @generated from field: google.protobuf.Struct overview = 9;
|
||||
|
||||
Reference in New Issue
Block a user