Skip to content

Commit

Permalink
temp checkin.datamodel still not unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakshmi Javadekar authored and jkotalik committed Nov 4, 2022
1 parent bafc96e commit 7e23388
Show file tree
Hide file tree
Showing 14 changed files with 509 additions and 397 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@
* **container**: [Container](#container) (Required): Definition of a container.
* **environment**: string: The resource id of the environment linked to the resource
* **extensions**: [ContainerExtension](#containerextension)[]: Extensions spec of the resource
<<<<<<< HEAD
* **identity**: [IdentitySettings](#identitysettings)
=======
>>>>>>> a5b5470c (temp checkin.datamodel still not unmarshalling)
* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called.
* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource.

Expand Down Expand Up @@ -303,6 +306,27 @@
* **labels**: [EnvironmentKubernetesMetadataExtensionLabels](#environmentkubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource


## EnvironmentKubernetesMetadataExtensionAnnotations
### Properties
### Additional Properties
* **Additional Properties Type**: string

## EnvironmentKubernetesMetadataExtensionLabels
### Properties
### Additional Properties
* **Additional Properties Type**: string

## EnvironmentExtension
* **Discriminator**: kind

### Base Properties
### EnvironmentKubernetesMetadataExtension
#### Properties
* **annotations**: [EnvironmentKubernetesMetadataExtensionAnnotations](#environmentkubernetesmetadataextensionannotations): Annotations to be applied to the Kubernetes resources output by the resource
* **kind**: 'kubernetesMetadata' (Required): Specifies the extensions of a resource.
* **labels**: [EnvironmentKubernetesMetadataExtensionLabels](#environmentkubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource


## EnvironmentKubernetesMetadataExtensionAnnotations
### Properties
### Additional Properties
Expand Down
2 changes: 1 addition & 1 deletion hack/bicep-types-radius/generated/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Resources":{"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":49},"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":69},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":85},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":102},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":167},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":204},"Applications.Link/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":36},"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":54},"Applications.Link/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":74},"Applications.Link/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":89},"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":104},"Applications.Link/daprSecretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":119},"Applications.Link/daprInvokeHttpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":133},"Applications.Link/daprStateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":153},"Applications.Link/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":168}},"Functions":{"applications.link/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":169}]},"applications.link/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":170}]},"applications.link/rabbitmqmessagequeues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":171}]},"applications.link/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":173}]}}}
{"Resources":{"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":49},"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":69},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":85},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":102},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":167},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":204},"Applications.Link/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":36},"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":54},"Applications.Link/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":74},"Applications.Link/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":89},"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":104},"Applications.Link/daprSecretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":119},"Applications.Link/daprInvokeHttpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":133},"Applications.Link/daprStateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":153},"Applications.Link/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":168}},"Functions":{"applications.link/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":169}]},"applications.link/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":170}]},"applications.link/rabbitmqmessagequeues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":171}]},"applications.link/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":173}]}}}
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ func toExtensionDataModel(e ExtensionClassification) datamodel.Extension {
case *ContainerKubernetesMetadataExtension:
converted := &datamodel.Extension{
Kind: datamodel.KubernetesMetadata,
KubernetesMetadata: &datamodel.BaseKubernetesMetadataExtension{
Annotations: to.StringMap(c.Annotations),
Labels: to.StringMap(c.Labels),
},
}
converted.KubernetesMetadata.Annotations = to.StringMap(c.Annotations)
converted.KubernetesMetadata.Labels = to.StringMap(c.Labels)
return *converted
}

Expand All @@ -519,6 +521,7 @@ func fromExtensionClassificationDataModel(e datamodel.Extension) ContainerExtens
return converted.GetContainerExtension()
case datamodel.KubernetesMetadata:
converted := ContainerKubernetesMetadataExtension{
Kind: to.StringPtr(string(e.Kind)),
Annotations: *to.StringMapPtr(e.KubernetesMetadata.Annotations),
Labels: *to.StringMapPtr(e.KubernetesMetadata.Labels),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestContainerConvertVersionedToDataModel(t *testing.T) {
require.Equal(t, []outputresource.OutputResource(nil), ct.Properties.Status.OutputResources)
require.Equal(t, "2022-03-15-privatepreview", ct.InternalMetadata.UpdatedAPIVersion)
require.Equal(t, 3, len(ct.Properties.Extensions))
require.Equal(t, GetContainerExtensions(t), ct.Properties.Extensions)

require.Equal(t, []string{"/bin/sh"}, ct.Properties.Container.Command)
require.Equal(t, []string{"-c", "while true; do echo hello; sleep 10;done"}, ct.Properties.Container.Args)
Expand Down Expand Up @@ -137,3 +138,41 @@ func TestContainerConvertFromValidation(t *testing.T) {
require.ErrorAs(t, tc.err, &err)
}
}

func GetContainerExtensions(t *testing.T) []datamodel.Extension {
var replicavalue int32 = 3
ptrreplicaval := &replicavalue
extensions := []datamodel.Extension{
{
Kind: datamodel.DaprSidecar,
DaprSidecar: &datamodel.DaprSidecarExtension{
AppID: "app-id",
AppPort: 80,
Config: "config",
Protocol: "http",
Provides: "provides",
},
},
{
Kind: datamodel.ManualScaling,
ManualScaling: &datamodel.ManualScalingExtension{
Replicas: ptrreplicaval,
},
},
{
Kind: datamodel.KubernetesMetadata,
KubernetesMetadata: &datamodel.BaseKubernetesMetadataExtension{
Annotations: map[string]string{
"prometheus.io/scrape": "true",
"prometheus.io/port": "80",
},
Labels: map[string]string{
"mbcp.pt/team": "Credit",
"mbcp.pt/contact": "radiususer",
},
},
},
}

return extensions
}
13 changes: 10 additions & 3 deletions pkg/corerp/api/v20220315privatepreview/environment_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (dst *EnvironmentResource) ConvertFrom(src conv.DataModelInterface) error {
}
}

