Skip to content

Commit

Permalink
Merge branch 'master' into better-failure-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges authored May 19, 2021
2 parents 08f32cf + b790d84 commit 40661b9
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
}
}
},
"arrayOfArraysOfArrays": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/Foo"
}
}
}
},
"arrayOfMaps": {
"type": "array",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ type FakeResourceList struct {
}

type FakeResource_SpecARM struct {
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`
ArrayFoo []FooARM `json:"arrayFoo"`
ArrayOfArrays [][]FooARM `json:"arrayOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]FooARM `json:"arrayOfMaps,omitempty"`
Name string `json:"name"`
Type FakeResourceSpecType `json:"type"`
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`
ArrayFoo []FooARM `json:"arrayFoo"`
ArrayOfArrays [][]FooARM `json:"arrayOfArrays,omitempty"`
ArrayOfArraysOfArrays [][][]FooARM `json:"arrayOfArraysOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]FooARM `json:"arrayOfMaps,omitempty"`
Name string `json:"name"`
Type FakeResourceSpecType `json:"type"`
}

var _ genruntime.ARMResourceSpec = &FakeResource_SpecARM{}
Expand Down Expand Up @@ -103,10 +104,11 @@ const FakeResourceSpecTypeMicrosoftAzureFakeResource = FakeResourceSpecType("Mic

type FakeResource_Spec struct {
// +kubebuilder:validation:Required
ArrayFoo []Foo `json:"arrayFoo"`
ArrayOfArrays [][]Foo `json:"arrayOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]Foo `json:"arrayOfMaps,omitempty"`
ArrayFoo []Foo `json:"arrayFoo"`
ArrayOfArrays [][]Foo `json:"arrayOfArrays,omitempty"`
ArrayOfArraysOfArrays [][][]Foo `json:"arrayOfArraysOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]Foo `json:"arrayOfMaps,omitempty"`

//AzureName: The name of the resource in Azure. This is often the same as the name
//of the resource in Kubernetes but it doesn't have to be.
Expand Down Expand Up @@ -143,6 +145,21 @@ func (fakeResourceSpec *FakeResource_Spec) ConvertToARM(name string, resolvedRef
}
result.ArrayOfArrays = append(result.ArrayOfArrays, itemTemp)
}
for _, item := range fakeResourceSpec.ArrayOfArraysOfArrays {
var itemTemp [][]FooARM
for _, item1 := range item {
var item1Temp []FooARM
for _, item2 := range item1 {
item2ARM, err := item2.ConvertToARM(name, resolvedReferences)
if err != nil {
return nil, err
}
item1Temp = append(item1Temp, item2ARM.(FooARM))
}
itemTemp = append(itemTemp, item1Temp)
}
result.ArrayOfArraysOfArrays = append(result.ArrayOfArraysOfArrays, itemTemp)
}
for _, item := range fakeResourceSpec.ArrayOfEnums {
result.ArrayOfEnums = append(result.ArrayOfEnums, item)
}
Expand Down Expand Up @@ -195,6 +212,22 @@ func (fakeResourceSpec *FakeResource_Spec) PopulateFromARM(owner genruntime.Know
}
fakeResourceSpec.ArrayOfArrays = append(fakeResourceSpec.ArrayOfArrays, itemTemp)
}
for _, item := range typedInput.ArrayOfArraysOfArrays {
var itemTemp [][]Foo
for _, item1 := range item {
var item1Temp []Foo
for _, item2 := range item1 {
var item3 Foo
err := item3.PopulateFromARM(owner, item2)
if err != nil {
return err
}
item1Temp = append(item1Temp, item3)
}
itemTemp = append(itemTemp, item1Temp)
}
fakeResourceSpec.ArrayOfArraysOfArrays = append(fakeResourceSpec.ArrayOfArraysOfArrays, itemTemp)
}
for _, item := range typedInput.ArrayOfEnums {
fakeResourceSpec.ArrayOfEnums = append(fakeResourceSpec.ArrayOfEnums, item)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ type FakeResourceParameters struct {
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`

// +kubebuilder:validation:Required
ArrayFoo []Foo `json:"arrayFoo"`
ArrayOfArrays [][]Foo `json:"arrayOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]Foo `json:"arrayOfMaps,omitempty"`
ArrayFoo []Foo `json:"arrayFoo"`
ArrayOfArrays [][]Foo `json:"arrayOfArrays,omitempty"`
ArrayOfArraysOfArrays [][][]Foo `json:"arrayOfArraysOfArrays,omitempty"`
ArrayOfEnums []Color `json:"arrayOfEnums,omitempty"`
ArrayOfMaps []map[string]Foo `json:"arrayOfMaps,omitempty"`

// +kubebuilder:validation:Required
Name string `json:"name"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@
"additionalProperties": {
"type": "string"
}
},
"mapOfMapsOfMapsOfStrings": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"mapOfMapsOfMaps": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Foo"
},
"properties": {}
},
"properties": {}
}
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ type FakeResourceList struct {
}

type FakeResource_SpecARM struct {
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`
MapFoo map[string]FooARM `json:"mapFoo"`
MapOfArrays map[string][]FooARM `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]FooARM `json:"mapOfMaps,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`
Name string `json:"name"`
Type FakeResourceSpecType `json:"type"`
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`
MapFoo map[string]FooARM `json:"mapFoo"`
MapOfArrays map[string][]FooARM `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]FooARM `json:"mapOfMaps,omitempty"`
MapOfMapsOfMaps map[string]map[string]map[string]FooARM `json:"mapOfMapsOfMaps,omitempty"`
MapOfMapsOfMapsOfStrings map[string]map[string]map[string]string `json:"mapOfMapsOfMapsOfStrings,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`
Name string `json:"name"`
Type FakeResourceSpecType `json:"type"`
}

var _ genruntime.ARMResourceSpec = &FakeResource_SpecARM{}
Expand Down Expand Up @@ -108,11 +110,13 @@ type FakeResource_Spec struct {
AzureName string `json:"azureName"`

// +kubebuilder:validation:Required
MapFoo map[string]Foo `json:"mapFoo"`
MapOfArrays map[string][]Foo `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]Foo `json:"mapOfMaps,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`
MapFoo map[string]Foo `json:"mapFoo"`
MapOfArrays map[string][]Foo `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]Foo `json:"mapOfMaps,omitempty"`
MapOfMapsOfMaps map[string]map[string]map[string]Foo `json:"mapOfMapsOfMaps,omitempty"`
MapOfMapsOfMapsOfStrings map[string]map[string]map[string]string `json:"mapOfMapsOfMapsOfStrings,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`

// +kubebuilder:validation:Required
Owner genruntime.KnownResourceReference `group:"microsoft.resources.infra.azure.com" json:"owner" kind:"ResourceGroup"`
Expand Down Expand Up @@ -173,6 +177,46 @@ func (fakeResourceSpec *FakeResource_Spec) ConvertToARM(name string, resolvedRef
}
}
}
if fakeResourceSpec.MapOfMapsOfMaps != nil {
result.MapOfMapsOfMaps = make(map[string]map[string]map[string]FooARM)
for key, value := range fakeResourceSpec.MapOfMapsOfMaps {
if value != nil {
valueTemp := make(map[string]map[string]FooARM)
for valueKey, value1 := range value {
if value1 != nil {
value1Temp := make(map[string]FooARM)
for valueKey1, value2 := range value1 {
value2ARM, err := value2.ConvertToARM(name, resolvedReferences)
if err != nil {
return nil, err
}
value1Temp[valueKey1] = value2ARM.(FooARM)
}
valueTemp[valueKey] = value1Temp
}
}
result.MapOfMapsOfMaps[key] = valueTemp
}
}
}
if fakeResourceSpec.MapOfMapsOfMapsOfStrings != nil {
result.MapOfMapsOfMapsOfStrings = make(map[string]map[string]map[string]string)
for key, value := range fakeResourceSpec.MapOfMapsOfMapsOfStrings {
if value != nil {
valueTemp := make(map[string]map[string]string)
for valueKey, value1 := range value {
if value1 != nil {
value1Temp := make(map[string]string)
for valueKey1, value2 := range value1 {
value1Temp[valueKey1] = value2
}
valueTemp[valueKey] = value1Temp
}
}
result.MapOfMapsOfMapsOfStrings[key] = valueTemp
}
}
}
if fakeResourceSpec.MapOfStrings != nil {
result.MapOfStrings = make(map[string]string)
for key, value := range fakeResourceSpec.MapOfStrings {
Expand Down Expand Up @@ -245,6 +289,47 @@ func (fakeResourceSpec *FakeResource_Spec) PopulateFromARM(owner genruntime.Know
}
}
}
if typedInput.MapOfMapsOfMaps != nil {
fakeResourceSpec.MapOfMapsOfMaps = make(map[string]map[string]map[string]Foo)
for key, value := range typedInput.MapOfMapsOfMaps {
if value != nil {
valueTemp := make(map[string]map[string]Foo)
for valueKey, value1 := range value {
if value1 != nil {
value1Temp := make(map[string]Foo)
for valueKey1, value2 := range value1 {
var value3 Foo
err := value3.PopulateFromARM(owner, value2)
if err != nil {
return err
}
value1Temp[valueKey1] = value3
}
valueTemp[valueKey] = value1Temp
}
}
fakeResourceSpec.MapOfMapsOfMaps[key] = valueTemp
}
}
}
if typedInput.MapOfMapsOfMapsOfStrings != nil {
fakeResourceSpec.MapOfMapsOfMapsOfStrings = make(map[string]map[string]map[string]string)
for key, value := range typedInput.MapOfMapsOfMapsOfStrings {
if value != nil {
valueTemp := make(map[string]map[string]string)
for valueKey, value1 := range value {
if value1 != nil {
value1Temp := make(map[string]string)
for valueKey1, value2 := range value1 {
value1Temp[valueKey1] = value2
}
valueTemp[valueKey] = value1Temp
}
}
fakeResourceSpec.MapOfMapsOfMapsOfStrings[key] = valueTemp
}
}
}
if typedInput.MapOfStrings != nil {
fakeResourceSpec.MapOfStrings = make(map[string]string)
for key, value := range typedInput.MapOfStrings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ type FakeResourceParameters struct {
ApiVersion FakeResourceSpecApiVersion `json:"apiVersion"`

// +kubebuilder:validation:Required
MapFoo map[string]Foo `json:"mapFoo"`
MapOfArrays map[string][]Foo `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]Foo `json:"mapOfMaps,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`
MapFoo map[string]Foo `json:"mapFoo"`
MapOfArrays map[string][]Foo `json:"mapOfArrays,omitempty"`
MapOfEnums map[string]Color `json:"mapOfEnums,omitempty"`
MapOfMaps map[string]map[string]Foo `json:"mapOfMaps,omitempty"`
MapOfMapsOfMaps map[string]map[string]map[string]Foo `json:"mapOfMapsOfMaps,omitempty"`
MapOfMapsOfMapsOfStrings map[string]map[string]map[string]string `json:"mapOfMapsOfMapsOfStrings,omitempty"`
MapOfStrings map[string]string `json:"mapOfStrings,omitempty"`

// +kubebuilder:validation:Required
Name string `json:"name"`
Expand Down

0 comments on commit 40661b9

Please sign in to comment.