Files
ziti/common/pb/edge_cmd_pb/impl.go
T
Andrew Martinez 8c0bf8b885 fixes 1691 multiple er re-enrolls creates multiple enrollments
- ers do not support having multiple enrollments, detail returns 1
- re-enrolling now clears existing enrollments
- adds test to re-enroll twice
- encapsulates all er re-enrollment logic as a single atomic command
2024-01-25 15:09:30 -05:00

91 lines
1.9 KiB
Go

package edge_cmd_pb
func (x *CreateEdgeTerminatorCommand) GetCommandType() int32 {
return int32(CommandType_CreateEdgeTerminatorType)
}
func (x *ReplaceEnrollmentWithAuthenticatorCmd) GetCommandType() int32 {
return int32(CommandType_ReplaceEnrollmentWithAuthenticatorType)
}
func (x *CreateEdgeRouterCmd) GetCommandType() int32 {
return int32(CommandType_CreateEdgeRouterType)
}
func (x *CreateTransitRouterCmd) GetCommandType() int32 {
return int32(CommandType_CreateTransitRouterType)
}
func (x *CreateIdentityWithEnrollmentsCmd) GetCommandType() int32 {
return int32(CommandType_CreateIdentityWithEnrollmentsType)
}
func (x *ReEnrollEdgeRouterCmd) GetCommandType() int32 {
return int32(CommandType_ReEnrollEdgeRouterType)
}
func (x *UpdateServiceConfigsCmd) GetCommandType() int32 {
return int32(CommandType_UpdateServiceConfigsType)
}
func EncodeTags(tags map[string]interface{}) (map[string]*TagValue, error) {
if len(tags) == 0 {
return nil, nil
}
result := map[string]*TagValue{}
for k, v := range tags {
if v == nil {
result[k] = &TagValue{
Value: &TagValue_NilValue{
NilValue: true,
},
}
} else {
switch val := v.(type) {
case string:
result[k] = &TagValue{
Value: &TagValue_StringValue{
StringValue: val,
},
}
case bool:
result[k] = &TagValue{
Value: &TagValue_BoolValue{
BoolValue: val,
},
}
case float64:
result[k] = &TagValue{
Value: &TagValue_FpValue{
FpValue: val,
},
}
}
}
}
return result, nil
}
func DecodeTags(tags map[string]*TagValue) map[string]interface{} {
if len(tags) == 0 {
return nil
}
result := map[string]interface{}{}
for k, v := range tags {
switch v.Value.(type) {
case *TagValue_NilValue:
result[k] = nil
case *TagValue_BoolValue:
result[k] = v.GetBoolValue()
case *TagValue_StringValue:
result[k] = v.GetStringValue()
case *TagValue_FpValue:
result[k] = v.GetFpValue()
}
}
return result
}