var extensions []ExtensionClassification
var extensions []EnvironmentExtensionClassification
if env.Properties.Extensions != nil {
for _, e := range env.Properties.Extensions {
extensions = append(extensions, fromEnvExtensionClassificationDataModel(e))
Expand Down Expand Up @@ -215,21 +215,28 @@ func fromEnvironmentComputeKind(kind datamodel.EnvironmentComputeKind) *string {
}

// fromExtensionClassificationEnvDataModel: Converts from base datamodel to versioned datamodel
func fromEnvExtensionClassificationDataModel(e datamodel.Extension) ExtensionClassification {
func fromEnvExtensionClassificationDataModel(e datamodel.Extension) EnvironmentExtensionClassification {
converted := EnvironmentKubernetesMetadataExtension{
Kind: to.StringPtr(string(e.Kind)),
Annotations: *to.StringMapPtr(e.KubernetesMetadata.Annotations),
Labels: *to.StringMapPtr(e.KubernetesMetadata.Labels),
}

return converted.GetExtension()
return converted.GetEnvironmentExtension()
}

// toEnvExtensionDataModel: Converts from versioned datamodel to base datamodel
func toEnvExtensionDataModel(e ExtensionClassification) datamodel.Extension {
switch c := e.(type) {
case *EnvironmentKubernetesMetadataExtension:

converted := &datamodel.Extension{
Kind: datamodel.KubernetesMetadata,
/* LJ: To be deleted later
KubernetesMetadata: &BaseKubernetesMetadataExtension(datamodel.EnvironmentKubernetesMetadataExtension{
Annotations: to.StringMap(c.Annotations),
Labels: to.StringMap(c.Labels),
}*/
}
converted.KubernetesMetadata.Annotations = to.StringMap(c.Annotations)
converted.KubernetesMetadata.Labels = to.StringMap(c.Labels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,32 @@
},
"extensions": [
{
"extension": {
"kind": "manualScaling"
},
"replicas": 2
"kind": "manualScaling",
"manualScaling": {
"replicas": 2
}
},
{
"extension": {
"kind": "daprSidecar"
},
"appId": "app-id",
"appPort": 80,
"config": "config",
"protocol": "http",
"provides": "provides"
"kind": "daprSidecar",
"daprSidecar": {
"appId": "app-id",
"appPort": 80,
"config": "config",
"protocol": "http",
"provides": "provides"
}
},
{
"extension": {
"kind": "kubernetesMetadata"
},
"annotations": {
"kind": "kubernetesMetadata",
"KubernetesMetadata": {
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "nunog"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "radiususer"
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@
}
},
{
"extension": {
"kind": "kubernetesMetadata"
},
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "nunog"
"kind": "kubernetesMetadata",
"KubernetesMetadata": {
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "radiususer"
}
}
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
}
},
"extensions": [
{
"extension": {
"kind": "kubernetesMetadata"
},
{
"kind": "kubernetesMetadata",
"kubernetesMetadata": {
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "nunog"
"mbcp.pt/contact": "radiususer"
}
}
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
},
"extensions": [
{
"extension": {
"kind": "kubernetesMetadata"
},
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "nunog"
"kind": "kubernetesMetadata",
"KubernetesMetadata": {
"annotations": {
"prometheus.io/scrape" : "true",
"prometheus.io/port": "80"
},
"labels": {
"mbcp.pt/team" : "Credit",
"mbcp.pt/contact": "radiususer"
}
}
}
}
]
}
}
5 changes: 5 additions & 0 deletions pkg/corerp/datamodel/kubernetesmetadataextension.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------

package datamodel

// ExtensionKind
Expand Down
Loading

0 comments on commit 7e23388

Please sign in to comment.