Skip to content

Commit

Permalink
Improve schema Vclusters -> VClusters parse list parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
strokyl committed Aug 5, 2024
1 parent 2e0e38b commit 11ba908
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 89 deletions.
2 changes: 1 addition & 1 deletion schema/console-default-schema.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Application":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application","Name":"Application","ParentPathParam":[],"Order":8}}},"ApplicationGroup":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-group","Name":"ApplicationGroup","ParentPathParam":[],"Order":11}}},"ApplicationInstance":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-instance","Name":"ApplicationInstance","ParentPathParam":[],"Order":9}}},"ApplicationInstancePermission":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-instance-permission","Name":"ApplicationInstancePermission","ParentPathParam":[],"Order":10}}},"Group":{"Versions":{"2":{"ListPath":"/public/iam/v2/group","Name":"Group","ParentPathParam":[],"Order":1}}},"KafkaCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/kafka-cluster","Name":"KafkaCluster","ParentPathParam":[],"Order":2}}},"KafkaConnectCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/cluster/{cluster}/kafka-connect","Name":"KafkaConnectCluster","ParentPathParam":["cluster"],"Order":3}}},"KsqlDBCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/cluster/{cluster}/ksqldb","Name":"KsqlDBCluster","ParentPathParam":["cluster"],"Order":4}}},"Subject":{"Versions":{"2":{"ListPath":"/public/kafka/v2/cluster/{cluster}/subject","Name":"Subject","ParentPathParam":["cluster"],"Order":6}}},"Topic":{"Versions":{"2":{"ListPath":"/public/kafka/v2/cluster/{cluster}/topic","Name":"Topic","ParentPathParam":["cluster"],"Order":5}}},"TopicPolicy":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/topic-policy","Name":"TopicPolicy","ParentPathParam":[],"Order":7}}},"User":{"Versions":{"2":{"ListPath":"/public/iam/v2/user","Name":"User","ParentPathParam":[],"Order":0}}}}
{"Application":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application","Name":"Application","ParentPathParam":[],"ListQueryParamter":{},"Order":8}}},"ApplicationGroup":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-group","Name":"ApplicationGroup","ParentPathParam":[],"ListQueryParamter":{},"Order":11}}},"ApplicationInstance":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-instance","Name":"ApplicationInstance","ParentPathParam":[],"ListQueryParamter":{"application":{"FlagName":"application","Required":false,"Type":"string"}},"Order":9}}},"ApplicationInstancePermission":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/application-instance-permission","Name":"ApplicationInstancePermission","ParentPathParam":[],"ListQueryParamter":{"filterByApplication":{"FlagName":"application","Required":false,"Type":"string"},"filterByApplicationInstance":{"FlagName":"application-instance","Required":false,"Type":"string"},"filterByGrantedTo":{"FlagName":"granted-to","Required":false,"Type":"string"}},"Order":10}}},"Group":{"Versions":{"2":{"ListPath":"/public/iam/v2/group","Name":"Group","ParentPathParam":[],"ListQueryParamter":{},"Order":1}}},"KafkaCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/kafka-cluster","Name":"KafkaCluster","ParentPathParam":[],"ListQueryParamter":{},"Order":2}}},"KafkaConnectCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/cluster/{cluster}/kafka-connect","Name":"KafkaConnectCluster","ParentPathParam":["cluster"],"ListQueryParamter":{},"Order":3}}},"KsqlDBCluster":{"Versions":{"2":{"ListPath":"/public/console/v2/cluster/{cluster}/ksqldb","Name":"KsqlDBCluster","ParentPathParam":["cluster"],"ListQueryParamter":{},"Order":4}}},"Subject":{"Versions":{"2":{"ListPath":"/public/kafka/v2/cluster/{cluster}/subject","Name":"Subject","ParentPathParam":["cluster"],"ListQueryParamter":{},"Order":6}}},"Topic":{"Versions":{"2":{"ListPath":"/public/kafka/v2/cluster/{cluster}/topic","Name":"Topic","ParentPathParam":["cluster"],"ListQueryParamter":{},"Order":5}}},"TopicPolicy":{"Versions":{"1":{"ListPath":"/public/self-serve/v1/topic-policy","Name":"TopicPolicy","ParentPathParam":[],"ListQueryParamter":{"app-instance":{"FlagName":"application-instance","Required":false,"Type":"string"}},"Order":7}}},"User":{"Versions":{"2":{"ListPath":"/public/iam/v2/user","Name":"User","ParentPathParam":[],"ListQueryParamter":{},"Order":0}}}}
175 changes: 124 additions & 51 deletions schema/console_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ func TestGetKindWithYamlFromOldConsolePlusWithoutOrder(t *testing.T) {
"Application": {
Versions: map[int]KindVersion{
1: &ConsoleKindVersion{
Name: "Application",
ListPath: "/public/self-serve/v1/application",
ParentPathParam: make([]string, 0),
Order: DefaultPriority,
Name: "Application",
ListPath: "/public/self-serve/v1/application",
ParentPathParam: make([]string, 0),
ListQueryParamter: map[string]QueryParameterOption{},
Order: DefaultPriority,
},
},
},
Expand All @@ -43,7 +44,14 @@ func TestGetKindWithYamlFromOldConsolePlusWithoutOrder(t *testing.T) {
Name: "ApplicationInstance",
ListPath: "/public/self-serve/v1/application-instance",
ParentPathParam: make([]string, 0),
Order: DefaultPriority,
ListQueryParamter: map[string]QueryParameterOption{
"application": {
FlagName: "application",
Required: false,
Type: "string",
},
},
Order: DefaultPriority,
},
},
},
Expand All @@ -53,7 +61,24 @@ func TestGetKindWithYamlFromOldConsolePlusWithoutOrder(t *testing.T) {
Name: "ApplicationInstancePermission",
ListPath: "/public/self-serve/v1/application-instance-permission",
ParentPathParam: make([]string, 0),
Order: DefaultPriority,
ListQueryParamter: map[string]QueryParameterOption{
"filterByApplication": {
FlagName: "application",
Required: false,
Type: "string",
},
"filterByApplicationInstance": {
FlagName: "application-instance",
Required: false,
Type: "string",
},
"filterByGrantedTo": {
FlagName: "granted-to",
Required: false,
Type: "string",
},
},
Order: DefaultPriority,
},
},
},
Expand All @@ -63,17 +88,25 @@ func TestGetKindWithYamlFromOldConsolePlusWithoutOrder(t *testing.T) {
Name: "TopicPolicy",
ListPath: "/public/self-serve/v1/topic-policy",
ParentPathParam: make([]string, 0),
Order: DefaultPriority,
ListQueryParamter: map[string]QueryParameterOption{
"app-instance": {
FlagName: "application-instance",
Required: false,
Type: "string",
},
},
Order: DefaultPriority,
},
},
},
"Topic": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "Topic",
ListPath: "/public/kafka/v2/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
Order: DefaultPriority,
Name: "Topic",
ListPath: "/public/kafka/v2/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
ListQueryParamter: map[string]QueryParameterOption{},
Order: DefaultPriority,
},
},
},
Expand Down Expand Up @@ -105,10 +138,11 @@ func TestGetKindWithYamlFromConsolePlus(t *testing.T) {
"Application": {
Versions: map[int]KindVersion{
1: &ConsoleKindVersion{
Name: "Application",
ListPath: "/public/self-serve/v1/application",
ParentPathParam: []string{},
Order: 6,
Name: "Application",
ListPath: "/public/self-serve/v1/application",
ParentPathParam: []string{},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 6,
},
},
},
Expand All @@ -118,7 +152,14 @@ func TestGetKindWithYamlFromConsolePlus(t *testing.T) {
Name: "ApplicationInstance",
ListPath: "/public/self-serve/v1/application-instance",
ParentPathParam: []string{},
Order: 7,
ListQueryParamter: map[string]QueryParameterOption{
"application": {
FlagName: "application",
Required: false,
Type: "string",
},
},
Order: 7,
},
},
},
Expand All @@ -128,17 +169,35 @@ func TestGetKindWithYamlFromConsolePlus(t *testing.T) {
Name: "ApplicationInstancePermission",
ListPath: "/public/self-serve/v1/application-instance-permission",
ParentPathParam: []string{},
Order: 8,
ListQueryParamter: map[string]QueryParameterOption{
"filterByApplication": {
FlagName: "application",
Required: false,
Type: "string",
},
"filterByApplicationInstance": {
FlagName: "application-instance",
Required: false,
Type: "string",
},
"filterByGrantedTo": {
FlagName: "granted-to",
Required: false,
Type: "string",
},
},
Order: 8,
},
},
},
"ApplicationGroup": {
Versions: map[int]KindVersion{
1: &ConsoleKindVersion{
Name: "ApplicationGroup",
ListPath: "/public/self-serve/v1/application-group",
ParentPathParam: []string{},
Order: 9,
Name: "ApplicationGroup",
ListPath: "/public/self-serve/v1/application-group",
ParentPathParam: []string{},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 9,
},
},
},
Expand All @@ -148,63 +207,75 @@ func TestGetKindWithYamlFromConsolePlus(t *testing.T) {
Name: "TopicPolicy",
ListPath: "/public/self-serve/v1/topic-policy",
ParentPathParam: []string{},
Order: 5,
ListQueryParamter: map[string]QueryParameterOption{
"app-instance": {
FlagName: "application-instance",
Required: false,
Type: "string",
},
},
Order: 5,
},
},
},
"Topic": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "Topic",
ListPath: "/public/kafka/v2/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
Order: 3,
Name: "Topic",
ListPath: "/public/kafka/v2/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 3,
},
},
},
"Subject": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "Subject",
ListPath: "/public/kafka/v2/cluster/{cluster}/subject",
ParentPathParam: []string{"cluster"},
Order: 4,
Name: "Subject",
ListPath: "/public/kafka/v2/cluster/{cluster}/subject",
ParentPathParam: []string{"cluster"},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 4,
},
},
},
"User": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "User",
ListPath: "/public/iam/v2/user",
ParentPathParam: []string{},
Order: 0,
Name: "User",
ListPath: "/public/iam/v2/user",
ParentPathParam: []string{},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 0,
},
},
},
"Group": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "Group",
ListPath: "/public/iam/v2/group",
ParentPathParam: []string{},
Order: 1,
Name: "Group",
ListPath: "/public/iam/v2/group",
ParentPathParam: []string{},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 1,
},
},
},
"KafkaCluster": {
Versions: map[int]KindVersion{
2: &ConsoleKindVersion{
Name: "KafkaCluster",
ListPath: "/public/console/v2/kafka-cluster",
ParentPathParam: []string{},
Order: 2,
Name: "KafkaCluster",
ListPath: "/public/console/v2/kafka-cluster",
ParentPathParam: []string{},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 2,
},
},
},
}
if !reflect.DeepEqual(kinds, expected) {
t.Error(spew.Printf("got kinds %v, want %v", kinds["Subject"], expected["Subject"]))
t.Error(spew.Printf("got kinds %v, want %v", kinds, expected))
}
})
}
Expand All @@ -230,16 +301,18 @@ func TestGetKindWithMultipleVersion(t *testing.T) {
"Topic": {
Versions: map[int]KindVersion{
1: &ConsoleKindVersion{
Name: "Topic",
ListPath: "/public/v1/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
Order: DefaultPriority,
Name: "Topic",
ListPath: "/public/v1/cluster/{cluster}/topic",
ParentPathParam: []string{"cluster"},
ListQueryParamter: map[string]QueryParameterOption{},
Order: DefaultPriority,
},
2: &ConsoleKindVersion{
Name: "Topic",
ListPath: "/public/v2/cluster/{cluster}/sa/{sa}/topic",
ParentPathParam: []string{"cluster", "sa"},
Order: 42,
Name: "Topic",
ListPath: "/public/v2/cluster/{cluster}/sa/{sa}/topic",
ParentPathParam: []string{"cluster", "sa"},
ListQueryParamter: map[string]QueryParameterOption{},
Order: 42,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion schema/gateway-default-schema.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"VClusters":{"Versions":{"2":{"ListPath":"/gateway/v2/vclusters","Name":"VClusters","ParentPathParam":[],"Order":7}}},"AliasTopics":{"Versions":{"2":{"ListPath":"/gateway/v2/alias-topics","Name":"AliasTopics","ParentPathParam":[],"Order":8}}},"ConcentrationRules":{"Versions":{"2":{"ListPath":"/gateway/v2/concentration-rules","Name":"ConcentrationRules","ParentPathParam":[],"Order":9}}},"GatewayGroups":{"Versions":{"2":{"ListPath":"/gateway/v2/gateway-groups","Name":"GatewayGroups","ParentPathParam":[],"Order":10}}},"ServiceAccounts":{"Versions":{"2":{"ListPath":"/gateway/v2/service-accounts","Name":"ServiceAccounts","ParentPathParam":[],"Order":11}}},"Interceptors":{"Versions":{"2":{"ListPath":"/gateway/v2/interceptors","Name":"Interceptors","ParentPathParam":[],"Order":12}}}}
{"AliasTopics":{"Versions":{"2":{"ListPath":"/gateway/v2/alias-topics","Name":"AliasTopics","ParentPathParam":[],"ListQueryParameter":{"name":{"FlagName":"name","Required":false,"Type":"string"},"showDefaults":{"FlagName":"show-defaults","Required":false,"Type":"boolean"},"vcluster":{"FlagName":"vcluster","Required":false,"Type":"string"}},"Order":8}}},"ConcentrationRules":{"Versions":{"2":{"ListPath":"/gateway/v2/concentration-rules","Name":"ConcentrationRules","ParentPathParam":[],"ListQueryParameter":{"name":{"FlagName":"name","Required":false,"Type":"string"},"showDefaults":{"FlagName":"show-defaults","Required":false,"Type":"boolean"},"vcluster":{"FlagName":"vcluster","Required":false,"Type":"string"}},"Order":9}}},"GatewayGroups":{"Versions":{"2":{"ListPath":"/gateway/v2/gateway-groups","Name":"GatewayGroups","ParentPathParam":[],"ListQueryParameter":{"showDefaults":{"FlagName":"show-defaults","Required":false,"Type":"boolean"}},"Order":10}}},"Interceptors":{"Versions":{"2":{"ListPath":"/gateway/v2/interceptors","Name":"Interceptors","ParentPathParam":[],"ListQueryParameter":{"global":{"FlagName":"global","Required":false,"Type":"boolean"},"group":{"FlagName":"group","Required":false,"Type":"string"},"name":{"FlagName":"name","Required":false,"Type":"string"},"username":{"FlagName":"username","Required":false,"Type":"string"},"vcluster":{"FlagName":"vcluster","Required":false,"Type":"string"}},"Order":12}}},"ServiceAccounts":{"Versions":{"2":{"ListPath":"/gateway/v2/service-accounts","Name":"ServiceAccounts","ParentPathParam":[],"ListQueryParameter":{"name":{"FlagName":"name","Required":false,"Type":"string"},"showDefaults":{"FlagName":"show-defaults","Required":false,"Type":"boolean"},"type":{"FlagName":"type","Required":false,"Type":"string"},"vcluster":{"FlagName":"vcluster","Required":false,"Type":"string"}},"Order":11}}},"VClusters":{"Versions":{"2":{"ListPath":"/gateway/v2/vclusters","Name":"VClusters","ParentPathParam":[],"ListQueryParameter":{},"Order":7}}}}
Loading

0 comments on commit 11ba908

Please sign in to comment.