diff --git a/README.md b/README.md index e457ff9ea..d09cc2fb3 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ Sample .NET Core reference application, powered by Microsoft, based on a simplif | Basket API | [![Basket API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/basket?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=199&branchName=dev) | Shopping Aggregator (Mobile) | [![Mobile Shopping Aggregator](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/mobile-shopping-agg?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=204&branchName=dev) | | Catalog API | [![Catalog API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/catalog?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=197&branchName=dev) | Web Client (MVC) | [![WebMVC Client](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/webmvc?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=209&branchName=dev) | |Identity API | [![Identity API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/identity?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=200&branchName=dev) | Web Client (SPA) | [![WebSPA Client](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/webspa?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=210&branchName=dev) | -| Location API | [![Location API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/location?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=202&branchName=dev) | Web Status (Health) | [![Web Status](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/webstatus?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=211&branchName=dev) | -| Marketing API | [![Marketing API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/marketing?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=203&branchName=dev) | Webhooks API | [![Webhooks API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/webhooks?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=207&branchName=dev) | | Ordering API | [![Ordering API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/ordering?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=198&branchName=dev) | Webhooks Client | [![Webhooks demo client](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/webhooks-client?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=208&branchName=dev) | | Payment API | [![Payment API](https://msftdevtools.visualstudio.com/eShopOnContainers/_apis/build/status/microservices/payment?branchName=dev)](https://msftdevtools.visualstudio.com/eShopOnContainers/_build/latest?definitionId=205&branchName=dev) | | | diff --git a/build/acr-build/queue-all.ps1 b/build/acr-build/queue-all.ps1 index 69448f9a2..d160abfc1 100644 --- a/build/acr-build/queue-all.ps1 +++ b/build/acr-build/queue-all.ps1 @@ -14,12 +14,10 @@ $services = @( @{ Name="eshopidentity"; Image="eshop/identity.api"; File="src/Services/Identity/Identity.API/Dockerfile" }, @{ Name="eshopordering"; Image="eshop/ordering.api"; File="src/Services/Ordering/Ordering.API/Dockerfile" }, @{ Name="eshoporderingbg"; Image="eshop/ordering.backgroundtasks"; File="src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile" }, - @{ Name="eshopmarketing"; Image="eshop/marketing.api"; File="src/Services/Marketing/Marketing.API/Dockerfile" }, @{ Name="eshopwebspa"; Image="eshop/webspa"; File="src/Web/WebSPA/Dockerfile" }, @{ Name="eshopwebmvc"; Image="eshop/webmvc"; File="src/Web/WebMVC/Dockerfile" }, @{ Name="eshopwebstatus"; Image="eshop/webstatus"; File="src/Web/WebStatus/Dockerfile" }, @{ Name="eshoppayment"; Image="eshop/payment.api"; File="src/Services/Payment/Payment.API/Dockerfile" }, - @{ Name="eshoplocations"; Image="eshop/locations.api"; File="src/Services/Location/Locations.API/Dockerfile" }, @{ Name="eshopocelotapigw"; Image="eshop/ocelotapigw"; File="src/ApiGateways/ApiGw-Base/Dockerfile" }, @{ Name="eshopmobileshoppingagg"; Image="eshop/mobileshoppingagg"; File="src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile" }, @{ Name="eshopwebshoppingagg"; Image="eshop/webshoppingagg"; File="src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile" }, diff --git a/build/multiarch-manifests/create-manifests.ps1 b/build/multiarch-manifests/create-manifests.ps1 index cc7f05194..6fc67b065 100644 --- a/build/multiarch-manifests/create-manifests.ps1 +++ b/build/multiarch-manifests/create-manifests.ps1 @@ -12,7 +12,7 @@ Write-Host "Tags used are linux-master, win-master, linux-dev, win-dev, linux-la Write-Host "Multiarch images tags will be master, dev, latest" -ForegroundColor Yellow -$services = "identity.api", "basket.api", "catalog.api", "ordering.api", "ordering.backgroundtasks", "marketing.api", "payment.api", "locations.api", "webhooks.api", "ocelotapigw", "mobileshoppingagg", "webshoppingagg", "ordering.signalrhub", "webstatus", "webspa", "webmvc", "webhooks.client" +$services = "identity.api", "basket.api", "catalog.api", "ordering.api", "ordering.backgroundtasks", "payment.api", "webhooks.api", "ocelotapigw", "mobileshoppingagg", "webshoppingagg", "ordering.signalrhub", "webstatus", "webspa", "webmvc", "webhooks.client" foreach ($svc in $services) { Write-Host "Creating manifest for $svc and tags :latest, :master, and :dev" diff --git a/deploy/azure/az/servicebus/sbusdeploy.json b/deploy/azure/az/servicebus/sbusdeploy.json index 50c1c6c54..46ac930aa 100644 --- a/deploy/azure/az/servicebus/sbusdeploy.json +++ b/deploy/azure/az/servicebus/sbusdeploy.json @@ -14,8 +14,6 @@ "BasketSubscriptionName": "Basket", "CatalogSubscriptionName": "Catalog", "OrderingSubscriptionName": "Ordering", - "LocationsSubscriptionName": "Locations", - "MarketingSubscriptionName": "Marketing", "GracePeriodSubscriptionName": "GracePeriod", "PaymentSubscriptionName": "Payment", "location": "[resourceGroup().location]", @@ -135,46 +133,6 @@ "entityAvailabilityStatus": "Available" } }, - { - "apiVersion": "[variables('sbVersion')]", - "name": "[variables('LocationsSubscriptionName')]", - "type": "Subscriptions", - "dependsOn": [ - "[variables('serviceBusTopicName')]" - ], - "properties": { - "lockDuration": "00:00:30", - "requiresSession": false, - "defaultMessageTimeToLive": "14.00:00:00", - "deadLetteringOnMessageExpiration": true, - "deadLetteringOnFilterEvaluationExceptions": true, - "maxDeliveryCount": 10, - "enableBatchedOperations": false, - "status": "Active", - "autoDeleteOnIdle": "10675199.02:48:05.4775807", - "entityAvailabilityStatus": "Available" - } - }, - { - "apiVersion": "[variables('sbVersion')]", - "name": "[variables('MarketingSubscriptionName')]", - "type": "Subscriptions", - "dependsOn": [ - "[variables('serviceBusTopicName')]" - ], - "properties": { - "lockDuration": "00:00:30", - "requiresSession": false, - "defaultMessageTimeToLive": "14.00:00:00", - "deadLetteringOnMessageExpiration": true, - "deadLetteringOnFilterEvaluationExceptions": true, - "maxDeliveryCount": 10, - "enableBatchedOperations": false, - "status": "Active", - "autoDeleteOnIdle": "10675199.02:48:05.4775807", - "entityAvailabilityStatus": "Available" - } - }, { "apiVersion": "[variables('sbVersion')]", "name": "[variables('GracePeriodSubscriptionName')]", diff --git a/deploy/azure/az/sql/sqldeploy.json b/deploy/azure/az/sql/sqldeploy.json index 397c94ad6..2bc8eeac3 100644 --- a/deploy/azure/az/sql/sqldeploy.json +++ b/deploy/azure/az/sql/sqldeploy.json @@ -73,22 +73,7 @@ "dependsOn": [ "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]" ] - }, - { - "type": "databases", - "name": "[parameters('sql_server').dbs.marketing]", - "apiVersion": "2014-04-01-preview", - "location": "[resourceGroup().location]", - "properties": { - "edition": "Standard", - "collation": "SQL_Latin1_General_CP1_CI_AS", - "maxSizeBytes": "1073741824", - "requestedServiceObjectiveName": "S1" - }, - "dependsOn": [ - "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]" - ] - }, + }, { "type": "firewallrules", "name": "AllowAllWindowsAzureIps", diff --git a/deploy/azure/az/sql/sqldeploy.parameters.json b/deploy/azure/az/sql/sqldeploy.parameters.json index 982e78f4c..473cf08cd 100644 --- a/deploy/azure/az/sql/sqldeploy.parameters.json +++ b/deploy/azure/az/sql/sqldeploy.parameters.json @@ -8,8 +8,7 @@ "dbs": { "ordering": "orderingdb", "identity": "identitydb", - "catalog": "catalogdb", - "marketing": "marketingdb" + "catalog": "catalogdb" } } }, diff --git a/deploy/azure/az/storage/marketing/deploystorage.json b/deploy/azure/az/storage/marketing/deploystorage.json deleted file mode 100644 index 632e0d09a..000000000 --- a/deploy/azure/az/storage/marketing/deploystorage.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "marketingstorage": { - "type": "string" - }, - "profileName" : { - "type": "string" - }, - "endpointName" : { - "type": "string" - } - }, - "variables": { - "marketingstorage": "[concat(parameters('marketingstorage'), uniqueString(resourceGroup().id))]", - "endpointName": "[concat(parameters('endpointName'), uniqueString(resourceGroup().id))]", - "profileName": "[parameters('profileName')]" - }, - "resources": [ - { - "type": "Microsoft.Storage/storageAccounts", - "name": "[variables('marketingstorage')]", - "apiVersion": "2016-01-01", - "location": "[resourceGroup().location]", - "tags": { - "displayName": "[variables('marketingstorage')]" - }, - "sku": { - "name": "Standard_LRS" - }, - "kind": "Storage" - }, - { - "name": "[variables('profileName')]", - "type": "Microsoft.Cdn/profiles", - "location": "[resourceGroup().location]", - "apiVersion": "2016-04-02", - "tags": { - "displayName": "[variables('profileName')]" - }, - "sku": { - "name": "Standard_Verizon" - }, - "resources": [ - { - "apiVersion": "2016-04-02", - "name": "[variables('endpointName')]", - "type": "endpoints", - "dependsOn": [ - "[variables('profileName')]", - "[variables('marketingstorage')]" - ], - "location": "[resourceGroup().location]", - "tags": { - "displayName": "[variables('endpointName')]" - }, - "properties": { - "originHostHeader": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('marketingstorage')),'2015-06-15' ).primaryEndpoints.blob,'https://',''),'/','')]", - "isHttpAllowed": true, - "isHttpsAllowed": true, - "queryStringCachingBehavior": "IgnoreQueryString", - "contentTypesToCompress": [ - "text/plain", - "text/html", - "text/css", - "application/x-javascript", - "text/javascript" - ], - "isCompressionEnabled": "True", - "origins": [ - { - "name": "origin1", - "properties": { - "hostName": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('marketingstorage')),'2015-06-15' ).primaryEndpoints.blob,'https://',''),'/','')]" - } - } - ] - } - } - ] - } - ], - "outputs": { - "hostName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.cdn/profiles/endpoints', variables('profileName'), variables('endpointName'))).hostName]" - }, - "originHostHeader": { - "type": "string", - "value": "[reference(resourceId('Microsoft.cdn/profiles/endpoints', variables('profileName'), variables('endpointName'))).originHostHeader]" - } - } -} \ No newline at end of file diff --git a/deploy/azure/az/storage/marketing/deploystorage.parameters.json b/deploy/azure/az/storage/marketing/deploystorage.parameters.json deleted file mode 100644 index 40f7b3a1b..000000000 --- a/deploy/azure/az/storage/marketing/deploystorage.parameters.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "marketingstorage": { - "value": "marketing" - }, - "profileName":{ - "value": "eshopmarketing" - }, - "endpointName":{ - "value": "marketing-endpoint" - } - } -} \ No newline at end of file diff --git a/deploy/azure/az/storage/marketing/readme.md b/deploy/azure/az/storage/marketing/readme.md deleted file mode 100644 index c0ec2be7a..000000000 --- a/deploy/azure/az/storage/marketing/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# Deploying Marketing Storage - -The ARM template `deploystorage.json` and its parameter file (`deploystorage.parameters.json`) are used to deploy following resources: - -1. One Storage Account -2. One CDN profile -3. One Endpoint - -## Editing deploystorage.parameters.json file - -You can edit the `deploystorage.parameters.json` file to set your values, but is not needed. The only parameters that can -be set are: - -1. `marketingstorage` is a string that is used to create the storage account name. ARM script creates unique values by appending a unique string to this parameter value, so you can leave the default value. - -2. `profileName` is a string that is used to create the CDN profile name. - -3. `endpointName` is a string that is used to create the storage endpoint name. ARM script creates unique values by appending a unique string to this parameter value, so you can leave the default value. - -## Deploy the template - -Once parameter file is edited you can deploy it using [create-resources script](../../readme.md). - -i. e. if you are in windows, to deploy a Storage account in a new resourcegroup located in westus, go to `deploy\az` folder and type: - -``` -create-resources.cmd storage\marketing\deploystorage newResourceGroup -c westus -``` - - - - - - - - - diff --git a/deploy/azure/readme.md b/deploy/azure/readme.md index 27b168713..cc35bb001 100644 --- a/deploy/azure/readme.md +++ b/deploy/azure/readme.md @@ -22,8 +22,6 @@ Using `docker-machine` is the recommended way to create a VM with docker install 3. [Deploying Redis Cache](az/redis/readme.md) 4. [Deploying Cosmosdb](az/cosmos/readme.md) 5. [Deploying Catalog Storage](az/storage/catalog/readme.md) -6. [Deploying Marketing Storage](az/storage/marketing/readme.md) -7. [Deploying Marketing Azure functions](az/azurefunctions/readme.md) diff --git a/deploy/k8s/archived/helm/apigwmm/.helmignore b/deploy/k8s/archived/helm/apigwmm/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/deploy/k8s/archived/helm/apigwmm/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/deploy/k8s/archived/helm/apigwmm/Chart.yaml b/deploy/k8s/archived/helm/apigwmm/Chart.yaml deleted file mode 100644 index 50b3d07c6..000000000 --- a/deploy/k8s/archived/helm/apigwmm/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: apigwmm -version: 0.1.0 diff --git a/deploy/k8s/archived/helm/apigwmm/envoy.yaml b/deploy/k8s/archived/helm/apigwmm/envoy.yaml deleted file mode 100644 index 54b1afa06..000000000 --- a/deploy/k8s/archived/helm/apigwmm/envoy.yaml +++ /dev/null @@ -1,75 +0,0 @@ -admin: - access_log_path: "/dev/null" - address: - socket_address: - address: 0.0.0.0 - port_value: 8001 -static_resources: - listeners: - - address: - socket_address: - address: 0.0.0.0 - port_value: 80 - filter_chains: - - filters: - - name: envoy.http_connection_manager - config: - codec_type: auto - stat_prefix: ingress_http - route_config: - name: eshop_backend_route - virtual_hosts: - - name: eshop_backend - domains: - - "*" - routes: - - name: "m-short" - match: - prefix: "/m/" - route: - auto_host_rewrite: true - prefix_rewrite: "/marketing-api/" - cluster: marketing - - name: "m-long" - match: - prefix: "/marketing-api/" - route: - auto_host_rewrite: true - cluster: marketing - http_filters: - - name: envoy.router - access_log: - - name: envoy.file_access_log - filter: - not_health_check_filter: {} - config: - json_format: - time: "%START_TIME%" - protocol: "%PROTOCOL%" - duration: "%DURATION%" - request_method: "%REQ(:METHOD)%" - request_host: "%REQ(HOST)%" - path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%" - response_flags: "%RESPONSE_FLAGS%" - route_name: "%ROUTE_NAME%" - upstream_host: "%UPSTREAM_HOST%" - upstream_cluster: "%UPSTREAM_CLUSTER%" - upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%" - path: "/tmp/access.log" - clusters: - - name: marketing - connect_timeout: 0.25s - type: logical_dns - lb_policy: round_robin - hosts: - - socket_address: - address: marketing-api - port_value: 80 - - name: locations - connect_timeout: 0.25s - type: logical_dns - lb_policy: round_robin - hosts: - - socket_address: - address: locations-api - port_value: 80 diff --git a/deploy/k8s/archived/helm/apigwmm/templates/NOTES.txt b/deploy/k8s/archived/helm/apigwmm/templates/NOTES.txt deleted file mode 100644 index 30ef33447..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/NOTES.txt +++ /dev/null @@ -1,2 +0,0 @@ -eShop API Gateway for Mobile Marketing services installed ----------------------------------------------------------- \ No newline at end of file diff --git a/deploy/k8s/archived/helm/apigwmm/templates/_helpers.tpl b/deploy/k8s/archived/helm/apigwmm/templates/_helpers.tpl deleted file mode 100644 index fd3d89212..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "apigwmm.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "apigwmm.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "apigwmm.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/deploy/k8s/archived/helm/apigwmm/templates/_names.tpl b/deploy/k8s/archived/helm/apigwmm/templates/_names.tpl deleted file mode 100644 index d44859fea..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/_names.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{{- define "suffix-name" -}} -{{- if .Values.app.name -}} -{{- .Values.app.name -}} -{{- else -}} -{{- .Release.Name -}} -{{- end -}} -{{- end -}} - -{{- define "sql-name" -}} -{{- if .Values.inf.sql.host -}} -{{- .Values.inf.sql.host -}} -{{- else -}} -{{- printf "%s" "sql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "mongo-name" -}} -{{- if .Values.inf.mongo.host -}} -{{- .Values.inf.mongo.host -}} -{{- else -}} -{{- printf "%s" "nosql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "url-of" -}} -{{- $name := first .}} -{{- $ctx := last .}} -{{- if eq $name "" -}} -{{- $ctx.Values.inf.k8s.dns -}} -{{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} -{{- end -}} -{{- end -}} - - - -{{- define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} -{{- else -}} -{{- .Values.pathBase -}} -{{- end -}} -{{- end -}} - -{{- define "fqdn-image" -}} -{{- if .Values.inf.registry -}} -{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} -{{- else -}} -{{- .Values.image.repository -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/apigwmm/templates/deployment.yaml b/deploy/k8s/archived/helm/apigwmm/templates/deployment.yaml deleted file mode 100644 index f93706bb9..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/deployment.yaml +++ /dev/null @@ -1,110 +0,0 @@ -{{- $name := include "apigwmm.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -{{- $envoycfgname := printf "%s-%s" "envoy" $name -}} -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: {{ template "apigwmm.fullname" . }} - labels: - ufo: {{ $cfgname}} - app: {{ template "apigwmm.name" . }} - chart: {{ template "apigwmm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "apigwmm.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "apigwmm.name" . }} - release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} - annotations: - linkerd.io/inject: enabled - {{- end }} - spec: - {{ if .Values.inf.registry -}} - imagePullSecrets: - - name: {{ .Values.inf.registry.secretName }} - {{- end }} - volumes: - - name: config - configMap: - name: {{ $envoycfgname }} - items: - - key: envoy.yaml - path: envoy.yaml - containers: - - name: {{ .Chart.Name }} - {{ if .Values.probes -}} - {{- if .Values.probes.liveness -}} - livenessProbe: - httpGet: - port: {{ .Values.probes.liveness.port }} - path: {{ .Values.probes.liveness.path }} - initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} - {{- end -}} - {{- end -}} - {{- if .Values.probes -}} - {{- if .Values.probes.readiness }} - readinessProbe: - httpGet: - port: {{ .Values.probes.readiness.port }} - path: {{ .Values.probes.readiness.path }} - initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} - timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} - {{- end -}} - {{- end }} - image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" - imagePullPolicy: IfNotPresent - volumeMounts: - - name: config - mountPath: {{ .Values.envoy.configPath }} - env: - - name: PATH_BASE - value: {{ include "pathBase" . }} - - name: k8sname - value: {{ .Values.clusterName }} - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .key }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - - name: admin - containerPort: 8001 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/deploy/k8s/archived/helm/apigwmm/templates/envoy-cm.yaml b/deploy/k8s/archived/helm/apigwmm/templates/envoy-cm.yaml deleted file mode 100644 index 71728d084..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/envoy-cm.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{- $name := include "apigwmm.fullname" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "envoy-{{ $name }}" - labels: - app: {{ template "apigwmm.name" . }} - chart: {{ template "apigwmm.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - {{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }} - diff --git a/deploy/k8s/archived/helm/apigwmm/templates/ingress.yaml b/deploy/k8s/archived/helm/apigwmm/templates/ingress.yaml deleted file mode 100644 index 44e9a90fc..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/ingress.yaml +++ /dev/null @@ -1,46 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $ingressPath := include "pathBase" . -}} -{{- $serviceName := .Values.app.svc.mobilemarketingapigw -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "apigwmm.fullname" . }} - labels: - app: {{ template "apigwmm.name" . }} - chart: {{ template "apigwmm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} - cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} -{{- end }} -{{- if .Values.inf.mesh.enabled }} -{{- with .Values.ingress.mesh.annotations }} -{{ toYaml . | indent 4 }} -{{- end }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $serviceName }} - servicePort: http - {{- end }} -{{- end }} diff --git a/deploy/k8s/archived/helm/apigwmm/templates/service.yaml b/deploy/k8s/archived/helm/apigwmm/templates/service.yaml deleted file mode 100644 index 286277c7d..000000000 --- a/deploy/k8s/archived/helm/apigwmm/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.app.svc.mobilemarketingapigw }} - labels: - app: {{ template "apigwmm.name" . }} - chart: {{ template "apigwmm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - - port: {{ .Values.service.adminPort }} - targetPort: admin - protocol: TCP - name: admin - selector: - app: {{ template "apigwmm.name" . }} - release: {{ .Release.Name }} diff --git a/deploy/k8s/archived/helm/apigwmm/values.yaml b/deploy/k8s/archived/helm/apigwmm/values.yaml deleted file mode 100644 index 21f12f27a..000000000 --- a/deploy/k8s/archived/helm/apigwmm/values.yaml +++ /dev/null @@ -1,45 +0,0 @@ -replicaCount: 1 -clusterName: eshop-aks -pathBase: /mobilemarketingapigw - -image: - repository: envoyproxy/envoy - tag: v1.11.1 - -service: - type: ClusterIP - port: 80 - adminPort: 8001 - -ingress: - enabled: true - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/" - ingress.kubernetes.io/rewrite-target: "/" - tls: [] - -resources: {} - - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -env: {} - -envoy: - configPath: /etc/envoy - -probes: - liveness: - path: /ready - initialDelaySeconds: 5 - periodSeconds: 15 - port: 8001 - readiness: - path: /ready - initialDelaySeconds: 5 - periodSeconds: 60 - port: 8001 \ No newline at end of file diff --git a/deploy/k8s/archived/helm/apigwwm/.helmignore b/deploy/k8s/archived/helm/apigwwm/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/deploy/k8s/archived/helm/apigwwm/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/deploy/k8s/archived/helm/apigwwm/Chart.yaml b/deploy/k8s/archived/helm/apigwwm/Chart.yaml deleted file mode 100644 index 4c2082969..000000000 --- a/deploy/k8s/archived/helm/apigwwm/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: apigwwm -version: 0.1.0 diff --git a/deploy/k8s/archived/helm/apigwwm/envoy.yaml b/deploy/k8s/archived/helm/apigwwm/envoy.yaml deleted file mode 100644 index c6f3421de..000000000 --- a/deploy/k8s/archived/helm/apigwwm/envoy.yaml +++ /dev/null @@ -1,75 +0,0 @@ -admin: - access_log_path: "/dev/null" - address: - socket_address: - address: 0.0.0.0 - port_value: 8001 -static_resources: - listeners: - - address: - socket_address: - address: 0.0.0.0 - port_value: 80 - filter_chains: - - filters: - - name: envoy.http_connection_manager - config: - codec_type: auto - stat_prefix: ingress_http - route_config: - name: eshop_backend_route - virtual_hosts: - - name: eshop_backend - domains: - - "*" - routes: - - name: "m-short" - match: - prefix: "/m/" - route: - auto_host_rewrite: true - prefix_rewrite: "/marketing-api/" - cluster: marketing - - name: "m-long" - match: - prefix: "/marketing-api/" - route: - auto_host_rewrite: true - cluster: marketing - http_filters: - - name: envoy.router - access_log: - - name: envoy.file_access_log - filter: - not_health_check_filter: {} - config: - json_format: - time: "%START_TIME%" - protocol: "%PROTOCOL%" - duration: "%DURATION%" - request_method: "%REQ(:METHOD)%" - request_host: "%REQ(HOST)%" - path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%" - response_flags: "%RESPONSE_FLAGS%" - route_name: "%ROUTE_NAME%" - upstream_host: "%UPSTREAM_HOST%" - upstream_cluster: "%UPSTREAM_CLUSTER%" - upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%" - path: "/tmp/access.log" - clusters: - - name: marketing - connect_timeout: 0.25s - type: strict_dns - lb_policy: round_robin - hosts: - - socket_address: - address: marketing-api - port_value: 80 - - name: locations - connect_timeout: 0.25s - type: strict_dns - lb_policy: round_robin - hosts: - - socket_address: - address: locations-api - port_value: 80 diff --git a/deploy/k8s/archived/helm/apigwwm/templates/NOTES.txt b/deploy/k8s/archived/helm/apigwwm/templates/NOTES.txt deleted file mode 100644 index 3420c97c8..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/NOTES.txt +++ /dev/null @@ -1,2 +0,0 @@ -eShop API Gateway for Web Marketing services installed ------------------------------------------------------- \ No newline at end of file diff --git a/deploy/k8s/archived/helm/apigwwm/templates/_helpers.tpl b/deploy/k8s/archived/helm/apigwwm/templates/_helpers.tpl deleted file mode 100644 index 194cf96ca..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "apigwwm.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "apigwwm.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "apigwwm.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/deploy/k8s/archived/helm/apigwwm/templates/_names.tpl b/deploy/k8s/archived/helm/apigwwm/templates/_names.tpl deleted file mode 100644 index d44859fea..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/_names.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{{- define "suffix-name" -}} -{{- if .Values.app.name -}} -{{- .Values.app.name -}} -{{- else -}} -{{- .Release.Name -}} -{{- end -}} -{{- end -}} - -{{- define "sql-name" -}} -{{- if .Values.inf.sql.host -}} -{{- .Values.inf.sql.host -}} -{{- else -}} -{{- printf "%s" "sql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "mongo-name" -}} -{{- if .Values.inf.mongo.host -}} -{{- .Values.inf.mongo.host -}} -{{- else -}} -{{- printf "%s" "nosql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "url-of" -}} -{{- $name := first .}} -{{- $ctx := last .}} -{{- if eq $name "" -}} -{{- $ctx.Values.inf.k8s.dns -}} -{{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} -{{- end -}} -{{- end -}} - - - -{{- define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} -{{- else -}} -{{- .Values.pathBase -}} -{{- end -}} -{{- end -}} - -{{- define "fqdn-image" -}} -{{- if .Values.inf.registry -}} -{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} -{{- else -}} -{{- .Values.image.repository -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/apigwwm/templates/deployment.yaml b/deploy/k8s/archived/helm/apigwwm/templates/deployment.yaml deleted file mode 100644 index 6ceb1fa1b..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/deployment.yaml +++ /dev/null @@ -1,110 +0,0 @@ -{{- $name := include "apigwwm.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -{{- $envoycfgname := printf "%s-%s" "envoy" $name -}} -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: {{ template "apigwwm.fullname" . }} - labels: - ufo: {{ $cfgname}} - app: {{ template "apigwwm.name" . }} - chart: {{ template "apigwwm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "apigwwm.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "apigwwm.name" . }} - release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} - annotations: - linkerd.io/inject: enabled - {{- end }} - spec: - {{ if .Values.inf.registry -}} - imagePullSecrets: - - name: {{ .Values.inf.registry.secretName }} - {{- end }} - volumes: - - name: config - configMap: - name: {{ $envoycfgname }} - items: - - key: envoy.yaml - path: envoy.yaml - containers: - - name: {{ .Chart.Name }} - {{ if .Values.probes -}} - {{- if .Values.probes.liveness -}} - livenessProbe: - httpGet: - port: {{ .Values.probes.liveness.port }} - path: {{ .Values.probes.liveness.path }} - initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} - {{- end -}} - {{- end -}} - {{- if .Values.probes -}} - {{- if .Values.probes.readiness }} - readinessProbe: - httpGet: - port: {{ .Values.probes.readiness.port }} - path: {{ .Values.probes.readiness.path }} - initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} - timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} - {{- end -}} - {{- end }} - image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" - imagePullPolicy: IfNotPresent - volumeMounts: - - name: config - mountPath: {{ .Values.envoy.configPath }} - env: - - name: PATH_BASE - value: {{ include "pathBase" . }} - - name: k8sname - value: {{ .Values.clusterName }} - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .key }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - - name: admin - containerPort: 8001 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/deploy/k8s/archived/helm/apigwwm/templates/envoy-cm.yaml b/deploy/k8s/archived/helm/apigwwm/templates/envoy-cm.yaml deleted file mode 100644 index 4d6307e36..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/envoy-cm.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{- $name := include "apigwwm.fullname" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "envoy-{{ $name }}" - labels: - app: {{ template "apigwwm.name" . }} - chart: {{ template "apigwwm.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - {{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 -}} - diff --git a/deploy/k8s/archived/helm/apigwwm/templates/ingress.yaml b/deploy/k8s/archived/helm/apigwwm/templates/ingress.yaml deleted file mode 100644 index 00d54c226..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/ingress.yaml +++ /dev/null @@ -1,47 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $ingressPath := include "pathBase" . -}} -{{- $serviceName := .Values.app.svc.webmarketingapigw -}} - -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "apigwwm.fullname" . }} - labels: - app: {{ template "apigwwm.name" . }} - chart: {{ template "apigwwm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -{{- if and .Values.inf.tls.enabled .Values.inf.tls.issuer }} - cert-manager.io/issuer: {{ .Values.inf.tls.issuer }} -{{- end }} -{{- if .Values.inf.mesh.enabled }} -{{- with .Values.ingress.mesh.annotations }} -{{ toYaml . | indent 4 }} -{{- end }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $serviceName }} - servicePort: http - {{- end }} -{{- end }} diff --git a/deploy/k8s/archived/helm/apigwwm/templates/service.yaml b/deploy/k8s/archived/helm/apigwwm/templates/service.yaml deleted file mode 100644 index cb11cc665..000000000 --- a/deploy/k8s/archived/helm/apigwwm/templates/service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.app.svc.webmarketingapigw }} - labels: - app: {{ template "apigwwm.name" . }} - chart: {{ template "apigwwm.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - - port: {{ .Values.service.adminPort }} - targetPort: admin - protocol: TCP - name: admin - selector: - app: {{ template "apigwwm.name" . }} - release: {{ .Release.Name }} diff --git a/deploy/k8s/archived/helm/apigwwm/values.yaml b/deploy/k8s/archived/helm/apigwwm/values.yaml deleted file mode 100644 index d866c2d3c..000000000 --- a/deploy/k8s/archived/helm/apigwwm/values.yaml +++ /dev/null @@ -1,46 +0,0 @@ -replicaCount: 1 -clusterName: eshop-aks -pathBase: /webmarketingapigw - -image: - repository: envoyproxy/envoy - tag: v1.11.1 - -service: - type: ClusterIP - port: 80 - adminPort: 8001 - -ingress: - enabled: true - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/" - ingress.kubernetes.io/rewrite-target: "/" - tls: [] - -resources: {} - - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -# env defines the environment variables that will be declared in the pod -env: {} - -envoy: - configPath: /etc/envoy - -probes: - liveness: - path: /ready - initialDelaySeconds: 5 - periodSeconds: 15 - port: 8001 - readiness: - path: /ready - initialDelaySeconds: 5 - periodSeconds: 60 - port: 8001 \ No newline at end of file diff --git a/deploy/k8s/archived/helm/app.yaml b/deploy/k8s/archived/helm/app.yaml index e83ea2823..acea31ef1 100644 --- a/deploy/k8s/archived/helm/app.yaml +++ b/deploy/k8s/archived/helm/app.yaml @@ -13,14 +13,10 @@ app: # app global settings spa: "" # ingress entry for web spa status: webstatus # ingress entry for web status webshoppingapigw: webshoppingapigw # ingress entry for web shopping Agw - webmarketingapigw: webmarketingapigw # ingress entry for web mkg Agw - mobilemarketingapigw: mobilemarketingapigw # ingress entry for mobile mkg Agw mobileshoppingapigw: mobileshoppingapigw # ingress entry for mobile shopping Agw webshoppingagg: webshoppingagg # ingress entry for web shopping aggregator mobileshoppingagg: mobileshoppingagg # ingress entry for mobile shopping aggregator payment: payment-api # ingress entry for payment api - locations: locations-api # ingress entry for locations api - marketing: marketing-api # ingress entry for marketing api webhooks: webhooks-api # ingress entry for webhooks api webhooksweb: webhooks-web # ingress entry for webhooks web demo client svc: @@ -34,13 +30,9 @@ app: # app global settings spa: webspa # service name for web spa status: webstatus # service name for web status webshoppingapigw: webshoppingapigw # service name for web shopping Agw - webmarketingapigw: webmarketingapigw # service name for web mkg Agw - mobilemarketingapigw: mobilemarketingapigw # service name for mobile mkg Agw mobileshoppingapigw: mobileshoppingapigw # service name for mobile shopping Agw webshoppingagg: webshoppingagg # service name for web shopping aggregator mobileshoppingagg: mobileshoppingagg # service name for mobile shopping aggregator payment: payment-api # service name for payment api - locations: locations-api # service name for locations api - marketing: marketing-api # service name for marketing ap webhooks: webhooks-api # service name for webhooks api webhooksweb: webhooks-client # service name for webhooks web diff --git a/deploy/k8s/archived/helm/deploy-all.ps1 b/deploy/k8s/archived/helm/deploy-all.ps1 index 1711c0c2c..51d87e720 100644 --- a/deploy/k8s/archived/helm/deploy-all.ps1 +++ b/deploy/k8s/archived/helm/deploy-all.ps1 @@ -113,7 +113,7 @@ if (-not [string]::IsNullOrEmpty($registry)) { Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green $infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data") -$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") +$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") $gateways = ("apigwmm", "apigwms", "apigwwm", "apigwws") if ($deployInfrastructure) { diff --git a/deploy/k8s/archived/helm/deploy-all.sh b/deploy/k8s/archived/helm/deploy-all.sh index 6f6d868aa..ad76bd54c 100644 --- a/deploy/k8s/archived/helm/deploy-all.sh +++ b/deploy/k8s/archived/helm/deploy-all.sh @@ -142,7 +142,7 @@ fi if [[ $push_images ]]; then echo "#################### Pushing images to the container registry ####################" - services=(basket.api catalog.api identity.api ordering.api marketing.api payment.api locations.api webmvc webspa webstatus) + services=(basket.api catalog.api identity.api ordering.api payment.api webmvc webspa webstatus) if [[ -z "$(docker image ls -q --filter=reference=eshop/$service:$image_tag)" ]]; then image_tag=linux-$image_tag @@ -209,7 +209,7 @@ fi echo "#################### Begin $app_name installation using Helm ####################" infras=(sql-data nosql-data rabbitmq keystore-data basket-data) -charts=(eshop-common apigwmm apigwms apigwwm apigwws basket-api catalog-api identity-api locations-api marketing-api mobileshoppingagg ordering-api ordering-backgroundtasks ordering-signalrhub payment-api webmvc webshoppingagg webspa webstatus webhooks-api webhooks-web) +charts=(eshop-common apigwms apigwws basket-api catalog-api identity-api mobileshoppingagg ordering-api ordering-backgroundtasks ordering-signalrhub payment-api webmvc webshoppingagg webspa webstatus webhooks-api webhooks-web) if [[ !$skip_infrastructure ]]; then for infra in "${infras[@]}" diff --git a/deploy/k8s/archived/helm/identity-api/templates/configmap.yaml b/deploy/k8s/archived/helm/identity-api/templates/configmap.yaml index 264ceb745..7c670f646 100644 --- a/deploy/k8s/archived/helm/identity-api/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/identity-api/templates/configmap.yaml @@ -2,8 +2,6 @@ {{- $sqlsrv := include "sql-name" . -}} {{- $mvc_url := include "url-of" (list .Values.app.ingress.entries.mvc .) -}} {{- $spa_url := include "url-of" (list .Values.app.ingress.entries.spa .) -}} -{{- $locations_url := include "url-of" (list .Values.app.ingress.entries.locations .) -}} -{{- $marketing_url := include "url-of" (list .Values.app.ingress.entries.marketing .) -}} {{- $basket_url := include "url-of" (list .Values.app.ingress.entries.basket .) -}} {{- $ordering_url := include "url-of" (list .Values.app.ingress.entries.ordering .) -}} {{- $mobileshoppingagg := include "url-of" (list .Values.app.ingress.entries.mobileshoppingagg .) -}} @@ -27,8 +25,6 @@ data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" mvc_e: http://{{ $mvc_url }} spa_e: http://{{ $spa_url }} - locations_e: http://{{ $locations_url }} - marketing_e: http://{{ $marketing_url }} basket_e: http://{{ $basket_url }} ordering_e: http://{{ $ordering_url }} mobileshoppingagg_e: http://{{ $mobileshoppingagg }} diff --git a/deploy/k8s/archived/helm/identity-api/values.yaml b/deploy/k8s/archived/helm/identity-api/values.yaml index 7b57dfde1..92fd57283 100644 --- a/deploy/k8s/archived/helm/identity-api/values.yaml +++ b/deploy/k8s/archived/helm/identity-api/values.yaml @@ -40,10 +40,6 @@ env: key: mvc_e - name: SpaClient key: spa_e - - name: LocationApiClient - key: locations_e - - name: MarketingApiClient - key: marketing_e - name: BasketApiClient key: basket_e - name: OrderingApiClient diff --git a/deploy/k8s/archived/helm/inf.yaml b/deploy/k8s/archived/helm/inf.yaml index 938be3d45..e73b37ee8 100644 --- a/deploy/k8s/archived/helm/inf.yaml +++ b/deploy/k8s/archived/helm/inf.yaml @@ -19,16 +19,8 @@ inf: db: OrderingDb # Ordering API SQL db name identity: db: IdentityDb # Ordering API SQL db name - marketing: - db: MarketingDb # Marketing API SQL db name webhooks: db: WebhooksDb # Webhooks DB - mongo: -# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used - locations: - database: LocationsDb - marketing: - database: MarketingDb redis: # inf.redis defines the redis' connection strings basket: svc: basket-data # Name of k8s svc for basket redis diff --git a/deploy/k8s/archived/helm/locations-api/.helmignore b/deploy/k8s/archived/helm/locations-api/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/deploy/k8s/archived/helm/locations-api/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/deploy/k8s/archived/helm/locations-api/Chart.yaml b/deploy/k8s/archived/helm/locations-api/Chart.yaml deleted file mode 100644 index 5126fe847..000000000 --- a/deploy/k8s/archived/helm/locations-api/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: locations-api -version: 0.1.0 diff --git a/deploy/k8s/archived/helm/locations-api/templates/NOTES.txt b/deploy/k8s/archived/helm/locations-api/templates/NOTES.txt deleted file mode 100644 index 3b48889bf..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/NOTES.txt +++ /dev/null @@ -1,9 +0,0 @@ -eShop Locations API installed. ------------------------------- - -This API is not directly exposed outside cluster. If need to access it use: - -export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "locations-api.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") -echo "Visit http://127.0.0.1:8080 to use your application" -kubectl port-forward $POD_NAME 8080:80 - diff --git a/deploy/k8s/archived/helm/locations-api/templates/_helpers.tpl b/deploy/k8s/archived/helm/locations-api/templates/_helpers.tpl deleted file mode 100644 index 086a461ba..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "locations-api.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "locations-api.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "locations-api.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/deploy/k8s/archived/helm/locations-api/templates/_names.tpl b/deploy/k8s/archived/helm/locations-api/templates/_names.tpl deleted file mode 100644 index d44859fea..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/_names.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{{- define "suffix-name" -}} -{{- if .Values.app.name -}} -{{- .Values.app.name -}} -{{- else -}} -{{- .Release.Name -}} -{{- end -}} -{{- end -}} - -{{- define "sql-name" -}} -{{- if .Values.inf.sql.host -}} -{{- .Values.inf.sql.host -}} -{{- else -}} -{{- printf "%s" "sql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "mongo-name" -}} -{{- if .Values.inf.mongo.host -}} -{{- .Values.inf.mongo.host -}} -{{- else -}} -{{- printf "%s" "nosql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "url-of" -}} -{{- $name := first .}} -{{- $ctx := last .}} -{{- if eq $name "" -}} -{{- $ctx.Values.inf.k8s.dns -}} -{{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} -{{- end -}} -{{- end -}} - - - -{{- define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} -{{- else -}} -{{- .Values.pathBase -}} -{{- end -}} -{{- end -}} - -{{- define "fqdn-image" -}} -{{- if .Values.inf.registry -}} -{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} -{{- else -}} -{{- .Values.image.repository -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/locations-api/templates/configmap.yaml b/deploy/k8s/archived/helm/locations-api/templates/configmap.yaml deleted file mode 100644 index c5d752509..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/configmap.yaml +++ /dev/null @@ -1,22 +0,0 @@ -{{- $name := include "locations-api.fullname" . -}} -{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} -{{- $mongo := include "mongo-name" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "cfg-{{ $name }}" - labels: - app: {{ template "locations-api.name" . }} - chart: {{ template "locations-api.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - all__EventBusConnection: {{ .Values.inf.eventbus.constr }} - all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" - internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} - urls__IdentityUrl: {{ $identity }} - locations__ConnectionString: mongodb://{{ $mongo }} - locations__Database: {{ .Values.inf.mongo.locations.database }} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/locations-api/templates/deployment.yaml b/deploy/k8s/archived/helm/locations-api/templates/deployment.yaml deleted file mode 100644 index 9a5bb608c..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/deployment.yaml +++ /dev/null @@ -1,96 +0,0 @@ -{{- $name := include "locations-api.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: {{ template "locations-api.fullname" . }} - labels: - ufo: {{ $cfgname}} - app: {{ template "locations-api.name" . }} - chart: {{ template "locations-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "locations-api.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "locations-api.name" . }} - release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} - annotations: - linkerd.io/inject: enabled - {{- end }} - spec: - {{ if .Values.inf.registry -}} - imagePullSecrets: - - name: {{ .Values.inf.registry.secretName }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - {{ if .Values.probes -}} - {{- if .Values.probes.liveness -}} - livenessProbe: - httpGet: - port: {{ .Values.probes.liveness.port }} - path: {{ .Values.probes.liveness.path }} - initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} - {{- end -}} - {{- end -}} - {{- if .Values.probes -}} - {{- if .Values.probes.readiness }} - readinessProbe: - httpGet: - port: {{ .Values.probes.readiness.port }} - path: {{ .Values.probes.readiness.path }} - initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} - timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} - {{- end -}} - {{- end }} - image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: PATH_BASE - value: {{ include "pathBase" . }} - - name: k8sname - value: {{ .Values.clusterName }} - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .key }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/deploy/k8s/archived/helm/locations-api/templates/service.yaml b/deploy/k8s/archived/helm/locations-api/templates/service.yaml deleted file mode 100644 index abd628beb..000000000 --- a/deploy/k8s/archived/helm/locations-api/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.app.svc.locations }} - labels: - app: {{ template "locations-api.name" . }} - chart: {{ template "locations-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app: {{ template "locations-api.name" . }} - release: {{ .Release.Name }} diff --git a/deploy/k8s/archived/helm/locations-api/values.yaml b/deploy/k8s/archived/helm/locations-api/values.yaml deleted file mode 100644 index 4718f2a0b..000000000 --- a/deploy/k8s/archived/helm/locations-api/values.yaml +++ /dev/null @@ -1,66 +0,0 @@ -replicaCount: 1 -clusterName: eshop-aks -pathBase: /locations-api - -image: - repository: eshop/locations.api - tag: latest - pullPolicy: IfNotPresent - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - tls: [] - -resources: {} - - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -# env defines the environment variables that will be declared in the pod -env: - urls: - # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). - configmap: - - name: ApplicationInsights__InstrumentationKey - key: all__InstrumentationKey - - name: EventBusConnection - key: all__EventBusConnection - - name: AzureServiceBusEnabled - key: all__UseAzureServiceBus - - name: UseLoadTest - key: all_EnableLoadTest - - name: IdentityUrl - key: internalurls__IdentityUrl - - name: IdentityUrlExternal - key: urls__IdentityUrl - - name: ConnectionString - key: locations__ConnectionString - - name: Database - key: locations__Database - # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) - values: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: OrchestratorType - value: 'K8S' -probes: - liveness: - path: /liveness - initialDelaySeconds: 10 - periodSeconds: 15 - port: 80 - readiness: - path: /hc - timeoutSeconds: 5 - initialDelaySeconds: 90 - periodSeconds: 60 - port: 80 diff --git a/deploy/k8s/archived/helm/marketing-api/.helmignore b/deploy/k8s/archived/helm/marketing-api/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/deploy/k8s/archived/helm/marketing-api/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/deploy/k8s/archived/helm/marketing-api/Chart.yaml b/deploy/k8s/archived/helm/marketing-api/Chart.yaml deleted file mode 100644 index 173f94fd6..000000000 --- a/deploy/k8s/archived/helm/marketing-api/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: marketing-api -version: 0.1.0 diff --git a/deploy/k8s/archived/helm/marketing-api/templates/NOTES.txt b/deploy/k8s/archived/helm/marketing-api/templates/NOTES.txt deleted file mode 100644 index 7fa66ed47..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/NOTES.txt +++ /dev/null @@ -1,9 +0,0 @@ -eShop Marketing API installed. ------------------------------- - -This API is not directly exposed outside cluster. If need to access it use: - -export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "marketing-api.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") -echo "Visit http://127.0.0.1:8080 to use your application" -kubectl port-forward $POD_NAME 8080:80 - diff --git a/deploy/k8s/archived/helm/marketing-api/templates/_helpers.tpl b/deploy/k8s/archived/helm/marketing-api/templates/_helpers.tpl deleted file mode 100644 index c252aeeac..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "marketing-api.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "marketing-api.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "marketing-api.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/deploy/k8s/archived/helm/marketing-api/templates/_names.tpl b/deploy/k8s/archived/helm/marketing-api/templates/_names.tpl deleted file mode 100644 index 605e92e7e..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/_names.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{{- define "suffix-name" -}} -{{- if .Values.app.name -}} -{{- .Values.app.name -}} -{{- else -}} -{{- .Release.Name -}} -{{- end -}} -{{- end -}} - -{{- define "sql-name" -}} -{{- if .Values.inf.sql.host -}} -{{- .Values.inf.sql.host -}} -{{- else -}} -{{- printf "%s" "sql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "mongo-name" -}} -{{- if .Values.inf.mongo.host -}} -{{- .Values.inf.mongo.host -}} -{{- else -}} -{{- printf "%s" "nosql-data" -}} -{{- end -}} -{{- end -}} - -{{- define "url-of" -}} -{{- $name := first .}} -{{- $ctx := last .}} -{{- if eq $name "" -}} -{{- $ctx.Values.inf.k8s.dns -}} -{{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} -{{- end -}} -{{- end -}} - - - -{{- define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} -{{- else -}} -{{- .Values.pathBase -}} -{{- end -}} -{{- end -}} - -{{- define "fqdn-image" -}} -{{- if .Values.inf.registry -}} -{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} -{{- else -}} -{{- .Values.image.repository -}} -{{- end -}} -{{- end -}} - -{{- define "protocol" -}} -{{- if .Values.inf.tls.enabled -}} -{{- printf "%s" "https" -}} -{{- else -}} -{{- printf "%s" "http" -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/marketing-api/templates/configmap.yaml b/deploy/k8s/archived/helm/marketing-api/templates/configmap.yaml deleted file mode 100644 index e6b495a7a..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/configmap.yaml +++ /dev/null @@ -1,27 +0,0 @@ -{{- $name := include "marketing-api.fullname" . -}} -{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} -{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} -{{- $mongo := include "mongo-name" . -}} -{{- $sqlsrv := include "sql-name" . -}} -{{- $protocol := include "protocol" . -}} - -apiVersion: v1 -kind: ConfigMap -metadata: - name: "cfg-{{ $name }}" - labels: - app: {{ template "marketing-api.name" . }} - chart: {{ template "marketing-api.chart" .}} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - all__EventBusConnection: {{ .Values.inf.eventbus.constr }} - all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" - internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} - urls__IdentityUrl: {{ $protocol }}://{{ $identity }} - marketing__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.marketing.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; - marketing__MongoConnectionString: mongodb://{{ $mongo }} - marketing__MongoDatabase: {{ .Values.inf.mongo.marketing.database }} - marketing__PicBaseUrl: {{ $protocol }}://{{ $webshoppingapigw }}/c/api/v1/catalog/items/[0]/pic/ \ No newline at end of file diff --git a/deploy/k8s/archived/helm/marketing-api/templates/deployment.yaml b/deploy/k8s/archived/helm/marketing-api/templates/deployment.yaml deleted file mode 100644 index 60d4cd1a3..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/deployment.yaml +++ /dev/null @@ -1,96 +0,0 @@ -{{- $name := include "marketing-api.fullname" . -}} -{{- $cfgname := printf "%s-%s" "cfg" $name -}} -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: {{ template "marketing-api.fullname" . }} - labels: - ufo: {{ $cfgname}} - app: {{ template "marketing-api.name" . }} - chart: {{ template "marketing-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app: {{ template "marketing-api.name" . }} - release: {{ .Release.Name }} - template: - metadata: - labels: - app: {{ template "marketing-api.name" . }} - release: {{ .Release.Name }} - {{ if .Values.inf.mesh.enabled -}} - annotations: - linkerd.io/inject: enabled - {{- end }} - spec: - {{ if .Values.inf.registry -}} - imagePullSecrets: - - name: {{ .Values.inf.registry.secretName }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - {{ if .Values.probes -}} - {{- if .Values.probes.liveness -}} - livenessProbe: - httpGet: - port: {{ .Values.probes.liveness.port }} - path: {{ .Values.probes.liveness.path }} - initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} - {{- end -}} - {{- end -}} - {{- if .Values.probes -}} - {{- if .Values.probes.readiness }} - readinessProbe: - httpGet: - port: {{ .Values.probes.readiness.port }} - path: {{ .Values.probes.readiness.path }} - initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} - timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }} - {{- end -}} - {{- end }} - image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: PATH_BASE - value: {{ include "pathBase" . }} - - name: k8sname - value: {{ .Values.clusterName }} - {{- if .Values.env.values -}} - {{- range .Values.env.values }} - - name: {{ .name }} - value: {{ .value | quote }} - {{- end -}} - {{- end -}} - {{- if .Values.env.configmap -}} - {{- range .Values.env.configmap }} - - name: {{ .name }} - valueFrom: - configMapKeyRef: - name: {{ $cfgname }} - key: {{ .key }} - {{- end -}} - {{- end }} - ports: - - name: http - containerPort: 80 - protocol: TCP - resources: -{{ toYaml .Values.resources | indent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} - {{- end }} - diff --git a/deploy/k8s/archived/helm/marketing-api/templates/service.yaml b/deploy/k8s/archived/helm/marketing-api/templates/service.yaml deleted file mode 100644 index 0e9bfbea2..000000000 --- a/deploy/k8s/archived/helm/marketing-api/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.app.svc.marketing }} - labels: - app: {{ template "marketing-api.name" . }} - chart: {{ template "marketing-api.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app: {{ template "marketing-api.name" . }} - release: {{ .Release.Name }} diff --git a/deploy/k8s/archived/helm/marketing-api/values.yaml b/deploy/k8s/archived/helm/marketing-api/values.yaml deleted file mode 100644 index 00bebf27f..000000000 --- a/deploy/k8s/archived/helm/marketing-api/values.yaml +++ /dev/null @@ -1,70 +0,0 @@ -replicaCount: 1 -clusterName: eshop-aks -pathBase: /marketing-api - -image: - repository: eshop/marketing.api - tag: latest - pullPolicy: IfNotPresent - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - tls: [] - -resources: {} - - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -# env defines the environment variables that will be declared in the pod -env: - urls: - # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). - configmap: - - name: ApplicationInsights__InstrumentationKey - key: all__InstrumentationKey - - name: EventBusConnection - key: all__EventBusConnection - - name: AzureServiceBusEnabled - key: all__UseAzureServiceBus - - name: UseLoadTest - key: all_EnableLoadTest - - name: IdentityUrl - key: internalurls__IdentityUrl - - name: IdentityUrlExternal - key: urls__IdentityUrl - - name: ConnectionString - key: marketing__ConnectionString - - name: MongoConnectionString - key: marketing__MongoConnectionString - - name: MongoDatabase - key: marketing__MongoDatabase - - name: PicBaseUrl - key: marketing__PicBaseUrl - # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) - values: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: OrchestratorType - value: 'K8S' -probes: - liveness: - path: /liveness - initialDelaySeconds: 10 - periodSeconds: 15 - port: 80 - readiness: - path: /hc - timeoutSeconds: 5 - initialDelaySeconds: 90 - periodSeconds: 60 - port: 80 diff --git a/deploy/k8s/archived/helm/mobileshoppingagg/templates/NOTES.txt b/deploy/k8s/archived/helm/mobileshoppingagg/templates/NOTES.txt index 61971f717..e7e5081ea 100644 --- a/deploy/k8s/archived/helm/mobileshoppingagg/templates/NOTES.txt +++ b/deploy/k8s/archived/helm/mobileshoppingagg/templates/NOTES.txt @@ -1,4 +1,4 @@ -eShop Mobile Marketing Aggregator is installed +eShop Mobile Shopping Aggregator is installed ---------------------------------------------- This API is not directly exposed outside cluster. If need to access it use: diff --git a/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml b/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml index 1ca69509f..6d3eeef4b 100644 --- a/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml @@ -21,9 +21,7 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc - internalurls__location__hc: http://{{ .Values.app.svc.locations }}/hc internalurls__grpcBasket: "http://{{ .Values.app.svc.basket }}:{{ .Values.service.grpcPort }}" internalurls__grpcCatalog: "http://{{ .Values.app.svc.catalog }}:{{ .Values.service.grpcPort }}" internalurls__grpcOrdering: "http://{{ .Values.app.svc.ordering }}:{{ .Values.service.grpcPort }}" diff --git a/deploy/k8s/archived/helm/mobileshoppingagg/values.yaml b/deploy/k8s/archived/helm/mobileshoppingagg/values.yaml index 844a59441..fc7ce7a38 100644 --- a/deploy/k8s/archived/helm/mobileshoppingagg/values.yaml +++ b/deploy/k8s/archived/helm/mobileshoppingagg/values.yaml @@ -49,12 +49,8 @@ env: key: internalurls__identity__hc - name: OrderingUrlHC key: internalurls__ordering__hc - - name: MarketingUrlHC - key: internalurls__marketing__hc - name: PaymentUrlHC key: internalurls__payment__hc - - name: LocationUrlHC - key: internalurls__location__hc - name: urls__grpcBasket key: internalurls__grpcBasket - name: urls__grpcCatalog diff --git a/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml b/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml index 2aa06fc7f..89b9faae0 100644 --- a/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml @@ -19,7 +19,6 @@ data: all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webmvc__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} - internalurls__apigwwm: http://{{ .Values.app.svc.webmarketingapigw }} internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc urls__apigwws: {{ $protocol }}://{{ $webshoppingapigw }} urls__mvc: {{ $protocol }}://{{ $mvc }} diff --git a/deploy/k8s/archived/helm/webmvc/values.yaml b/deploy/k8s/archived/helm/webmvc/values.yaml index 973f187f5..5db29dd01 100644 --- a/deploy/k8s/archived/helm/webmvc/values.yaml +++ b/deploy/k8s/archived/helm/webmvc/values.yaml @@ -44,8 +44,6 @@ env: key: urls__mvc - name: IdentityUrl key: urls__IdentityUrl - - name: MarketingUrl - key: internalurls__apigwwm - name: IdentityUrlHC key: internalurls__identity__hc - name: SignalrHubUrl diff --git a/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml b/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml index d01de8dcd..b1b07ffee 100644 --- a/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml @@ -21,9 +21,7 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc - internalurls__location__hc: http://{{ .Values.app.svc.locations }}/hc internalurls__grpcBasket: "http://{{ .Values.app.svc.basket }}:{{ .Values.service.grpcPort }}" internalurls__grpcCatalog: "http://{{ .Values.app.svc.catalog }}:{{ .Values.service.grpcPort }}" internalurls__grpcOrdering: "http://{{ .Values.app.svc.ordering }}:{{ .Values.service.grpcPort }}" diff --git a/deploy/k8s/archived/helm/webshoppingagg/values.yaml b/deploy/k8s/archived/helm/webshoppingagg/values.yaml index 15501c727..602dcf93a 100644 --- a/deploy/k8s/archived/helm/webshoppingagg/values.yaml +++ b/deploy/k8s/archived/helm/webshoppingagg/values.yaml @@ -49,12 +49,8 @@ env: key: internalurls__identity__hc - name: OrderingUrlHC key: internalurls__ordering__hc - - name: MarketingUrlHC - key: internalurls__marketing__hc - name: PaymentUrlHC key: internalurls__payment__hc - - name: LocationUrlHC - key: internalurls__location__hc - name: urls__grpcBasket key: internalurls__grpcBasket - name: urls__grpcCatalog diff --git a/deploy/k8s/archived/helm/webspa/templates/configmap.yaml b/deploy/k8s/archived/helm/webspa/templates/configmap.yaml index ecdbf8b63..353ff638f 100644 --- a/deploy/k8s/archived/helm/webspa/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webspa/templates/configmap.yaml @@ -1,7 +1,6 @@ {{- $name := include "webspa.fullname" . -}} {{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} {{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} -{{- $webmarketingapigw := include "url-of" (list .Values.app.ingress.entries.webmarketingapigw .) -}} {{- $spa := include "url-of" (list .Values.app.ingress.entries.spa .) -}} {{- $mongo := include "mongo-name" . -}} {{- $protocol := include "protocol" . -}} @@ -23,5 +22,4 @@ data: internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc urls__apigwws: {{ $protocol }}://{{ $webshoppingapigw }} urls__spa: {{ $protocol }}://{{ $spa }} - urls__IdentityUrl: {{ $protocol }}://{{ $identity }} - urls__apigwwm: {{ $protocol }}://{{ $webmarketingapigw }} \ No newline at end of file + urls__IdentityUrl: {{ $protocol }}://{{ $identity }} \ No newline at end of file diff --git a/deploy/k8s/archived/helm/webspa/values.yaml b/deploy/k8s/archived/helm/webspa/values.yaml index e1547ed39..4a7eea52b 100644 --- a/deploy/k8s/archived/helm/webspa/values.yaml +++ b/deploy/k8s/archived/helm/webspa/values.yaml @@ -42,8 +42,6 @@ env: key: urls__spa - name: IdentityUrl key: urls__IdentityUrl - - name: MarketingUrl - key: urls__apigwwm - name: IdentityUrlHC key: internalurls__identity__hc - name: SignalrHubUrl diff --git a/deploy/k8s/archived/helm/webstatus/templates/configmap.yaml b/deploy/k8s/archived/helm/webstatus/templates/configmap.yaml index bf40d2a7d..b53864602 100644 --- a/deploy/k8s/archived/helm/webstatus/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webstatus/templates/configmap.yaml @@ -24,12 +24,8 @@ data: internalurls__spa__hc: http://{{ .Values.app.svc.spa }}/hc name__apigwws__hc: Web Shopping API GW HTTP Check internalurls__apigwws__hc: http://{{ .Values.app.svc.webshoppingapigw }}:8001/ready - name__apigwwm__hc: Web Marketing API GW HTTP Check - internalurls__apigwwm__hc: http://{{ .Values.app.svc.webmarketingapigw }}:8001/ready name__apigwms__hc: Mobile Shopping API GW HTTP Check internalurls__apigwms__hc: http://{{ .Values.app.svc.mobileshoppingapigw }}:8001/ready - name__apigwmm__hc: Mobile Marketing API GW HTTP Check - internalurls__apigwmm__hc: http://{{ .Values.app.svc.mobilemarketingapigw }}:8001/ready name__apigwwsagg__hc: Web Shopping Aggregator GW HTTP Check internalurls__apigwwsagg__hc: http://{{ .Values.app.svc.webshoppingagg }}/hc name__apigwmsagg__hc: Mobile Shopping Aggregator HTTP Check @@ -44,10 +40,6 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc name__identity__hc: Identity HTTP Check internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc - name__marketing__hc: Marketing HTTP Check - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc - name__locations__hc: Locations HTTP Check - internalurls__locations__hc: http://{{ .Values.app.svc.locations }}/hc name__payment__hc: Payment HTTP Check internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc name__signalrhub__hc: Ordering SignalR Hub HTTP Check diff --git a/deploy/k8s/archived/helm/webstatus/values.yaml b/deploy/k8s/archived/helm/webstatus/values.yaml index e5a23ec85..1ce23fec3 100644 --- a/deploy/k8s/archived/helm/webstatus/values.yaml +++ b/deploy/k8s/archived/helm/webstatus/values.yaml @@ -67,24 +67,16 @@ env: - name: HealthChecks-UI__HealthChecks__7__Uri key: internalurls__identity__hc - name: HealthChecks-UI__HealthChecks__8__Name - key: name__marketing__hc - - name: HealthChecks-UI__HealthChecks__8__Uri - key: internalurls__marketing__hc - - name: HealthChecks-UI__HealthChecks__9__Name - key: name__locations__hc - - name: HealthChecks-UI__HealthChecks__9__Uri - key: internalurls__locations__hc - - name: HealthChecks-UI__HealthChecks__10__Name key: name__payment__hc - - name: HealthChecks-UI__HealthChecks__10__Uri + - name: HealthChecks-UI__HealthChecks__8__Uri key: internalurls__payment__hc - - name: HealthChecks-UI__HealthChecks__11__Name + - name: HealthChecks-UI__HealthChecks__9__Name key: name__signalrhub__hc - - name: HealthChecks-UI__HealthChecks__11__Uri + - name: HealthChecks-UI__HealthChecks__9__Uri key: internalurls__signalrhub__hc - - name: HealthChecks-UI__HealthChecks__12__Name + - name: HealthChecks-UI__HealthChecks__10__Name key: name__orderingbackground__hc - - name: HealthChecks-UI__HealthChecks__12__Uri + - name: HealthChecks-UI__HealthChecks__10__Uri key: internalurls__orderingbackground__hc # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) diff --git a/deploy/k8s/helm/app.yaml b/deploy/k8s/helm/app.yaml index e83ea2823..acea31ef1 100644 --- a/deploy/k8s/helm/app.yaml +++ b/deploy/k8s/helm/app.yaml @@ -13,14 +13,10 @@ app: # app global settings spa: "" # ingress entry for web spa status: webstatus # ingress entry for web status webshoppingapigw: webshoppingapigw # ingress entry for web shopping Agw - webmarketingapigw: webmarketingapigw # ingress entry for web mkg Agw - mobilemarketingapigw: mobilemarketingapigw # ingress entry for mobile mkg Agw mobileshoppingapigw: mobileshoppingapigw # ingress entry for mobile shopping Agw webshoppingagg: webshoppingagg # ingress entry for web shopping aggregator mobileshoppingagg: mobileshoppingagg # ingress entry for mobile shopping aggregator payment: payment-api # ingress entry for payment api - locations: locations-api # ingress entry for locations api - marketing: marketing-api # ingress entry for marketing api webhooks: webhooks-api # ingress entry for webhooks api webhooksweb: webhooks-web # ingress entry for webhooks web demo client svc: @@ -34,13 +30,9 @@ app: # app global settings spa: webspa # service name for web spa status: webstatus # service name for web status webshoppingapigw: webshoppingapigw # service name for web shopping Agw - webmarketingapigw: webmarketingapigw # service name for web mkg Agw - mobilemarketingapigw: mobilemarketingapigw # service name for mobile mkg Agw mobileshoppingapigw: mobileshoppingapigw # service name for mobile shopping Agw webshoppingagg: webshoppingagg # service name for web shopping aggregator mobileshoppingagg: mobileshoppingagg # service name for mobile shopping aggregator payment: payment-api # service name for payment api - locations: locations-api # service name for locations api - marketing: marketing-api # service name for marketing ap webhooks: webhooks-api # service name for webhooks api webhooksweb: webhooks-client # service name for webhooks web diff --git a/deploy/k8s/helm/deploy-all-mac.ps1 b/deploy/k8s/helm/deploy-all-mac.ps1 index c74b7e05e..3de7dc6c6 100644 --- a/deploy/k8s/helm/deploy-all-mac.ps1 +++ b/deploy/k8s/helm/deploy-all-mac.ps1 @@ -120,8 +120,8 @@ if (-not [string]::IsNullOrEmpty($registry)) { Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green $infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data") -$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") -$gateways = ("apigwmm", "apigwms", "apigwwm", "apigwws") +$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") +$gateways = ("apigwms", "apigwws") if ($deployInfrastructure) { foreach ($infra in $infras) { diff --git a/deploy/k8s/helm/deploy-all.ps1 b/deploy/k8s/helm/deploy-all.ps1 index da0424195..213e60fb7 100644 --- a/deploy/k8s/helm/deploy-all.ps1 +++ b/deploy/k8s/helm/deploy-all.ps1 @@ -119,8 +119,8 @@ if (-not [string]::IsNullOrEmpty($registry)) { Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green $infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data") -$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") -$gateways = ("apigwmm", "apigwms", "apigwwm", "apigwws") +$charts = ("eshop-common", "basket-api","catalog-api", "identity-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web") +$gateways = ("apigwms", "apigwws") if ($deployInfrastructure) { foreach ($infra in $infras) { diff --git a/deploy/k8s/helm/deploy-all.sh b/deploy/k8s/helm/deploy-all.sh index bf07105ef..4b4c8eafd 100644 --- a/deploy/k8s/helm/deploy-all.sh +++ b/deploy/k8s/helm/deploy-all.sh @@ -142,7 +142,7 @@ fi if [[ $push_images ]]; then echo "#################### Pushing images to the container registry ####################" - services=(basket.api catalog.api identity.api ordering.api marketing.api payment.api locations.api webmvc webspa webstatus) + services=(basket.api catalog.api identity.api ordering.api payment.api webmvc webspa webstatus) if [[ -z "$(docker image ls -q --filter=reference=eshop/$service:$image_tag)" ]]; then image_tag=linux-$image_tag @@ -209,7 +209,7 @@ fi echo "#################### Begin $app_name installation using Helm ####################" infras=(sql-data nosql-data rabbitmq keystore-data basket-data) -charts=(eshop-common apigwmm apigwms apigwwm apigwws basket-api catalog-api identity-api locations-api marketing-api mobileshoppingagg ordering-api ordering-backgroundtasks ordering-signalrhub payment-api webmvc webshoppingagg webspa webstatus webhooks-api webhooks-web) +charts=(eshop-common apigwms apigwws basket-api catalog-api identity-api mobileshoppingagg ordering-api ordering-backgroundtasks ordering-signalrhub payment-api webmvc webshoppingagg webspa webstatus webhooks-api webhooks-web) if [[ !$skip_infrastructure ]]; then for infra in "${infras[@]}" diff --git a/deploy/k8s/helm/identity-api/templates/configmap.yaml b/deploy/k8s/helm/identity-api/templates/configmap.yaml index 264ceb745..7c670f646 100644 --- a/deploy/k8s/helm/identity-api/templates/configmap.yaml +++ b/deploy/k8s/helm/identity-api/templates/configmap.yaml @@ -2,8 +2,6 @@ {{- $sqlsrv := include "sql-name" . -}} {{- $mvc_url := include "url-of" (list .Values.app.ingress.entries.mvc .) -}} {{- $spa_url := include "url-of" (list .Values.app.ingress.entries.spa .) -}} -{{- $locations_url := include "url-of" (list .Values.app.ingress.entries.locations .) -}} -{{- $marketing_url := include "url-of" (list .Values.app.ingress.entries.marketing .) -}} {{- $basket_url := include "url-of" (list .Values.app.ingress.entries.basket .) -}} {{- $ordering_url := include "url-of" (list .Values.app.ingress.entries.ordering .) -}} {{- $mobileshoppingagg := include "url-of" (list .Values.app.ingress.entries.mobileshoppingagg .) -}} @@ -27,8 +25,6 @@ data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" mvc_e: http://{{ $mvc_url }} spa_e: http://{{ $spa_url }} - locations_e: http://{{ $locations_url }} - marketing_e: http://{{ $marketing_url }} basket_e: http://{{ $basket_url }} ordering_e: http://{{ $ordering_url }} mobileshoppingagg_e: http://{{ $mobileshoppingagg }} diff --git a/deploy/k8s/helm/identity-api/values.yaml b/deploy/k8s/helm/identity-api/values.yaml index 7b57dfde1..92fd57283 100644 --- a/deploy/k8s/helm/identity-api/values.yaml +++ b/deploy/k8s/helm/identity-api/values.yaml @@ -40,10 +40,6 @@ env: key: mvc_e - name: SpaClient key: spa_e - - name: LocationApiClient - key: locations_e - - name: MarketingApiClient - key: marketing_e - name: BasketApiClient key: basket_e - name: OrderingApiClient diff --git a/deploy/k8s/helm/inf.yaml b/deploy/k8s/helm/inf.yaml index 938be3d45..e73b37ee8 100644 --- a/deploy/k8s/helm/inf.yaml +++ b/deploy/k8s/helm/inf.yaml @@ -19,16 +19,8 @@ inf: db: OrderingDb # Ordering API SQL db name identity: db: IdentityDb # Ordering API SQL db name - marketing: - db: MarketingDb # Marketing API SQL db name webhooks: db: WebhooksDb # Webhooks DB - mongo: -# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used - locations: - database: LocationsDb - marketing: - database: MarketingDb redis: # inf.redis defines the redis' connection strings basket: svc: basket-data # Name of k8s svc for basket redis diff --git a/deploy/k8s/helm/mobileshoppingagg/templates/NOTES.txt b/deploy/k8s/helm/mobileshoppingagg/templates/NOTES.txt index 61971f717..e7e5081ea 100644 --- a/deploy/k8s/helm/mobileshoppingagg/templates/NOTES.txt +++ b/deploy/k8s/helm/mobileshoppingagg/templates/NOTES.txt @@ -1,4 +1,4 @@ -eShop Mobile Marketing Aggregator is installed +eShop Mobile Shopping Aggregator is installed ---------------------------------------------- This API is not directly exposed outside cluster. If need to access it use: diff --git a/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml b/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml index 1ca69509f..6d3eeef4b 100644 --- a/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml @@ -21,9 +21,7 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc - internalurls__location__hc: http://{{ .Values.app.svc.locations }}/hc internalurls__grpcBasket: "http://{{ .Values.app.svc.basket }}:{{ .Values.service.grpcPort }}" internalurls__grpcCatalog: "http://{{ .Values.app.svc.catalog }}:{{ .Values.service.grpcPort }}" internalurls__grpcOrdering: "http://{{ .Values.app.svc.ordering }}:{{ .Values.service.grpcPort }}" diff --git a/deploy/k8s/helm/mobileshoppingagg/values.yaml b/deploy/k8s/helm/mobileshoppingagg/values.yaml index 844a59441..fc7ce7a38 100644 --- a/deploy/k8s/helm/mobileshoppingagg/values.yaml +++ b/deploy/k8s/helm/mobileshoppingagg/values.yaml @@ -49,12 +49,8 @@ env: key: internalurls__identity__hc - name: OrderingUrlHC key: internalurls__ordering__hc - - name: MarketingUrlHC - key: internalurls__marketing__hc - name: PaymentUrlHC key: internalurls__payment__hc - - name: LocationUrlHC - key: internalurls__location__hc - name: urls__grpcBasket key: internalurls__grpcBasket - name: urls__grpcCatalog diff --git a/deploy/k8s/helm/webmvc/templates/configmap.yaml b/deploy/k8s/helm/webmvc/templates/configmap.yaml index 2aa06fc7f..89b9faae0 100644 --- a/deploy/k8s/helm/webmvc/templates/configmap.yaml +++ b/deploy/k8s/helm/webmvc/templates/configmap.yaml @@ -19,7 +19,6 @@ data: all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webmvc__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} - internalurls__apigwwm: http://{{ .Values.app.svc.webmarketingapigw }} internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc urls__apigwws: {{ $protocol }}://{{ $webshoppingapigw }} urls__mvc: {{ $protocol }}://{{ $mvc }} diff --git a/deploy/k8s/helm/webmvc/values.yaml b/deploy/k8s/helm/webmvc/values.yaml index 973f187f5..5db29dd01 100644 --- a/deploy/k8s/helm/webmvc/values.yaml +++ b/deploy/k8s/helm/webmvc/values.yaml @@ -44,8 +44,6 @@ env: key: urls__mvc - name: IdentityUrl key: urls__IdentityUrl - - name: MarketingUrl - key: internalurls__apigwwm - name: IdentityUrlHC key: internalurls__identity__hc - name: SignalrHubUrl diff --git a/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml b/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml index d01de8dcd..b1b07ffee 100644 --- a/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml @@ -21,9 +21,7 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc - internalurls__location__hc: http://{{ .Values.app.svc.locations }}/hc internalurls__grpcBasket: "http://{{ .Values.app.svc.basket }}:{{ .Values.service.grpcPort }}" internalurls__grpcCatalog: "http://{{ .Values.app.svc.catalog }}:{{ .Values.service.grpcPort }}" internalurls__grpcOrdering: "http://{{ .Values.app.svc.ordering }}:{{ .Values.service.grpcPort }}" diff --git a/deploy/k8s/helm/webshoppingagg/values.yaml b/deploy/k8s/helm/webshoppingagg/values.yaml index 15501c727..602dcf93a 100644 --- a/deploy/k8s/helm/webshoppingagg/values.yaml +++ b/deploy/k8s/helm/webshoppingagg/values.yaml @@ -49,12 +49,8 @@ env: key: internalurls__identity__hc - name: OrderingUrlHC key: internalurls__ordering__hc - - name: MarketingUrlHC - key: internalurls__marketing__hc - name: PaymentUrlHC key: internalurls__payment__hc - - name: LocationUrlHC - key: internalurls__location__hc - name: urls__grpcBasket key: internalurls__grpcBasket - name: urls__grpcCatalog diff --git a/deploy/k8s/helm/webspa/templates/configmap.yaml b/deploy/k8s/helm/webspa/templates/configmap.yaml index ecdbf8b63..353ff638f 100644 --- a/deploy/k8s/helm/webspa/templates/configmap.yaml +++ b/deploy/k8s/helm/webspa/templates/configmap.yaml @@ -1,7 +1,6 @@ {{- $name := include "webspa.fullname" . -}} {{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} {{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} -{{- $webmarketingapigw := include "url-of" (list .Values.app.ingress.entries.webmarketingapigw .) -}} {{- $spa := include "url-of" (list .Values.app.ingress.entries.spa .) -}} {{- $mongo := include "mongo-name" . -}} {{- $protocol := include "protocol" . -}} @@ -23,5 +22,4 @@ data: internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc urls__apigwws: {{ $protocol }}://{{ $webshoppingapigw }} urls__spa: {{ $protocol }}://{{ $spa }} - urls__IdentityUrl: {{ $protocol }}://{{ $identity }} - urls__apigwwm: {{ $protocol }}://{{ $webmarketingapigw }} \ No newline at end of file + urls__IdentityUrl: {{ $protocol }}://{{ $identity }} \ No newline at end of file diff --git a/deploy/k8s/helm/webspa/values.yaml b/deploy/k8s/helm/webspa/values.yaml index e1547ed39..4a7eea52b 100644 --- a/deploy/k8s/helm/webspa/values.yaml +++ b/deploy/k8s/helm/webspa/values.yaml @@ -42,8 +42,6 @@ env: key: urls__spa - name: IdentityUrl key: urls__IdentityUrl - - name: MarketingUrl - key: urls__apigwwm - name: IdentityUrlHC key: internalurls__identity__hc - name: SignalrHubUrl diff --git a/deploy/k8s/helm/webstatus/templates/configmap.yaml b/deploy/k8s/helm/webstatus/templates/configmap.yaml index bf40d2a7d..b53864602 100644 --- a/deploy/k8s/helm/webstatus/templates/configmap.yaml +++ b/deploy/k8s/helm/webstatus/templates/configmap.yaml @@ -24,12 +24,8 @@ data: internalurls__spa__hc: http://{{ .Values.app.svc.spa }}/hc name__apigwws__hc: Web Shopping API GW HTTP Check internalurls__apigwws__hc: http://{{ .Values.app.svc.webshoppingapigw }}:8001/ready - name__apigwwm__hc: Web Marketing API GW HTTP Check - internalurls__apigwwm__hc: http://{{ .Values.app.svc.webmarketingapigw }}:8001/ready name__apigwms__hc: Mobile Shopping API GW HTTP Check internalurls__apigwms__hc: http://{{ .Values.app.svc.mobileshoppingapigw }}:8001/ready - name__apigwmm__hc: Mobile Marketing API GW HTTP Check - internalurls__apigwmm__hc: http://{{ .Values.app.svc.mobilemarketingapigw }}:8001/ready name__apigwwsagg__hc: Web Shopping Aggregator GW HTTP Check internalurls__apigwwsagg__hc: http://{{ .Values.app.svc.webshoppingagg }}/hc name__apigwmsagg__hc: Mobile Shopping Aggregator HTTP Check @@ -44,10 +40,6 @@ data: internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc name__identity__hc: Identity HTTP Check internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc - name__marketing__hc: Marketing HTTP Check - internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc - name__locations__hc: Locations HTTP Check - internalurls__locations__hc: http://{{ .Values.app.svc.locations }}/hc name__payment__hc: Payment HTTP Check internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc name__signalrhub__hc: Ordering SignalR Hub HTTP Check diff --git a/deploy/k8s/helm/webstatus/values.yaml b/deploy/k8s/helm/webstatus/values.yaml index e5a23ec85..1ce23fec3 100644 --- a/deploy/k8s/helm/webstatus/values.yaml +++ b/deploy/k8s/helm/webstatus/values.yaml @@ -67,24 +67,16 @@ env: - name: HealthChecks-UI__HealthChecks__7__Uri key: internalurls__identity__hc - name: HealthChecks-UI__HealthChecks__8__Name - key: name__marketing__hc - - name: HealthChecks-UI__HealthChecks__8__Uri - key: internalurls__marketing__hc - - name: HealthChecks-UI__HealthChecks__9__Name - key: name__locations__hc - - name: HealthChecks-UI__HealthChecks__9__Uri - key: internalurls__locations__hc - - name: HealthChecks-UI__HealthChecks__10__Name key: name__payment__hc - - name: HealthChecks-UI__HealthChecks__10__Uri + - name: HealthChecks-UI__HealthChecks__8__Uri key: internalurls__payment__hc - - name: HealthChecks-UI__HealthChecks__11__Name + - name: HealthChecks-UI__HealthChecks__9__Name key: name__signalrhub__hc - - name: HealthChecks-UI__HealthChecks__11__Uri + - name: HealthChecks-UI__HealthChecks__9__Uri key: internalurls__signalrhub__hc - - name: HealthChecks-UI__HealthChecks__12__Name + - name: HealthChecks-UI__HealthChecks__10__Name key: name__orderingbackground__hc - - name: HealthChecks-UI__HealthChecks__12__Uri + - name: HealthChecks-UI__HealthChecks__10__Uri key: internalurls__orderingbackground__hc # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) diff --git a/obsolete/readme/README.ENV.md b/obsolete/readme/README.ENV.md index bdb436a1a..037a01ebc 100644 --- a/obsolete/readme/README.ENV.md +++ b/obsolete/readme/README.ENV.md @@ -16,39 +16,35 @@ To enable the service bus of Azure in eShop solution it is necessary having crea For example: >ESHOP_AZURE_SERVICE_BUS=Endpoint=sb://yourservicebusservice.servicebus.windows.net/;SharedAccessKeyName=Root;SharedAccessKey=yourtopicpolicykey=;EntityPath=eshop_event_bus -Once the service bus service is created, it is necessary to set to true the "AzureServiceBusEnabled" environment variable from `settings.json` file on Catalog.API, Ordering.API, Basket.API, Payment.API, GracePeriodManager, Marketing.API and Locations.API. +Once the service bus service is created, it is necessary to set to true the "AzureServiceBusEnabled" environment variable from `settings.json` file on Catalog.API, Ordering.API, Basket.API, Payment.API and GracePeriodManager. With the steps explained in the next section, you will be able to run the application with Azure Storage Account instead of the local container storage. # Azure Storage Account service -To enable Azure storage of Azure in eShopOnAzure solution it is necessary having created previously the storage service through ARM file or manually through Azure portal. You can use the ARM files find under **deploy/az/storage** folder already created in eShop. Once the storage account is created, it is very important to create a new container(blob kind) and upload the solution catalog pics files before to continue.Later, it is necessary to set to true the "AzureStorageEnabled" environment variable from `settings.json` in Catalog.API and Marketing.API.Finally, it is necessary to get the container endpoint url from information service in the Azure portal, This url must be declared on .env file located in the solution root folder with `ESHOP_AZURE_STORAGE_CATALOG` for the Catalog.API content and `ESHOP_AZURE_STORAGE_MARKETING` for the Marketing.API content. +To enable Azure storage of Azure in eShopOnAzure solution it is necessary having created previously the storage service through ARM file or manually through Azure portal. You can use the ARM files find under **deploy/az/storage** folder already created in eShop. Once the storage account is created, it is very important to create a new container(blob kind) and upload the solution catalog pics files before to continue.Later, it is necessary to set to true the "AzureStorageEnabled" environment variable from `settings.json` in Catalog.API.Finally, it is necessary to get the container endpoint url from information service in the Azure portal, This url must be declared on .env file located in the solution root folder with `ESHOP_AZURE_STORAGE_CATALOG` for the Catalog.API content. Do not forget to put a slash character '/' in the end of the url. For example: >ESHOP_AZURE_STORAGE_CATALOG=https://yourcatalogstorageaccountservice.blob.core.windows.net/yourcontainername/ ->ESHOP_AZURE_STORAGE_MARKETING=https://yourmarketingstorageaccountservice.blob.core.windows.net/yourcontainername/ ## Check status of Azure Storage Account with Health Checks -It is possible to add status check for the Azure Storage Account inside the Catalog Web Status. In case that the status check is enabled, for the Catalog and/or Marketing section in the WebStatus page, Azure Storage will be checked as one of the dependencies for theses APIs. To enable this check add the account name and key to the .env file for your account. +It is possible to add status check for the Azure Storage Account inside the Catalog Web Status. In case that the status check is enabled, for the Catalog section in the WebStatus page, Azure Storage will be checked as one of the dependencies for theses APIs. To enable this check add the account name and key to the .env file for your account. For example: >ESHOP_AZURE_STORAGE_CATALOG_NAME=storageaccountname >ESHOP_AZURE_STORAGE_CATALOG_KEY=storageaccountkey ->ESHOP_AZURE_STORAGE_MARKETING_NAME=storageaccountname ->ESHOP_AZURE_STORAGE_MARKETING_KEY=storageaccountkey With the steps explained in the next section, you will be able to run the application with Azure SQL Database instead of local storage. # Azure SQL Database -To enable Azure SQL Database in eShop is required to have a Azure SQL with the databases for Ordering.API, Identity.API, Catalaog.API and Marketing.API. You can use the [ARM files](deploy/az/sql/readme.md) already created in this project or do it manually. Once the databases are created, it is necessary to get the connection string for each service and set the corresponding variable in the .env file. +To enable Azure SQL Database in eShop is required to have a Azure SQL with the databases for Ordering.API, Identity.API, Catalaog.API. You can use the [ARM files](deploy/az/sql/readme.md) already created in this project or do it manually. Once the databases are created, it is necessary to get the connection string for each service and set the corresponding variable in the .env file. For example: >ESHOP_AZURE_CATALOG_DB=catalogazureconnectionstring >ESHOP_AZURE_IDENTITY_DB=identityazureconnectionstring >ESHOP_AZURE_ORDERING_DB=orderingazureconnectionstring ->ESHOP_AZURE_MARKETING_DB=marketingazureconnectionstring With the steps explained in the next section, you will be able to run the application with Azure Cosmos DB Database instead of local storage. @@ -61,7 +57,5 @@ For example: # Azure Functions To enable the Azure Functions in eShop you can add the URI where the functions have been deployed. You can use the ARM files under **deploy/az/azurefunctions** to create the resources in Azure. Once created and available, it is necessary to add to the .env file the `ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI` variable. -For example: - >ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI=https://marketing-functions.azurewebsites.net/api/MarketingDetailsHttpTrigger?code=AzureFunctioncode See Azure Functions deployment Files and Readme for more details [ARM files](deploy/az/azurefunctions/readme.md) \ No newline at end of file diff --git a/obsolete/readme/readme-docker-compose.md b/obsolete/readme/readme-docker-compose.md index 882630682..c9f48b52c 100644 --- a/obsolete/readme/readme-docker-compose.md +++ b/obsolete/readme/readme-docker-compose.md @@ -27,7 +27,6 @@ When using this file the following environments variables must be set: * `ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP` with the IP or DNS name of the docker host that runs the services (can use `localhost` if needed). * `ESHOP_AZURE_STORAGE_CATALOG` with the URL of the Azure Storage that will host the catalog images -* `ESHOP_AZURE_STORAGE_MARKETING` with the URL of the Azure Storage that will host the marketing campaign images You might wonder why an external image resource (storage) is needed when using `docker-compose.prod.yml` instead of `docker-compose.override.yml`. Answer to this is related to a limitation of Docker Compose file format. This is how we set the environment configuration of Catalog microservice in `docker-compose.override.yml`: diff --git a/src/.dockerignore b/src/.dockerignore index 2cec0e7b0..dc9d4af2c 100644 --- a/src/.dockerignore +++ b/src/.dockerignore @@ -20,5 +20,4 @@ Web/WebSPA/wwwroot/ packages/ test-results/ TestResults/ -Mobile/ -Services/Marketing/Infrastructure/ \ No newline at end of file +Mobile/ \ No newline at end of file diff --git a/src/.env b/src/.env index 96b801650..d65bdbbf6 100644 --- a/src/.env +++ b/src/.env @@ -7,21 +7,17 @@ # Use this values to run the app locally in Windows ESHOP_EXTERNAL_DNS_NAME_OR_IP=host.docker.internal ESHOP_STORAGE_CATALOG_URL=http://host.docker.internal:5202/c/api/v1/catalog/items/[0]/pic/ -ESHOP_STORAGE_MARKETING_URL=http://host.docker.internal:5110/api/v1/campaigns/[0]/pic/ # Use this values to run the app locally in Mac # ESHOP_EXTERNAL_DNS_NAME_OR_IP=docker.for.mac.localhost # ESHOP_STORAGE_CATALOG_URL=http://docker.for.mac.localhost:5202/c/api/v1/catalog/items/[0]/pic/ -# ESHOP_STORAGE_MARKETING_URL=http://docker.for.mac.localhost:5110/api/v1/campaigns/[0]/pic/ # Use this values to run the app locally in Linux # ESHOP_EXTERNAL_DNS_NAME_OR_IP=docker.for.linux.localhost # ESHOP_STORAGE_CATALOG_URL=http://docker.for.linux.localhost:5202/c/api/v1/catalog/items/[0]/pic/ -# ESHOP_STORAGE_MARKETING_URL=http://docker.for.linux.localhost:5110/api/v1/campaigns/[0]/pic/ # Configure this values to the cloud storage locations # ESHOP_STORAGE_CATALOG_URL= -# ESHOP_STORAGE_MARKETING_URL= ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.162 @@ -31,12 +27,9 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.162 #ESHOP_AZURE_CATALOG_DB= #ESHOP_AZURE_IDENTITY_DB= #ESHOP_AZURE_ORDERING_DB= -#ESHOP_AZURE_MARKETING_DB= #ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI= #ESHOP_AZURE_STORAGE_CATALOG_NAME= #ESHOP_AZURE_STORAGE_CATALOG_KEY= -#ESHOP_AZURE_STORAGE_MARKETING_NAME= -#ESHOP_AZURE_STORAGE_MARKETING_KEY= #ESHOP_SERVICE_BUS_USERNAME= #ESHOP_SERVICE_BUS_PASSWORD= #INSTRUMENTATION_KEY= diff --git a/src/DockerfileSolutionRestore.txt b/src/DockerfileSolutionRestore.txt index 006f664d8..040bf761e 100644 Binary files a/src/DockerfileSolutionRestore.txt and b/src/DockerfileSolutionRestore.txt differ diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 04a9aa043..22c3c9b7b 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -13,8 +13,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { new ApiResource("orders", "Orders Service"), new ApiResource("basket", "Basket Service"), - new ApiResource("marketing", "Marketing Service"), - new ApiResource("locations", "Locations Service"), new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), new ApiResource("webshoppingagg", "Web Shopping Aggregator"), new ApiResource("orders.signalrhub", "Ordering Signalr Hub"), @@ -55,8 +53,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration IdentityServerConstants.StandardScopes.Profile, "orders", "basket", - "locations", - "marketing", "webshoppingagg", "orders.signalrhub", "webhooks" @@ -84,8 +80,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration IdentityServerConstants.StandardScopes.OfflineAccess, "orders", "basket", - "locations", - "marketing", "mobileshoppingagg", "webhooks" }, @@ -122,8 +116,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration IdentityServerConstants.StandardScopes.OfflineAccess, "orders", "basket", - "locations", - "marketing", "webshoppingagg", "orders.signalrhub", "webhooks" @@ -191,43 +183,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration IdentityServerConstants.StandardScopes.OfflineAccess, "orders", "basket", - "locations", - "marketing", "webshoppingagg", "webhooks" }, }, new Client - { - ClientId = "locationsswaggerui", - ClientName = "Locations Swagger UI", - AllowedGrantTypes = GrantTypes.Implicit, - AllowAccessTokensViaBrowser = true, - - RedirectUris = { $"{clientsUrl["LocationsApi"]}/swagger/oauth2-redirect.html" }, - PostLogoutRedirectUris = { $"{clientsUrl["LocationsApi"]}/swagger/" }, - - AllowedScopes = - { - "locations" - } - }, - new Client - { - ClientId = "marketingswaggerui", - ClientName = "Marketing Swagger UI", - AllowedGrantTypes = GrantTypes.Implicit, - AllowAccessTokensViaBrowser = true, - - RedirectUris = { $"{clientsUrl["MarketingApi"]}/swagger/oauth2-redirect.html" }, - PostLogoutRedirectUris = { $"{clientsUrl["MarketingApi"]}/swagger/" }, - - AllowedScopes = - { - "marketing" - } - }, - new Client { ClientId = "basketswaggerui", ClientName = "Basket Swagger UI", diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index 653c6fded..dd8ed9bd2 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -22,8 +22,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data clientUrls.Add("Mvc", configuration.GetValue("MvcClient")); clientUrls.Add("Spa", configuration.GetValue("SpaClient")); clientUrls.Add("Xamarin", configuration.GetValue("XamarinCallback")); - clientUrls.Add("LocationsApi", configuration.GetValue("LocationApiClient")); - clientUrls.Add("MarketingApi", configuration.GetValue("MarketingApiClient")); clientUrls.Add("BasketApi", configuration.GetValue("BasketApiClient")); clientUrls.Add("OrderingApi", configuration.GetValue("OrderingApiClient")); clientUrls.Add("MobileShoppingAgg", configuration.GetValue("MobileShoppingAggClient")); diff --git a/src/Services/Location/Locations.API/Controllers/HomeController.cs b/src/Services/Location/Locations.API/Controllers/HomeController.cs deleted file mode 100644 index 15cb07404..000000000 --- a/src/Services/Location/Locations.API/Controllers/HomeController.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace Microsoft.eShopOnContainers.Services.Locations.API.Controllers -{ - public class HomeController : Controller - { - // GET: // - public IActionResult Index() - { - return new RedirectResult("~/swagger"); - } - } -} diff --git a/src/Services/Location/Locations.API/Controllers/LocationsController.cs b/src/Services/Location/Locations.API/Controllers/LocationsController.cs deleted file mode 100644 index a9cbae1c2..000000000 --- a/src/Services/Location/Locations.API/Controllers/LocationsController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services; -using Microsoft.eShopOnContainers.Services.Locations.API.Model; -using Microsoft.eShopOnContainers.Services.Locations.API.ViewModel; -using System; -using System.Collections.Generic; -using System.Net; -using System.Threading.Tasks; - -namespace Locations.API.Controllers -{ - [Route("api/v1/[controller]")] - [Authorize] - [ApiController] - public class LocationsController : ControllerBase - { - private readonly ILocationsService _locationsService; - private readonly IIdentityService _identityService; - - public LocationsController(ILocationsService locationsService, IIdentityService identityService) - { - _locationsService = locationsService ?? throw new ArgumentNullException(nameof(locationsService)); - _identityService = identityService ?? throw new ArgumentNullException(nameof(identityService)); - } - - //GET api/v1/[controller]/user/1 - [Route("user/{userId:guid}")] - [HttpGet] - [ProducesResponseType(typeof(UserLocation), (int)HttpStatusCode.OK)] - public async Task> GetUserLocationAsync(Guid userId) - { - return await _locationsService.GetUserLocationAsync(userId.ToString()); - } - - //GET api/v1/[controller]/ - [Route("")] - [HttpGet] - [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] - public async Task>> GetAllLocationsAsync() - { - return await _locationsService.GetAllLocationAsync(); - } - - //GET api/v1/[controller]/1 - [Route("{locationId}")] - [HttpGet] - [ProducesResponseType(typeof(Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations), (int)HttpStatusCode.OK)] - public async Task> GetLocationAsync(int locationId) - { - return await _locationsService.GetLocationAsync(locationId); - } - - //POST api/v1/[controller]/ - [Route("")] - [HttpPost] - [ProducesResponseType((int)HttpStatusCode.OK)] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task CreateOrUpdateUserLocationAsync([FromBody]LocationRequest newLocReq) - { - var userId = _identityService.GetUserIdentity(); - var result = await _locationsService.AddOrUpdateUserLocationAsync(userId, newLocReq); - - if (!result) - { - return BadRequest(); - } - - return Ok(); - } - } -} diff --git a/src/Services/Location/Locations.API/Dockerfile b/src/Services/Location/Locations.API/Dockerfile deleted file mode 100644 index 0c5fabfe4..000000000 --- a/src/Services/Location/Locations.API/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base -WORKDIR /app -EXPOSE 80 - -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build -WORKDIR /src - -# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles -# to take advantage of Docker's build cache, to speed up local container builds -COPY "eShopOnContainers-ServicesAndWebApps.sln" "eShopOnContainers-ServicesAndWebApps.sln" - -COPY "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" -COPY "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" -COPY "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" -COPY "BuildingBlocks/EventBus/EventBus/EventBus.csproj" "BuildingBlocks/EventBus/EventBus/EventBus.csproj" -COPY "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" -COPY "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" -COPY "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" -COPY "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" -COPY "Services/Basket/Basket.API/Basket.API.csproj" "Services/Basket/Basket.API/Basket.API.csproj" -COPY "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" -COPY "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" -COPY "Services/Catalog/Catalog.API/Catalog.API.csproj" "Services/Catalog/Catalog.API/Catalog.API.csproj" -COPY "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" -COPY "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" -COPY "Services/Identity/Identity.API/Identity.API.csproj" "Services/Identity/Identity.API/Identity.API.csproj" -COPY "Services/Location/Locations.API/Locations.API.csproj" "Services/Location/Locations.API/Locations.API.csproj" -COPY "Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj" "Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj" -COPY "Services/Marketing/Marketing.API/Marketing.API.csproj" "Services/Marketing/Marketing.API/Marketing.API.csproj" -COPY "Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj" "Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj" -COPY "Services/Ordering/Ordering.API/Ordering.API.csproj" "Services/Ordering/Ordering.API/Ordering.API.csproj" -COPY "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" -COPY "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" -COPY "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" -COPY "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" -COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" -COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" -COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" -COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" -COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" -COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" -COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" -COPY "Web/WebSPA/WebSPA.csproj" "Web/WebSPA/WebSPA.csproj" -COPY "Web/WebStatus/WebStatus.csproj" "Web/WebStatus/WebStatus.csproj" - -COPY "docker-compose.dcproj" "docker-compose.dcproj" - -COPY "NuGet.config" "NuGet.config" - -RUN dotnet restore "eShopOnContainers-ServicesAndWebApps.sln" - -COPY . . -WORKDIR /src/Services/Location/Locations.API -RUN dotnet publish --no-restore -c Release -o /app - -FROM build as functionaltest -WORKDIR /src/Services/Location/Locations.FunctionalTests - -FROM build AS publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app . -ENTRYPOINT ["dotnet", "Locations.API.dll"] diff --git a/src/Services/Location/Locations.API/Dockerfile.develop b/src/Services/Location/Locations.API/Dockerfile.develop deleted file mode 100644 index ab1f7bfb8..000000000 --- a/src/Services/Location/Locations.API/Dockerfile.develop +++ /dev/null @@ -1,17 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster -ARG BUILD_CONFIGURATION=Debug -ENV ASPNETCORE_ENVIRONMENT=Development -ENV DOTNET_USE_POLLING_FILE_WATCHER=true -EXPOSE 80 - -WORKDIR /src -COPY ["Services/Location/Locations.API/Locations.API.csproj", "Services/Location/Locations.API/"] -COPY ["BuildingBlocks/EventBus/EventBus/EventBus.csproj", "BuildingBlocks/EventBus/EventBus/"] -COPY ["BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj", "BuildingBlocks/EventBus/EventBusRabbitMQ/"] -COPY ["BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj", "BuildingBlocks/EventBus/EventBusServiceBus/"] -RUN dotnet restore Services/Location/Locations.API/Locations.API.csproj -nowarn:msb3202,nu1503 -COPY . . -WORKDIR "/src/Services/Location/Locations.API" -RUN dotnet build --no-restore -c $BUILD_CONFIGURATION - -ENTRYPOINT ["dotnet", "run", "--no-build", "--no-launch-profile", "-c", "$BUILD_CONFIGURATION", "--"] diff --git a/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs deleted file mode 100644 index 772129da9..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults -{ - public class InternalServerErrorObjectResult : ObjectResult - { - public InternalServerErrorObjectResult(object error) - : base(error) - { - StatusCode = StatusCodes.Status500InternalServerError; - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Exceptions/LocationDomainException.cs b/src/Services/Location/Locations.API/Infrastructure/Exceptions/LocationDomainException.cs deleted file mode 100644 index 53016fcb2..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Exceptions/LocationDomainException.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions -{ - using System; - - /// - /// Exception type for app exceptions - /// - public class LocationDomainException : Exception - { - public LocationDomainException() - { } - - public LocationDomainException(string message) - : base(message) - { } - - public LocationDomainException(string message, Exception innerException) - : base(message, innerException) - { } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs deleted file mode 100644 index e2d4c9aed..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ /dev/null @@ -1,37 +0,0 @@ - -using Microsoft.AspNetCore.Authorization; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters -{ - internal class AuthorizeCheckOperationFilter : IOperationFilter - { - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - // Check for authorize attribute - var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType().Any() || - context.MethodInfo.GetCustomAttributes(true).OfType().Any(); - - if (!hasAuthorize) return; - - operation.Responses.TryAdd("401", new OpenApiResponse() { Description = "Unauthorized" }); - operation.Responses.TryAdd("403", new OpenApiResponse() { Description = "Forbidden" }); - - var oAuthScheme = new OpenApiSecurityScheme - { - Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" } - }; - - operation.Security = new List - { - new OpenApiSecurityRequirement - { - [ oAuthScheme ] = new [] { "locationsapi" } - } - }; - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index 12cffe878..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -1,68 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters -{ - using AspNetCore.Mvc; - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Mvc.Filters; - using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults; - using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions; - using Microsoft.Extensions.Hosting; - using Microsoft.Extensions.Logging; - using System.Net; - - public class HttpGlobalExceptionFilter : IExceptionFilter - { - private readonly IHostEnvironment env; - private readonly ILogger logger; - - public HttpGlobalExceptionFilter(IHostEnvironment env, ILogger logger) - { - this.env = env; - this.logger = logger; - } - - public void OnException(ExceptionContext context) - { - logger.LogError(new EventId(context.Exception.HResult), - context.Exception, - context.Exception.Message); - - if (context.Exception.GetType() == typeof(LocationDomainException)) - { - var json = new JsonErrorResponse - { - Messages = new[] { context.Exception.Message } - }; - - // Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1 - //It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information - context.Result = new BadRequestObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; - } - else - { - var json = new JsonErrorResponse - { - Messages = new[] { "An error occur.Try it again." } - }; - - if (env.IsDevelopment()) - { - json.DeveloperMessage = context.Exception; - } - - // Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1 - // It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information - context.Result = new InternalServerErrorObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; - } - context.ExceptionHandled = true; - } - - private class JsonErrorResponse - { - public string[] Messages { get; set; } - - public object DeveloperMessage { get; set; } - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/LocationsContext.cs b/src/Services/Location/Locations.API/Infrastructure/LocationsContext.cs deleted file mode 100644 index 4289ffe68..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/LocationsContext.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure -{ - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using Microsoft.Extensions.Options; - using MongoDB.Driver; - - public class LocationsContext - { - private readonly IMongoDatabase _database = null; - - public LocationsContext(IOptions settings) - { - var client = new MongoClient(settings.Value.ConnectionString); - if (client != null) - _database = client.GetDatabase(settings.Value.Database); - } - - public IMongoCollection UserLocation - { - get - { - return _database.GetCollection("UserLocation"); - } - } - - public IMongoCollection Locations - { - get - { - return _database.GetCollection("Locations"); - } - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs b/src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs deleted file mode 100644 index 91d00a4f3..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs +++ /dev/null @@ -1,354 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure -{ - using Microsoft.AspNetCore.Builder; - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Logging; - using Microsoft.Extensions.Options; - using MongoDB.Driver; - using MongoDB.Driver.GeoJsonObjectModel; - using System.Collections.Generic; - using System.Threading.Tasks; - - public class LocationsContextSeed - { - private static LocationsContext ctx; - public static async Task SeedAsync(IApplicationBuilder applicationBuilder, ILoggerFactory loggerFactory) - { - var config = applicationBuilder - .ApplicationServices.GetRequiredService>(); - - ctx = new LocationsContext(config); - - if (!ctx.Locations.Database.GetCollection(nameof(Locations)).AsQueryable().Any()) - { - await SetIndexes(); - await SetNorthAmerica(); - await SetSouthAmerica(); - await SetAfrica(); - await SetEurope(); - await SetAsia(); - await SetAustralia(); - await SetBarcelonaLocations(); - } - } - - static async Task SetNorthAmerica() - { - var us = new Locations() - { - Code = "NA", - Description = "North America", - LocationId = 1 - }; - us.SetLocation(-103.219329, 48.803281); - us.SetArea(GetNorthAmericaPoligon()); - await ctx.Locations.InsertOneAsync(us); - await SetUSLocations(us.Id); - } - - static async Task SetUSLocations(string parentId) - { - var us = new Locations() - { - Parent_Id = parentId, - Code = "US", - Description = "United States", - LocationId = 2 - }; - us.SetLocation(-101.357386, 41.650455); - us.SetArea(GetUSPoligon()); - await ctx.Locations.InsertOneAsync(us); - await SetWashingtonLocations(us.Id); - } - - static async Task SetWashingtonLocations(string parentId) - { - var wht = new Locations() - { - Parent_Id = parentId, - Code = "WHT", - Description = "Washington", - LocationId = 3 - }; - wht.SetLocation(-119.542781, 47.223652); - wht.SetArea(GetWashingtonPoligon()); - await ctx.Locations.InsertOneAsync(wht); - await SetSeattleLocations(wht.Id); - await SetRedmondLocations(wht.Id); - } - - static async Task SetSeattleLocations(string parentId) - { - var stl = new Locations() - { - Parent_Id = parentId, - Code = "SEAT", - Description = "Seattle", - LocationId = 4 - }; - stl.SetArea(GetSeattlePoligon()); - stl.SetLocation(-122.330747, 47.603111); - await ctx.Locations.InsertOneAsync(stl); - } - - static async Task SetRedmondLocations(string parentId) - { - var rdm = new Locations() - { - Parent_Id = parentId, - Code = "REDM", - Description = "Redmond", - LocationId = 5 - }; - rdm.SetLocation(-122.122887, 47.674961); - rdm.SetArea(GetRedmondPoligon()); - await ctx.Locations.InsertOneAsync(rdm); - } - - static async Task SetBarcelonaLocations() - { - var bcn = new Locations() - { - Code = "BCN", - Description = "Barcelona", - LocationId = 6 - }; - bcn.SetLocation(2.156453, 41.395226); - bcn.SetArea(GetBarcelonaPoligon()); - await ctx.Locations.InsertOneAsync(bcn); - } - - static async Task SetSouthAmerica() - { - var sa = new Locations() - { - Code = "SA", - Description = "South America", - LocationId = 7 - }; - sa.SetLocation(-60.328704, -16.809748); - sa.SetArea(GetSouthAmericaPoligon()); - await ctx.Locations.InsertOneAsync(sa); - } - - static async Task SetAfrica() - { - var afc = new Locations() - { - Code = "AFC", - Description = "Africa", - LocationId = 8 - }; - afc.SetLocation(19.475383, 13.063667); - afc.SetArea(GetAfricaPoligon()); - await ctx.Locations.InsertOneAsync(afc); - } - - static async Task SetEurope() - { - var eu = new Locations() - { - Code = "EU", - Description = "Europe", - LocationId = 9 - }; - eu.SetLocation(13.147258, 49.947844); - eu.SetArea(GetEuropePoligon()); - await ctx.Locations.InsertOneAsync(eu); - } - - static async Task SetAsia() - { - var asa = new Locations() - { - Code = "AS", - Description = "Asia", - LocationId = 10 - }; - asa.SetLocation(97.522257, 56.069107); - asa.SetArea(GetAsiaPoligon()); - await ctx.Locations.InsertOneAsync(asa); - } - - static async Task SetAustralia() - { - var aus = new Locations() - { - Code = "AUS", - Description = "Australia", - LocationId = 11 - }; - aus.SetLocation(133.733195, -25.010726); - aus.SetArea(GetAustraliaPoligon()); - await ctx.Locations.InsertOneAsync(aus); - } - - static async Task SetIndexes() - { - // Set location indexes - var builder = Builders.IndexKeys; - var keys = builder.Geo2DSphere(prop => prop.Location); - await ctx.Locations.Indexes.CreateOneAsync(keys); - } - - static List GetNorthAmericaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-168.07786, 68.80277), - new GeoJson2DGeographicCoordinates(-119.60378, 32.7561), - new GeoJson2DGeographicCoordinates(-116.01966, 28.94642), - new GeoJson2DGeographicCoordinates(-98.52265, 14.49378), - new GeoJson2DGeographicCoordinates(-71.18188, 34.96278), - new GeoJson2DGeographicCoordinates(-51.97606, 48.24377), - new GeoJson2DGeographicCoordinates(-75.39806, 72.93141), - new GeoJson2DGeographicCoordinates(-168.07786, 68.80277) - }; - } - - static List GetSouthAmericaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-91.43724, 13.29007), - new GeoJson2DGeographicCoordinates(-87.96315, -27.15081), - new GeoJson2DGeographicCoordinates(-78.75404, -50.71852), - new GeoJson2DGeographicCoordinates(-59.14765, -58.50773), - new GeoJson2DGeographicCoordinates(-50.08813, -42.22419), - new GeoJson2DGeographicCoordinates(-37.21044, -22.56725), - new GeoJson2DGeographicCoordinates(-36.61675, -0.38594), - new GeoJson2DGeographicCoordinates(-44.46056, -16.6746), - new GeoJson2DGeographicCoordinates(-91.43724, 13.29007), - }; - } - - static List GetAfricaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-12.68724, 34.05892), - new GeoJson2DGeographicCoordinates(-18.33301, 20.77313), - new GeoJson2DGeographicCoordinates(-14.13503, 6.21292), - new GeoJson2DGeographicCoordinates(1.40221, -14.23693), - new GeoJson2DGeographicCoordinates(22.41485, -35.55408), - new GeoJson2DGeographicCoordinates(51.86499, -25.39831), - new GeoJson2DGeographicCoordinates(53.49269, 4.59405), - new GeoJson2DGeographicCoordinates(35.102, 26.14685), - new GeoJson2DGeographicCoordinates(21.63319, 33.75767), - new GeoJson2DGeographicCoordinates(6.58235, 37.05665), - new GeoJson2DGeographicCoordinates(-12.68724, 34.05892), - }; - } - - static List GetEuropePoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-11.73143, 35.27646), - new GeoJson2DGeographicCoordinates(-10.84462, 35.25123), - new GeoJson2DGeographicCoordinates(-10.09927, 35.26833), - new GeoJson2DGeographicCoordinates(49.00838, 36.56984), - new GeoJson2DGeographicCoordinates(36.63837, 71.69807), - new GeoJson2DGeographicCoordinates(-10.88788, 61.13851), - new GeoJson2DGeographicCoordinates(-11.73143, 35.27646), - }; - } - - static List GetAsiaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(31.1592, 45.91629), - new GeoJson2DGeographicCoordinates(32.046, 45.89479), - new GeoJson2DGeographicCoordinates(62.32261, -4.45013), - new GeoJson2DGeographicCoordinates(154.47713, 35.14525), - new GeoJson2DGeographicCoordinates(-166.70788, 68.62211), - new GeoJson2DGeographicCoordinates(70.38837, 75.89335), - new GeoJson2DGeographicCoordinates(32.00274, 67.23428), - new GeoJson2DGeographicCoordinates(31.1592, 45.91629), - }; - } - - static List GetAustraliaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(100.76857, -45.74117), - new GeoJson2DGeographicCoordinates(101.65538, -45.76273), - new GeoJson2DGeographicCoordinates(167.08823, -50.66317), - new GeoJson2DGeographicCoordinates(174.16463, -34.62579), - new GeoJson2DGeographicCoordinates(160.94837, -5.01004), - new GeoJson2DGeographicCoordinates(139.29462, -7.86376), - new GeoJson2DGeographicCoordinates(101.61212, -11.44654), - new GeoJson2DGeographicCoordinates(100.76857, -45.74117), - }; - } - - static List GetUSPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-62.88205, 48.7985), - new GeoJson2DGeographicCoordinates(-129.3132, 48.76513), - new GeoJson2DGeographicCoordinates(-120.9496, 30.12256), - new GeoJson2DGeographicCoordinates(-111.3944, 30.87114), - new GeoJson2DGeographicCoordinates(-78.11975, 24.24979), - new GeoJson2DGeographicCoordinates(-62.88205, 48.7985) - }; - } - - static List GetSeattlePoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-122.36238,47.82929), - new GeoJson2DGeographicCoordinates(-122.42091,47.6337), - new GeoJson2DGeographicCoordinates(-122.37371,47.45224), - new GeoJson2DGeographicCoordinates(-122.20788,47.50259), - new GeoJson2DGeographicCoordinates(-122.26934,47.73644), - new GeoJson2DGeographicCoordinates(-122.36238,47.82929) - }; - } - - static List GetRedmondPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-122.15432, 47.73148), - new GeoJson2DGeographicCoordinates(-122.17673, 47.72559), - new GeoJson2DGeographicCoordinates(-122.16904, 47.67851), - new GeoJson2DGeographicCoordinates(-122.16136, 47.65036), - new GeoJson2DGeographicCoordinates(-122.15604, 47.62746), - new GeoJson2DGeographicCoordinates(-122.01562, 47.63463), - new GeoJson2DGeographicCoordinates(-122.04961, 47.74244), - new GeoJson2DGeographicCoordinates(-122.15432, 47.73148) - }; - } - - static List GetWashingtonPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(-124.68633, 48.8943), - new GeoJson2DGeographicCoordinates(-124.32962, 45.66613), - new GeoJson2DGeographicCoordinates(-116.73824, 45.93384), - new GeoJson2DGeographicCoordinates(-116.96912, 49.04282), - new GeoJson2DGeographicCoordinates(-124.68633, 48.8943) - }; - } - - static List GetBarcelonaPoligon() - { - return new List() - { - new GeoJson2DGeographicCoordinates(2.033879, 41.383858), - new GeoJson2DGeographicCoordinates(2.113741, 41.419068), - new GeoJson2DGeographicCoordinates(2.188778, 41.451153), - new GeoJson2DGeographicCoordinates(2.235266, 41.418033), - new GeoJson2DGeographicCoordinates(2.137101, 41.299536), - new GeoJson2DGeographicCoordinates(2.033879, 41.383858) - }; - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index e6b43d109..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Middlewares -{ - class ByPassAuthMiddleware - { - private readonly RequestDelegate _next; - private string _currentUserId; - public ByPassAuthMiddleware(RequestDelegate next) - { - _next = next; - _currentUserId = null; - } - - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path == "/noauth") - { - var userid = context.Request.Query["userid"]; - if (!string.IsNullOrEmpty(userid)) - { - _currentUserId = userid; - } - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to {_currentUserId}"); - } - - else if (path == "/noauth/reset") - { - _currentUserId = null; - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to none. Token required for protected endpoints."); - } - else - { - var currentUserId = _currentUserId; - - var authHeader = context.Request.Headers["Authorization"]; - if (authHeader != StringValues.Empty) - { - var header = authHeader.FirstOrDefault(); - if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length) - { - currentUserId = header.Substring("Email ".Length); - } - } - - - if (!string.IsNullOrEmpty(currentUserId)) - { - var user = new ClaimsIdentity(new[] { - new Claim("emails", currentUserId), - new Claim("name", "Test user"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"), - new Claim("nonce", Guid.NewGuid().ToString()), - new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), - new Claim("sub", currentUserId), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} - , "ByPassAuth"); - - context.User = new ClaimsPrincipal(user); - } - - await _next.Invoke(context); - } - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs b/src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs deleted file mode 100644 index cd50fa987..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories -{ - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using System.Collections.Generic; - using System.Threading.Tasks; - using ViewModel; - - public interface ILocationsRepository - { - Task GetAsync(int locationId); - - Task> GetLocationListAsync(); - - Task GetUserLocationAsync(string userId); - - Task> GetCurrentUserRegionsListAsync(LocationRequest currentPosition); - - Task AddUserLocationAsync(UserLocation location); - - Task UpdateUserLocationAsync(UserLocation userLocation); - - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs b/src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs deleted file mode 100644 index 9f8d42ad4..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories -{ - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using Microsoft.Extensions.Options; - using MongoDB.Bson; - using MongoDB.Driver; - using MongoDB.Driver.GeoJsonObjectModel; - using System.Collections.Generic; - using System.Threading.Tasks; - using ViewModel; - - public class LocationsRepository - : ILocationsRepository - { - private readonly LocationsContext _context; - - public LocationsRepository(IOptions settings) - { - _context = new LocationsContext(settings); - } - - public async Task GetAsync(int locationId) - { - var filter = Builders.Filter.Eq("LocationId", locationId); - return await _context.Locations - .Find(filter) - .FirstOrDefaultAsync(); - } - - public async Task GetUserLocationAsync(string userId) - { - var filter = Builders.Filter.Eq("UserId", userId); - return await _context.UserLocation - .Find(filter) - .FirstOrDefaultAsync(); - } - - public async Task> GetLocationListAsync() - { - return await _context.Locations.Find(new BsonDocument()).ToListAsync(); - } - - public async Task> GetCurrentUserRegionsListAsync(LocationRequest currentPosition) - { - var point = GeoJson.Point(GeoJson.Geographic(currentPosition.Longitude, currentPosition.Latitude)); - var orderByDistanceQuery = new FilterDefinitionBuilder().Near(x => x.Location, point); - var withinAreaQuery = new FilterDefinitionBuilder().GeoIntersects("Polygon", point); - var filter = Builders.Filter.And(orderByDistanceQuery, withinAreaQuery); - return await _context.Locations.Find(filter).ToListAsync(); - } - - public async Task AddUserLocationAsync(UserLocation location) - { - await _context.UserLocation.InsertOneAsync(location); - } - - public async Task UpdateUserLocationAsync(UserLocation userLocation) - { - await _context.UserLocation.ReplaceOneAsync( - doc => doc.UserId == userLocation.UserId, - userLocation, - new UpdateOptions { IsUpsert = true }); - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Services/IIdentityService.cs b/src/Services/Location/Locations.API/Infrastructure/Services/IIdentityService.cs deleted file mode 100644 index a2b79d8d1..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Services/IIdentityService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services -{ - public interface IIdentityService - { - string GetUserIdentity(); - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs b/src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs deleted file mode 100644 index 11459492a..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services -{ - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using Microsoft.eShopOnContainers.Services.Locations.API.ViewModel; - using System.Collections.Generic; - using System.Threading.Tasks; - - public interface ILocationsService - { - Task GetLocationAsync(int locationId); - - Task GetUserLocationAsync(string id); - - Task> GetAllLocationAsync(); - - Task AddOrUpdateUserLocationAsync(string userId, LocationRequest locRequest); - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Services/IdentityService.cs b/src/Services/Location/Locations.API/Infrastructure/Services/IdentityService.cs deleted file mode 100644 index d06b44a4f..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Services/IdentityService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Http; -using System; - -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services -{ - public class IdentityService : IIdentityService - { - private readonly IHttpContextAccessor _context; - - public IdentityService(IHttpContextAccessor context) - { - _context = context ?? throw new ArgumentNullException(nameof(context)); - } - - public string GetUserIdentity() - { - return _context.HttpContext.User.FindFirst("sub").Value; - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs b/src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs deleted file mode 100644 index f6b9ed708..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services -{ - using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; - using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions; - using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories; - using Microsoft.eShopOnContainers.Services.Locations.API.IntegrationEvents.Events; - using Microsoft.eShopOnContainers.Services.Locations.API.Model; - using Microsoft.eShopOnContainers.Services.Locations.API.ViewModel; - using Microsoft.Extensions.Logging; - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - - public class LocationsService : ILocationsService - { - private readonly ILocationsRepository _locationsRepository; - private readonly IEventBus _eventBus; - private readonly ILogger _logger; - - public LocationsService( - ILocationsRepository locationsRepository, - IEventBus eventBus, - ILogger logger) - { - _locationsRepository = locationsRepository ?? throw new ArgumentNullException(nameof(locationsRepository)); - _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } - - public async Task GetLocationAsync(int locationId) - { - return await _locationsRepository.GetAsync(locationId); - } - - public async Task GetUserLocationAsync(string userId) - { - return await _locationsRepository.GetUserLocationAsync(userId); - } - - public async Task> GetAllLocationAsync() - { - return await _locationsRepository.GetLocationListAsync(); - } - - public async Task AddOrUpdateUserLocationAsync(string userId, LocationRequest currentPosition) - { - // Get the list of ordered regions the user currently is within - var currentUserAreaLocationList = await _locationsRepository.GetCurrentUserRegionsListAsync(currentPosition); - - if (currentUserAreaLocationList is null) - { - throw new LocationDomainException("User current area not found"); - } - - // If current area found, then update user location - var locationAncestors = new List(); - var userLocation = await _locationsRepository.GetUserLocationAsync(userId); - userLocation = userLocation ?? new UserLocation(); - userLocation.UserId = userId; - userLocation.LocationId = currentUserAreaLocationList[0].LocationId; - userLocation.UpdateDate = DateTime.UtcNow; - await _locationsRepository.UpdateUserLocationAsync(userLocation); - - // Publish integration event to update marketing read data model - // with the new locations updated - PublishNewUserLocationPositionIntegrationEvent(userId, currentUserAreaLocationList); - - return true; - } - - private void PublishNewUserLocationPositionIntegrationEvent(string userId, List newLocations) - { - var newUserLocations = MapUserLocationDetails(newLocations); - var @event = new UserLocationUpdatedIntegrationEvent(userId, newUserLocations); - - _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - - _eventBus.Publish(@event); - } - - private List MapUserLocationDetails(List newLocations) - { - var result = new List(); - newLocations.ForEach(location => - { - result.Add(new UserLocationDetails() - { - LocationId = location.LocationId, - Code = location.Code, - Description = location.Description - }); - }); - - return result; - } - } -} diff --git a/src/Services/Location/Locations.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs b/src/Services/Location/Locations.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs deleted file mode 100644 index 7c3e72769..000000000 --- a/src/Services/Location/Locations.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.IntegrationEvents.Events -{ - using Locations.API.Model; - using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - using System.Collections.Generic; - - public class UserLocationUpdatedIntegrationEvent : IntegrationEvent - { - public string UserId { get; set; } - public List LocationList { get; set; } - - public UserLocationUpdatedIntegrationEvent(string userId, List locationList) - { - UserId = userId; - LocationList = locationList; - } - } -} diff --git a/src/Services/Location/Locations.API/LocationSettings.cs b/src/Services/Location/Locations.API/LocationSettings.cs deleted file mode 100644 index b3972239c..000000000 --- a/src/Services/Location/Locations.API/LocationSettings.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Locations.API -{ - public class LocationSettings - { - public string ExternalCatalogBaseUrl { get; set; } - public string EventBusConnection { get; set; } - public string ConnectionString { get; set; } - public string Database { get; set; } - } -} diff --git a/src/Services/Location/Locations.API/Locations.API.csproj b/src/Services/Location/Locations.API/Locations.API.csproj deleted file mode 100644 index d4899becb..000000000 --- a/src/Services/Location/Locations.API/Locations.API.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - netcoreapp3.1 - ..\..\..\..\docker-compose.dcproj - aspnet-Locations.API-20161122013619 - false - true - preview - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Services/Location/Locations.API/Model/Core/LocationPoint.cs b/src/Services/Location/Locations.API/Model/Core/LocationPoint.cs deleted file mode 100644 index 48b6e32a7..000000000 --- a/src/Services/Location/Locations.API/Model/Core/LocationPoint.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Locations.API.Model.Core -{ - public class LocationPoint - { - public LocationPoint() - { - } - - public LocationPoint(double longitude, double latitude) - { - this.coordinates.Add(longitude); - this.coordinates.Add(latitude); - } - - public string type { get; private set; } = "Point"; - - public List coordinates { get; private set; } = new List(); - } -} diff --git a/src/Services/Location/Locations.API/Model/Core/LocationPolygon.cs b/src/Services/Location/Locations.API/Model/Core/LocationPolygon.cs deleted file mode 100644 index 18380cc79..000000000 --- a/src/Services/Location/Locations.API/Model/Core/LocationPolygon.cs +++ /dev/null @@ -1,25 +0,0 @@ -using MongoDB.Driver.GeoJsonObjectModel; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Locations.API.Model.Core -{ - public class LocationPolygon - { - public LocationPolygon() - { - } - - public LocationPolygon(List coordinatesList) - { - var coordinatesMapped = coordinatesList.Select(x => new List() { x.Longitude, x.Latitude }).ToList(); - this.coordinates.Add(coordinatesMapped); - } - - public string type { get; private set; } = "Polygon"; - - public List>> coordinates { get; private set; } = new List>>(); - } -} diff --git a/src/Services/Location/Locations.API/Model/Locations.cs b/src/Services/Location/Locations.API/Model/Locations.cs deleted file mode 100644 index ba3dbe62c..000000000 --- a/src/Services/Location/Locations.API/Model/Locations.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Model -{ - using global::Locations.API.Model.Core; - using MongoDB.Bson; - using MongoDB.Bson.Serialization.Attributes; - using MongoDB.Driver.GeoJsonObjectModel; - using System.Collections.Generic; - - public class Locations - { - [BsonId] - [BsonRepresentation(BsonType.ObjectId)] - public string Id { get; set; } - public int LocationId { get; set; } - public string Code { get; set; } - [BsonRepresentation(BsonType.ObjectId)] - public string Parent_Id { get; set; } - public string Description { get; set; } - public double Latitude { get; set; } - public double Longitude { get; set; } - public LocationPoint Location { get; private set; } - public LocationPolygon Polygon { get; private set; } - - // Temporal commented in previewVersion7 of netcore and 2.9.0-beta2 of Mongo packages, review in next versions - // public GeoJsonPoint Location { get; private set; } - // public GeoJsonPolygon Polygon { get; private set; } - public void SetLocation(double lon, double lat) => SetPosition(lon, lat); - public void SetArea(List coordinatesList) => SetPolygon(coordinatesList); - - private void SetPosition(double lon, double lat) - { - Latitude = lat; - Longitude = lon; - Location = new LocationPoint(lon, lat); - } - - private void SetPolygon(List coordinatesList) - { - Polygon = new LocationPolygon(coordinatesList); - } - } -} diff --git a/src/Services/Location/Locations.API/Model/UserLocation.cs b/src/Services/Location/Locations.API/Model/UserLocation.cs deleted file mode 100644 index 4686bd006..000000000 --- a/src/Services/Location/Locations.API/Model/UserLocation.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Model -{ - using MongoDB.Bson; - using MongoDB.Bson.Serialization.Attributes; - using System; - - public class UserLocation - { - [BsonIgnoreIfDefault] - [BsonRepresentation(BsonType.ObjectId)] - public string Id { get; set; } - public string UserId { get; set; } - public int LocationId { get; set; } - public DateTime UpdateDate { get; set; } - } -} diff --git a/src/Services/Location/Locations.API/Model/UserLocationDetails.cs b/src/Services/Location/Locations.API/Model/UserLocationDetails.cs deleted file mode 100644 index 7983e8e59..000000000 --- a/src/Services/Location/Locations.API/Model/UserLocationDetails.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.Model -{ - public class UserLocationDetails - { - public int LocationId { get; set; } - public string Code { get; set; } - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/Services/Location/Locations.API/Program.cs b/src/Services/Location/Locations.API/Program.cs deleted file mode 100644 index f9e21a8a4..000000000 --- a/src/Services/Location/Locations.API/Program.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using Serilog; -using System; -using System.IO; - -namespace Microsoft.eShopOnContainers.Services.Locations.API -{ - public class Program - { - public static readonly string Namespace = typeof(Program).Namespace; - public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); - - public static int Main(string[] args) - { - var configuration = GetConfiguration(); - - Log.Logger = CreateSerilogLogger(configuration); - - try - { - Log.Information("Configuring web host ({ApplicationContext})...", AppName); - var host = BuildWebHost(configuration, args); - - Log.Information("Starting web host ({ApplicationContext})...", AppName); - host.Run(); - - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); - return 1; - } - finally - { - Log.CloseAndFlush(); - } - } - - private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) => - WebHost.CreateDefaultBuilder(args) - .CaptureStartupErrors(false) - .ConfigureAppConfiguration(x => x.AddConfiguration(configuration)) - .UseStartup() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseSerilog() - .Build(); - - private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) - { - var seqServerUrl = configuration["Serilog:SeqServerUrl"]; - var logstashUrl = configuration["Serilog:LogstashgUrl"]; - return new LoggerConfiguration() - .MinimumLevel.Verbose() - .Enrich.WithProperty("ApplicationContext", AppName) - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl) - .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl) - .ReadFrom.Configuration(configuration) - .CreateLogger(); - } - - private static IConfiguration GetConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables(); - - var config = builder.Build(); - - if (config.GetValue("UseVault", false)) - { - builder.AddAzureKeyVault( - $"https://{config["Vault:Name"]}.vault.azure.net/", - config["Vault:ClientId"], - config["Vault:ClientSecret"]); - } - - return builder.Build(); - } - } -} \ No newline at end of file diff --git a/src/Services/Location/Locations.API/Properties/launchSettings.json b/src/Services/Location/Locations.API/Properties/launchSettings.json deleted file mode 100644 index 1c86a33b1..000000000 --- a/src/Services/Location/Locations.API/Properties/launchSettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:54020/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "api/values", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Locations.API": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/values", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:3279" - } - } -} \ No newline at end of file diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs deleted file mode 100644 index ca6a57e6e..000000000 --- a/src/Services/Location/Locations.API/Startup.cs +++ /dev/null @@ -1,312 +0,0 @@ -using Autofac; -using Autofac.Extensions.DependencyInjection; -using HealthChecks.UI.Client; -using Locations.API.Controllers; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Azure.ServiceBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Middlewares; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories; -using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Logging; -using Microsoft.OpenApi.Models; -using RabbitMQ.Client; -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; - -namespace Microsoft.eShopOnContainers.Services.Locations.API -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - public virtual IServiceProvider ConfigureServices(IServiceCollection services) - { - RegisterAppInsights(services); - - services.AddCustomHealthCheck(Configuration); - - services.AddControllers(options => - { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); - }) - // Added for functional tests - .AddApplicationPart(typeof(LocationsController).Assembly) - .AddNewtonsoftJson(); - - ConfigureAuthService(services); - - services.Configure(Configuration); - - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var logger = sp.GetRequiredService>(); - - var serviceBusConnectionString = Configuration["EventBusConnection"]; - var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); - - return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger); - }); - } - else - { - services.AddSingleton(sp => - { - var logger = sp.GetRequiredService>(); - - var factory = new ConnectionFactory() - { - HostName = Configuration["EventBusConnection"], - DispatchConsumersAsync = true - }; - - if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) - { - factory.UserName = Configuration["EventBusUserName"]; - } - - if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) - { - factory.Password = Configuration["EventBusPassword"]; - } - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); - }); - } - - RegisterEventBus(services); - - // Add framework services. - services.AddSwaggerGen(options => - { - options.DescribeAllEnumsAsStrings(); - options.SwaggerDoc("v1", new OpenApiInfo - { - Title = "eShopOnContainers - Location HTTP API", - Version = "v1", - Description = "The Location Microservice HTTP API. This is a Data-Driven/CRUD microservice sample", - }); - - options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme - { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows() - { - Implicit = new OpenApiOAuthFlow() - { - AuthorizationUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/token"), - Scopes = new Dictionary() - { - { "locations", "Locations API" } - } - } - } - }); - - options.OperationFilter(); - - }); - - services.AddCors(options => - { - options.AddPolicy("CorsPolicy", - builder => builder - .SetIsOriginAllowed((host) => true) - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials()); - }); - - services.AddSingleton(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - - //configure autofac - var container = new ContainerBuilder(); - container.Populate(services); - - return new AutofacServiceProvider(container.Build()); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - //loggerFactory.AddAzureWebAppDiagnostics(); - //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); - - var pathBase = Configuration["PATH_BASE"]; - if (!string.IsNullOrEmpty(pathBase)) - { - app.UsePathBase(pathBase); - } - - app.UseRouting(); - app.UseCors("CorsPolicy"); - ConfigureAuth(app); - - app.UseEndpoints(endpoints => - { - endpoints.MapDefaultControllerRoute(); - endpoints.MapControllers(); - endpoints.MapHealthChecks("/hc", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - endpoints.MapHealthChecks("/liveness", new HealthCheckOptions - { - Predicate = r => r.Name.Contains("self") - }); - }); - - app.UseSwagger() - .UseSwaggerUI(c => - { - c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Locations.API V1"); - c.OAuthClientId("locationsswaggerui"); - c.OAuthAppName("Locations Swagger UI"); - }); - - LocationsContextSeed.SeedAsync(app, loggerFactory) - .Wait(); - } - - private void RegisterAppInsights(IServiceCollection services) - { - services.AddApplicationInsightsTelemetry(Configuration); - services.AddApplicationInsightsKubernetesEnricher(); - } - - private void ConfigureAuthService(IServiceCollection services) - { - // prevent from mapping "sub" claim to nameidentifier. - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); - - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }) - .AddJwtBearer(options => - { - options.Authority = Configuration.GetValue("IdentityUrl"); - options.Audience = "locations"; - options.RequireHttpsMetadata = false; - }); - } - - protected virtual void ConfigureAuth(IApplicationBuilder app) - { - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - - app.UseAuthentication(); - app.UseAuthorization(); - } - - private void RegisterEventBus(IServiceCollection services) - { - var subscriptionClientName = Configuration["SubscriptionClientName"]; - - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var serviceBusPersisterConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - return new EventBusServiceBus(serviceBusPersisterConnection, logger, - eventBusSubcriptionsManager, subscriptionClientName, iLifetimeScope); - }); - } - else - { - services.AddSingleton(sp => - { - var rabbitMQPersistentConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); - }); - } - - services.AddSingleton(); - } - } - - public static class CustomExtensionMethods - { - public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) - { - var hcBuilder = services.AddHealthChecks(); - - hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); - - hcBuilder - .AddMongoDb( - configuration["ConnectionString"], - name: "locations-mongodb-check", - tags: new string[] { "mongodb" }); - - if (configuration.GetValue("AzureServiceBusEnabled")) - { - hcBuilder - .AddAzureServiceBusTopic( - configuration["EventBusConnection"], - topicName: "eshop_event_bus", - name: "locations-servicebus-check", - tags: new string[] { "servicebus" }); - } - else - { - hcBuilder - .AddRabbitMQ( - $"amqp://{configuration["EventBusConnection"]}", - name: "locations-rabbitmqbus-check", - tags: new string[] { "rabbitmqbus" }); - } - - return services; - } - } -} diff --git a/src/Services/Location/Locations.API/ViewModel/LocationRequest.cs b/src/Services/Location/Locations.API/ViewModel/LocationRequest.cs deleted file mode 100644 index 5301cee87..000000000 --- a/src/Services/Location/Locations.API/ViewModel/LocationRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Locations.API.ViewModel -{ - public class LocationRequest - { - public double Longitude { get; set; } - public double Latitude { get; set; } - } -} diff --git a/src/Services/Location/Locations.API/appsettings.json b/src/Services/Location/Locations.API/appsettings.json deleted file mode 100644 index 3ee24b242..000000000 --- a/src/Services/Location/Locations.API/appsettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "ConnectionString": "mongodb://nosql.data", - "Database": "LocationsDb", - "IdentityUrl": "http://localhost:5105", - "Serilog": { - "SeqServerUrl": null, - "LogstashgUrl": null, - "MinimumLevel": { - "Default": "Information", - "Override": { - "Microsoft": "Warning", - "Microsoft.eShopOnContainers": "Information", - "System": "Warning" - } - } - }, - "AzureServiceBusEnabled": false, - "SubscriptionClientName": "Locations", - "ApplicationInsights": { - "InstrumentationKey": "" - }, - "EventBusRetryCount": 5, - "UseVault": false, - "Vault": { - "Name": "eshop", - "ClientId": "your-client-id", - "ClientSecret": "your-client-secret" - } -} diff --git a/src/Services/Location/Locations.API/azds.yaml b/src/Services/Location/Locations.API/azds.yaml deleted file mode 100644 index e86a09927..000000000 --- a/src/Services/Location/Locations.API/azds.yaml +++ /dev/null @@ -1,56 +0,0 @@ -kind: helm-release -apiVersion: 1.1 -build: - context: ..\..\..\.. - dockerfile: Dockerfile -install: - chart: ../../../../k8s/helm/locations-api - set: - replicaCount: 1 - image: - tag: $(tag) - pullPolicy: Never - ingress: - annotations: - kubernetes.io/ingress.class: traefik-azds - hosts: - - $(spacePrefix)eshop$(hostSuffix) - inf: - k8s: - dns: $(spacePrefix)eshop$(hostSuffix) - values: - - values.dev.yaml? - - secrets.dev.yaml? - - inf.yaml - - app.yaml -configurations: - develop: - build: - useGitIgnore: true - dockerfile: Dockerfile.develop - args: - BUILD_CONFIGURATION: ${BUILD_CONFIGURATION:-Debug} - container: - sync: - - '**/Pages/**' - - '**/Views/**' - - '**/wwwroot/**' - - '!**/*.{sln,csproj}' - command: - - dotnet - - run - - --no-restore - - --no-build - - --no-launch-profile - - -c - - ${BUILD_CONFIGURATION:-Debug} - iterate: - processesToKill: - - dotnet - - vsdbg - buildCommands: - - - dotnet - - build - - --no-restore - - -c - - ${BUILD_CONFIGURATION:-Debug} diff --git a/src/Services/Location/Locations.API/values.dev.yaml b/src/Services/Location/Locations.API/values.dev.yaml deleted file mode 100644 index eaed45149..000000000 --- a/src/Services/Location/Locations.API/values.dev.yaml +++ /dev/null @@ -1,3 +0,0 @@ -ingress: - enabled: true - tls: [] \ No newline at end of file diff --git a/src/Services/Location/Locations.FunctionalTests/LocationTestsStartup.cs b/src/Services/Location/Locations.FunctionalTests/LocationTestsStartup.cs deleted file mode 100644 index 08bf2ffa5..000000000 --- a/src/Services/Location/Locations.FunctionalTests/LocationTestsStartup.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.eShopOnContainers.Services.Locations.API; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Locations.FunctionalTests -{ - public class LocationsTestsStartup : Startup - { - public LocationsTestsStartup(IConfiguration env) : base(env) - { - } - - public override IServiceProvider ConfigureServices(IServiceCollection services) - { - // Added to avoid the Authorize data annotation in test environment. - // Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json - services.Configure(Configuration); - return base.ConfigureServices(services); - } - protected override void ConfigureAuth(IApplicationBuilder app) - { - if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant()) - { - app.UseMiddleware(); - } - else - { - base.ConfigureAuth(app); - } - } - - class LocationAuthorizeMiddleware - { - private readonly RequestDelegate _next; - public LocationAuthorizeMiddleware(RequestDelegate rd) - { - _next = rd; - } - - public async Task Invoke(HttpContext httpContext) - { - var identity = new ClaimsIdentity("cookies"); - identity.AddClaim(new Claim("sub", "4611ce3f-380d-4db5-8d76-87a8689058ed")); - httpContext.User.AddIdentity(identity); - await _next.Invoke(httpContext); - } - } - } -} diff --git a/src/Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj b/src/Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj deleted file mode 100644 index 0b6f4f1fa..000000000 --- a/src/Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - netcoreapp3.1 - false - false - - - - - - - - - Always - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - - diff --git a/src/Services/Location/Locations.FunctionalTests/LocationsScenarioBase.cs b/src/Services/Location/Locations.FunctionalTests/LocationsScenarioBase.cs deleted file mode 100644 index 8c68fa3f6..000000000 --- a/src/Services/Location/Locations.FunctionalTests/LocationsScenarioBase.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; -using System.IO; -using System.Reflection; - -namespace Locations.FunctionalTests -{ - public class LocationsScenarioBase - { - public TestServer CreateServer() - { - var path = Assembly.GetAssembly(typeof(LocationsScenarioBase)) - .Location; - - var hostBuilder = new WebHostBuilder() - .UseContentRoot(Path.GetDirectoryName(path)) - .ConfigureAppConfiguration(cb => - { - cb.AddJsonFile("appsettings.json", optional: false) - .AddEnvironmentVariables(); - }).UseStartup(); - - return new TestServer(hostBuilder); - } - - public static class Get - { - public static string Locations = "api/v1/locations"; - - public static string LocationBy(int id) - { - return $"api/v1/locations/{id}"; - } - - public static string UserLocationBy(string id) - { - return $"api/v1/locations/user/{id}"; - } - } - - public static class Post - { - public static string AddNewLocation = "api/v1/locations/"; - } - } -} diff --git a/src/Services/Location/Locations.FunctionalTests/LocationsScenarios.cs b/src/Services/Location/Locations.FunctionalTests/LocationsScenarios.cs deleted file mode 100644 index 5f8c90dfd..000000000 --- a/src/Services/Location/Locations.FunctionalTests/LocationsScenarios.cs +++ /dev/null @@ -1,140 +0,0 @@ -using Microsoft.eShopOnContainers.Services.Locations.API.Model; -using Microsoft.eShopOnContainers.Services.Locations.API.ViewModel; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace Locations.FunctionalTests -{ - public class LocationsScenarios - : LocationsScenarioBase - { - [Fact] - public async Task Set_new_user_seattle_location_response_ok_status_code() - { - using (var server = CreateServer()) - { - var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed"; - var content = new StringContent(BuildLocationsRequest(-122.315752, 47.604610), UTF8Encoding.UTF8, "application/json"); - - // Expected result - var expectedLocation = "SEAT"; - - // Act - var response = await server.CreateClient() - .PostAsync(Post.AddNewLocation, content); - - var userLocationResponse = await server.CreateClient() - .GetAsync(Get.UserLocationBy(userId)); - - var responseBody = await userLocationResponse.Content.ReadAsStringAsync(); - var userLocation = JsonConvert.DeserializeObject(responseBody); - - var locationResponse = await server.CreateClient() - .GetAsync(Get.LocationBy(userLocation.LocationId)); - - responseBody = await locationResponse.Content.ReadAsStringAsync(); - var location = JsonConvert.DeserializeObject(responseBody); - - // Assert - Assert.Equal(expectedLocation, location.Code); - } - } - - [Fact] - public async Task Set_new_user_readmond_location_response_ok_status_code() - { - using (var server = CreateServer()) - { - var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed"; - var content = new StringContent(BuildLocationsRequest(-122.119998, 47.690876), UTF8Encoding.UTF8, "application/json"); - - var client = server.CreateClient(); - - // Expected result - var expectedLocation = "REDM"; - - // Act - - var response = await client.PostAsync(Post.AddNewLocation, content); - - var userLocationResponse = await client.GetAsync(Get.UserLocationBy(userId)); - userLocationResponse.EnsureSuccessStatusCode(); - - var responseBody = await userLocationResponse.Content.ReadAsStringAsync(); - var userLocation = JsonConvert.DeserializeObject(responseBody); - - Assert.NotNull(userLocation); - - var locationResponse = await client.GetAsync(Get.LocationBy(userLocation.LocationId)); - - responseBody = await locationResponse.Content.ReadAsStringAsync(); - var location = JsonConvert.DeserializeObject(responseBody); - - // Assert - Assert.Equal(expectedLocation, location.Code); - } - } - - [Fact] - public async Task Set_new_user_Washington_location_response_ok_status_code() - { - using (var server = CreateServer()) - { - var userId = "4611ce3f-380d-4db5-8d76-87a8689058ed"; - var content = new StringContent(BuildLocationsRequest(-121.040360, 48.091631), UTF8Encoding.UTF8, "application/json"); - - // Expected result - var expectedLocation = "WHT"; - - // Act - var response = await server.CreateClient() - .PostAsync(Post.AddNewLocation, content); - - var userLocationResponse = await server.CreateClient() - .GetAsync(Get.UserLocationBy(userId)); - - var responseBody = await userLocationResponse.Content.ReadAsStringAsync(); - var userLocation = JsonConvert.DeserializeObject(responseBody); - - var locationResponse = await server.CreateClient() - .GetAsync(Get.LocationBy(userLocation.LocationId)); - - responseBody = await locationResponse.Content.ReadAsStringAsync(); - var location = JsonConvert.DeserializeObject(responseBody); - - // Assert - Assert.Equal(expectedLocation, location.Code); - } - } - - [Fact] - public async Task Get_all_locations_response_ok_status_code() - { - using (var server = CreateServer()) - { - var response = await server.CreateClient() - .GetAsync(Get.Locations); - - var responseBody = await response.Content.ReadAsStringAsync(); - var locations = JsonConvert.DeserializeObject>(responseBody); - - // Assert - Assert.NotEmpty(locations); - } - } - - string BuildLocationsRequest(double lon, double lat) - { - var location = new LocationRequest() - { - Longitude = lon, - Latitude = lat - }; - return JsonConvert.SerializeObject(location); - } - } -} diff --git a/src/Services/Location/Locations.FunctionalTests/appsettings.json b/src/Services/Location/Locations.FunctionalTests/appsettings.json deleted file mode 100644 index 6880b2ee1..000000000 --- a/src/Services/Location/Locations.FunctionalTests/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ConnectionString": "mongodb://localhost:27017", - "Database": "LocationsDb", - "ExternalCatalogBaseUrl": "http://localhost:5101", - "IdentityUrl": "http://localhost:5105", - "isTest": "true", - "EventBusConnection": "localhost", - "SubscriptionClientName": "Locations", - "SuppressCheckForUnhandledSecurityMetadata":true -} diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/function.json b/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/function.json deleted file mode 100644 index 70b31994a..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/function.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "bindings": [ - { - "authLevel": "function", - "name": "req", - "type": "httpTrigger", - "direction": "in" - }, - { - "name": "$return", - "type": "http", - "direction": "out" - } - ], - "disabled": false -} \ No newline at end of file diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/project.json b/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/project.json deleted file mode 100644 index 97c3bba09..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - - "frameworks": { - - "net46":{ - - "dependencies": { - - "Dapper": "1.50.2", - - "System.Data.SqlClient":"4.1.0", - - "Microsoft.WindowsAzure.ConfigurationManager":"3.2.1" - - } - - } - - } - -} \ No newline at end of file diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/run.csx b/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/run.csx deleted file mode 100644 index 9ca9b5a3b..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/MarketingDetailsHttpTrigger/run.csx +++ /dev/null @@ -1,91 +0,0 @@ -using System.Net; -using System.Net.Http.Headers; -using System.Configuration; -using Dapper; -using System.Data.SqlClient; - -public static async Task Run(HttpRequestMessage req, TraceWriter log) -{ - log.Info($"Campaign HTTP trigger function processed a request. RequestUri={req.RequestUri}"); - - string htmlResponse = string.Empty; - - // parse query parameter - string campaignId = req.GetQueryNameValuePairs() - .FirstOrDefault(q => string.Compare(q.Key, "campaignId", true) == 0) - .Value; - - string userId = req.GetQueryNameValuePairs() - .FirstOrDefault(q => string.Compare(q.Key, "userId", true) == 0) - .Value; - - var cnnString = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString; - - using (var conn = new SqlConnection(cnnString)) - { - await conn.OpenAsync(); - var sql = "SELECT * FROM [dbo].[Campaign] WHERE Id = @CampaignId;"; - var campaign = (await conn.QueryAsync(sql, new { CampaignId = campaignId })).FirstOrDefault(); - htmlResponse = BuildHtmlResponse(campaign); - } - - var response = new HttpResponseMessage(HttpStatusCode.OK); - response.Content = new ByteArrayContent(System.Text.Encoding.UTF8.GetBytes(htmlResponse)); - response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); - - return response; -} - -private static string BuildHtmlResponse(Campaign campaign) -{ - var marketingStorageUri = ConfigurationManager.AppSettings["MarketingStorageUri"]; - - return string.Format(@" - - - - -
- Campaign Details -
- -
-
-
-
- Card image cap -
-

{1}

-

{2}

- -
-
-
-
- - ", - $"{marketingStorageUri}{campaign.PictureName}", - campaign.Name, - campaign.Description, - campaign.From.ToString("MMMM dd, yyyy"), - campaign.From.ToString("MMMM dd, yyyy")); -} - -public class Campaign -{ - public int Id { get; set; } - - public string Name { get; set; } - - public string Description { get; set; } - - public DateTime From { get; set; } - - public DateTime To { get; set; } - - public string PictureUri { get; set; } - - public string PictureName { get; set; } -} diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/host.json b/src/Services/Marketing/Infrastructure/AzureFunctions/host.json deleted file mode 100644 index 9e26dfeeb..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/host.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/local.settings.json b/src/Services/Marketing/Infrastructure/AzureFunctions/local.settings.json deleted file mode 100644 index 92d59f7e2..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/local.settings.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "IsEncrypted": false, - "Value": { - "APPSETTING_FUNCTIONS_EXTENSION_VERSION": "~1", - "APPSETTING_ScmType": "None", - "APPSETTING_WEBSITE_AUTH_ENABLED": "False", - "APPSETTING_REMOTEDEBUGGINGVERSION": "11.0.611103.400", - "APPSETTING_AzureWebJobsDashboard": "", - "APPSETTING_MarketingStorageUri": "", - "APPSETTING_WEBSITE_NODE_DEFAULT_VERSION": "6.5.0", - "APPSETTING_WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "", - "APPSETTING_WEBSITE_CONTENTSHARE": "", - "APPSETTING_WEBSITE_SLOT_NAME": "", - "APPSETTING_AzureWebJobsStorage": "", - "APPSETTING_WEBSITE_SITE_NAME": "" - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Infrastructure/AzureFunctions/marketing-functions.csproj b/src/Services/Marketing/Infrastructure/AzureFunctions/marketing-functions.csproj deleted file mode 100644 index 33e93b625..000000000 --- a/src/Services/Marketing/Infrastructure/AzureFunctions/marketing-functions.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - net461 - - - - - - - - - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - diff --git a/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs b/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs deleted file mode 100644 index 67ac1bca5..000000000 --- a/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs +++ /dev/null @@ -1,232 +0,0 @@ -using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers -{ - using System; - using System.Linq; - using System.Collections.Generic; - using Infrastructure.Repositories; - using AspNetCore.Mvc; - using Infrastructure; - using System.Threading.Tasks; - using Model; - using EntityFrameworkCore; - using Dto; - using AspNetCore.Authorization; - using Extensions.Options; - using Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel; - using Microsoft.AspNetCore.Http; - using System.Net; - - [Route("api/v1/[controller]")] - [Authorize] - [ApiController] - public class CampaignsController : ControllerBase - { - private readonly MarketingContext _context; - private readonly MarketingSettings _settings; - private readonly IMarketingDataRepository _marketingDataRepository; - private readonly IIdentityService _identityService; - - public CampaignsController(MarketingContext context, - IMarketingDataRepository marketingDataRepository, - IOptionsSnapshot settings, - IIdentityService identityService) - { - _context = context; - _marketingDataRepository = marketingDataRepository; - _settings = settings.Value; - _identityService = identityService; - } - - [HttpGet] - [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] - public async Task>> GetAllCampaignsAsync() - { - var campaignList = await _context.Campaigns.ToListAsync(); - - if (campaignList is null) - { - return Ok(); - } - - return MapCampaignModelListToDtoList(campaignList); - } - - [HttpGet("{id:int}")] - [ProducesResponseType(typeof(CampaignDTO), (int)HttpStatusCode.OK)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task> GetCampaignByIdAsync(int id) - { - var campaign = await _context.Campaigns.SingleOrDefaultAsync(c => c.Id == id); - - if (campaign is null) - { - return NotFound(); - } - - return MapCampaignModelToDto(campaign); - } - - [HttpPost] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.Created)] - public async Task CreateCampaignAsync([FromBody] CampaignDTO campaignDto) - { - if (campaignDto is null) - { - return BadRequest(); - } - - var campaign = MapCampaignDtoToModel(campaignDto); - - await _context.Campaigns.AddAsync(campaign); - await _context.SaveChangesAsync(); - - return CreatedAtAction(nameof(GetCampaignByIdAsync), new { id = campaign.Id }, null); - } - - [HttpPut("{id:int}")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [ProducesResponseType((int)HttpStatusCode.Created)] - public async Task UpdateCampaignAsync(int id, [FromBody] CampaignDTO campaignDto) - { - if (id < 1 || campaignDto is null) - { - return BadRequest(); - } - - var campaignToUpdate = await _context.Campaigns.FindAsync(id); - if (campaignToUpdate is null) - { - return NotFound(); - } - - campaignToUpdate.Name = campaignDto.Name; - campaignToUpdate.Description = campaignDto.Description; - campaignToUpdate.From = campaignDto.From; - campaignToUpdate.To = campaignDto.To; - campaignToUpdate.PictureUri = campaignDto.PictureUri; - - await _context.SaveChangesAsync(); - - return CreatedAtAction(nameof(GetCampaignByIdAsync), new { id = campaignToUpdate.Id }, null); - } - - [HttpDelete("{id:int}")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [ProducesResponseType((int)HttpStatusCode.NoContent)] - public async Task DeleteCampaignByIdAsync(int id) - { - if (id < 1) - { - return BadRequest(); - } - - var campaignToDelete = await _context.Campaigns.FindAsync(id); - - if (campaignToDelete is null) - { - return NotFound(); - } - - _context.Campaigns.Remove(campaignToDelete); - await _context.SaveChangesAsync(); - - return NoContent(); - } - - [HttpGet("user")] - [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] - public async Task>> GetCampaignsByUserIdAsync( int pageSize = 10, int pageIndex = 0) - { - var userId = _identityService.GetUserIdentity(); - - var marketingData = await _marketingDataRepository.GetAsync(userId.ToString()); - - var campaignDtoList = new List(); - - if (marketingData != null) - { - var locationIdCandidateList = marketingData.Locations.Select(x => x.LocationId); - var userCampaignList = await _context.Rules - .OfType() - .Include(c => c.Campaign) - .Where(c => c.Campaign.From <= DateTime.Now - && c.Campaign.To >= DateTime.Now - && locationIdCandidateList.Contains(c.LocationId)) - .Select(c => c.Campaign) - .ToListAsync(); - - if (userCampaignList != null && userCampaignList.Any()) - { - var userCampaignDtoList = MapCampaignModelListToDtoList(userCampaignList); - campaignDtoList.AddRange(userCampaignDtoList); - } - } - - var totalItems = campaignDtoList.Count(); - - campaignDtoList = campaignDtoList - .Skip(pageSize * pageIndex) - .Take(pageSize).ToList(); - - return new PaginatedItemsViewModel(pageIndex, pageSize, totalItems, campaignDtoList); - } - - private List MapCampaignModelListToDtoList(List campaignList) - { - var campaignDtoList = new List(); - - campaignList.ForEach(campaign => campaignDtoList - .Add(MapCampaignModelToDto(campaign))); - - return campaignDtoList; - } - - private CampaignDTO MapCampaignModelToDto(Campaign campaign) - { - var userId = _identityService.GetUserIdentity(); - var dto = new CampaignDTO - { - Id = campaign.Id, - Name = campaign.Name, - Description = campaign.Description, - From = campaign.From, - To = campaign.To, - PictureUri = GetUriPlaceholder(campaign), - }; - - if (!string.IsNullOrEmpty(_settings.CampaignDetailFunctionUri)) - { - dto.DetailsUri = $"{_settings.CampaignDetailFunctionUri}&campaignId={campaign.Id}&userId={userId}"; - } - - return dto; - } - - private Campaign MapCampaignDtoToModel(CampaignDTO campaignDto) - { - return new Campaign - { - Id = campaignDto.Id, - Name = campaignDto.Name, - Description = campaignDto.Description, - From = campaignDto.From, - To = campaignDto.To, - PictureUri = campaignDto.PictureUri - }; - } - - private string GetUriPlaceholder(Campaign campaign) - { - var baseUri = _settings.PicBaseUrl; - - return _settings.AzureStorageEnabled - ? baseUri + campaign.PictureName - : baseUri.Replace("[0]", campaign.Id.ToString()); - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Controllers/HomeController.cs b/src/Services/Marketing/Marketing.API/Controllers/HomeController.cs deleted file mode 100644 index d37386b9a..000000000 --- a/src/Services/Marketing/Marketing.API/Controllers/HomeController.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers -{ - using Microsoft.AspNetCore.Mvc; - - // GET: // - public class HomeController : Controller - { - public IActionResult Index() - { - return new RedirectResult("~/swagger"); - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Controllers/LocationsController.cs b/src/Services/Marketing/Marketing.API/Controllers/LocationsController.cs deleted file mode 100644 index 7d5959cb5..000000000 --- a/src/Services/Marketing/Marketing.API/Controllers/LocationsController.cs +++ /dev/null @@ -1,151 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers -{ - using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.Mvc; - using Microsoft.eShopOnContainers.Services.Marketing.API.Dto; - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; - using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Threading.Tasks; - - [Authorize] - [ApiController] - public class LocationsController : ControllerBase - { - private readonly MarketingContext _context; - - public LocationsController(MarketingContext context) - { - _context = context; - } - - [HttpGet] - [Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [ProducesResponseType(typeof(UserLocationRuleDTO),(int)HttpStatusCode.OK)] - public ActionResult GetLocationByCampaignAndLocationRuleId(int campaignId, - int userLocationRuleId) - { - if (campaignId < 1 || userLocationRuleId < 1) - { - return BadRequest(); - } - - var location = _context.Rules - .OfType() - .SingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId); - - if (location is null) - { - return NotFound(); - } - - return MapUserLocationRuleModelToDto(location); - } - - [HttpGet] - [Route("api/v1/campaigns/{campaignId:int}/locations")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.OK)] - [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] - public ActionResult> GetAllLocationsByCampaignId(int campaignId) - { - if (campaignId < 1) - { - return BadRequest(); - } - - var locationList = _context.Rules - .OfType() - .Where(c => c.CampaignId == campaignId) - .ToList(); - - if(locationList is null) - { - return Ok(); - } - - return MapUserLocationRuleModelListToDtoList(locationList); - } - - [HttpPost] - [Route("api/v1/campaigns/{campaignId:int}/locations")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.Created)] - public async Task CreateLocationAsync(int campaignId, [FromBody] UserLocationRuleDTO locationRuleDto) - { - if (campaignId < 1 || locationRuleDto is null) - { - return BadRequest(); - } - - var locationRule = MapUserLocationRuleDtoToModel(locationRuleDto); - locationRule.CampaignId = campaignId; - - await _context.Rules.AddAsync(locationRule); - await _context.SaveChangesAsync(); - - return CreatedAtAction(nameof(GetLocationByCampaignAndLocationRuleId), - new { campaignId = campaignId, userLocationRuleId = locationRule.Id }, null); - } - - [HttpDelete] - [Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}")] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task DeleteLocationByIdAsync(int campaignId, int userLocationRuleId) - { - if (campaignId < 1 || userLocationRuleId < 1) - { - return BadRequest(); - } - - var locationToDelete = _context.Rules - .OfType() - .SingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId); - - if (locationToDelete is null) - { - return NotFound(); - } - - _context.Rules.Remove(locationToDelete); - await _context.SaveChangesAsync(); - - return NoContent(); - } - - private List MapUserLocationRuleModelListToDtoList(List userLocationRuleList) - { - var userLocationRuleDtoList = new List(); - - userLocationRuleList.ForEach(userLocationRule => userLocationRuleDtoList - .Add(MapUserLocationRuleModelToDto(userLocationRule))); - - return userLocationRuleDtoList; - } - - private UserLocationRuleDTO MapUserLocationRuleModelToDto(UserLocationRule userLocationRule) - { - return new UserLocationRuleDTO - { - Id = userLocationRule.Id, - Description = userLocationRule.Description, - LocationId = userLocationRule.LocationId - }; - } - - private UserLocationRule MapUserLocationRuleDtoToModel(UserLocationRuleDTO userLocationRuleDto) - { - return new UserLocationRule - { - Id = userLocationRuleDto.Id, - Description = userLocationRuleDto.Description, - LocationId = userLocationRuleDto.LocationId - }; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Controllers/PicController.cs b/src/Services/Marketing/Marketing.API/Controllers/PicController.cs deleted file mode 100644 index 740f4975b..000000000 --- a/src/Services/Marketing/Marketing.API/Controllers/PicController.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers -{ - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Mvc; - using System.IO; - - [ApiController] - public class PicController : ControllerBase - { - private readonly IWebHostEnvironment _env; - public PicController(IWebHostEnvironment env) - { - _env = env; - } - - [HttpGet] - [Route("api/v1/campaigns/{campaignId:int}/pic")] - public ActionResult GetImage(int campaignId) - { - var webRoot = _env.WebRootPath; - var path = Path.Combine(webRoot, campaignId + ".png"); - - var buffer = System.IO.File.ReadAllBytes(path); - - return File(buffer, "image/png"); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Dockerfile b/src/Services/Marketing/Marketing.API/Dockerfile deleted file mode 100644 index e7a3f120b..000000000 --- a/src/Services/Marketing/Marketing.API/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base -WORKDIR /app -EXPOSE 80 - -FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build -WORKDIR /src - -# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles -# to take advantage of Docker's build cache, to speed up local container builds -COPY "eShopOnContainers-ServicesAndWebApps.sln" "eShopOnContainers-ServicesAndWebApps.sln" - -COPY "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" "ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj" -COPY "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" "ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj" -COPY "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" -COPY "BuildingBlocks/EventBus/EventBus/EventBus.csproj" "BuildingBlocks/EventBus/EventBus/EventBus.csproj" -COPY "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" -COPY "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" -COPY "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" -COPY "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" -COPY "Services/Basket/Basket.API/Basket.API.csproj" "Services/Basket/Basket.API/Basket.API.csproj" -COPY "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" "Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj" -COPY "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" "Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj" -COPY "Services/Catalog/Catalog.API/Catalog.API.csproj" "Services/Catalog/Catalog.API/Catalog.API.csproj" -COPY "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" "Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj" -COPY "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" "Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj" -COPY "Services/Identity/Identity.API/Identity.API.csproj" "Services/Identity/Identity.API/Identity.API.csproj" -COPY "Services/Location/Locations.API/Locations.API.csproj" "Services/Location/Locations.API/Locations.API.csproj" -COPY "Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj" "Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj" -COPY "Services/Marketing/Marketing.API/Marketing.API.csproj" "Services/Marketing/Marketing.API/Marketing.API.csproj" -COPY "Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj" "Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj" -COPY "Services/Ordering/Ordering.API/Ordering.API.csproj" "Services/Ordering/Ordering.API/Ordering.API.csproj" -COPY "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" "Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj" -COPY "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" "Services/Ordering/Ordering.Domain/Ordering.Domain.csproj" -COPY "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" "Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj" -COPY "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" "Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj" -COPY "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" "Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj" -COPY "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" "Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj" -COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj" -COPY "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" "Services/Webhooks/Webhooks.API/Webhooks.API.csproj" -COPY "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" "Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj" -COPY "Web/WebhookClient/WebhookClient.csproj" "Web/WebhookClient/WebhookClient.csproj" -COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj" -COPY "Web/WebSPA/WebSPA.csproj" "Web/WebSPA/WebSPA.csproj" -COPY "Web/WebStatus/WebStatus.csproj" "Web/WebStatus/WebStatus.csproj" - -COPY "docker-compose.dcproj" "docker-compose.dcproj" - -COPY "NuGet.config" "NuGet.config" - -RUN dotnet restore "eShopOnContainers-ServicesAndWebApps.sln" - -COPY . . -WORKDIR /src/Services/Marketing/Marketing.API -RUN dotnet publish --no-restore -c Release -o /app - -FROM build as functionaltest -WORKDIR /src/Services/Marketing/Marketing.FunctionalTests - -FROM build AS publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app . -ENTRYPOINT ["dotnet", "Marketing.API.dll"] diff --git a/src/Services/Marketing/Marketing.API/Dockerfile.develop b/src/Services/Marketing/Marketing.API/Dockerfile.develop deleted file mode 100644 index 8425f47c1..000000000 --- a/src/Services/Marketing/Marketing.API/Dockerfile.develop +++ /dev/null @@ -1,18 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster -ARG BUILD_CONFIGURATION=Debug -ENV ASPNETCORE_ENVIRONMENT=Development -ENV DOTNET_USE_POLLING_FILE_WATCHER=true -EXPOSE 80 - -WORKDIR /src -COPY [Services/Marketing/Marketing.API/Marketing.API.csproj", "Services/Marketing/Marketing.API/"] -COPY [BuildingBlocks/EventBus/EventBus/EventBus.csproj", "BuildingBlocks/EventBus/EventBus/"] -COPY [BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj", "BuildingBlocks/EventBus/EventBusRabbitMQ/"] -COPY [BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj", "BuildingBlocks/EventBus/EventBusServiceBus/"] -COPY [BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj", "BuildingBlocks/WebHostCustomization/WebHost.Customization/"] -RUN dotnet restore Services/Marketing/Marketing.API/Marketing.API.csproj -nowarn:msb3202,nu1503 -COPY . . -WORKDIR "/src/Services/Marketing/Marketing.API" -RUN dotnet build --no-restore -c $BUILD_CONFIGURATION - -ENTRYPOINT ["dotnet", "run", "--no-build", "--no-launch-profile", "-c", "$BUILD_CONFIGURATION", "--"] diff --git a/src/Services/Marketing/Marketing.API/Dto/CampaignDTO.cs b/src/Services/Marketing/Marketing.API/Dto/CampaignDTO.cs deleted file mode 100644 index 3c409c8a9..000000000 --- a/src/Services/Marketing/Marketing.API/Dto/CampaignDTO.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Dto -{ - using System; - - public class CampaignDTO - { - public int Id { get; set; } - - public string Name { get; set; } - - public string Description { get; set; } - - public DateTime From { get; set; } - - public DateTime To { get; set; } - - public string PictureUri { get; set; } - public string DetailsUri { get; set; } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs b/src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs deleted file mode 100644 index 3400b0dda..000000000 --- a/src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Dto -{ - public class UserLocationDTO - { - public string Id { get; set; } - public Guid UserId { get; set; } - public int LocationId { get; set; } - public DateTime UpdateDate { get; set; } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Dto/UserLocationRuleDTO.cs b/src/Services/Marketing/Marketing.API/Dto/UserLocationRuleDTO.cs deleted file mode 100644 index a76eb90a0..000000000 --- a/src/Services/Marketing/Marketing.API/Dto/UserLocationRuleDTO.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Dto -{ - public class UserLocationRuleDTO - { - public int Id { get; set; } - - public int LocationId { get; set; } - - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs b/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs deleted file mode 100644 index 5975d92af..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults -{ - using AspNetCore.Http; - using Microsoft.AspNetCore.Mvc; - - public class InternalServerErrorObjectResult : ObjectResult - { - public InternalServerErrorObjectResult(object error) - : base(error) - { - StatusCode = StatusCodes.Status500InternalServerError; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/CampaignEntityTypeConfiguration.cs b/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/CampaignEntityTypeConfiguration.cs deleted file mode 100644 index 22292e53f..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/CampaignEntityTypeConfiguration.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.EntityConfigurations -{ - class CampaignEntityTypeConfiguration - : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Campaign"); - - builder.HasKey(m => m.Id); - - builder.Property(m => m.Id) - .UseHiLo("campaign_hilo") - .IsRequired(); - - builder.Property(m => m.Name) - .HasColumnName("Name") - .IsRequired(); - - builder.Property(m => m.From) - .HasColumnName("From") - .IsRequired(); - - builder.Property(m => m.To) - .HasColumnName("To") - .IsRequired(); - - builder.Property(m => m.Description) - .HasColumnName("Description") - .IsRequired(); - - builder.Property(m => m.PictureUri) - .HasColumnName("PictureUri") - .IsRequired(); - - builder.HasMany(m => m.Rules) - .WithOne(r => r.Campaign) - .HasForeignKey(r => r.CampaignId) - .IsRequired(); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/RuleEntityTypeConfiguration.cs b/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/RuleEntityTypeConfiguration.cs deleted file mode 100644 index ebf1d1b3a..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/RuleEntityTypeConfiguration.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.EntityConfigurations -{ - class RuleEntityTypeConfiguration - : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Rule"); - - builder.HasKey(r => r.Id); - - builder.Property(r => r.Id) - .UseHiLo("rule_hilo") - .IsRequired(); - - builder.HasDiscriminator("RuleTypeId") - .HasValue(RuleType.UserProfileRule.Id) - .HasValue(RuleType.PurchaseHistoryRule.Id) - .HasValue(RuleType.UserLocationRule.Id); - - builder.Property(r => r.Description) - .HasColumnName("Description") - .IsRequired(); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/UserLocationRuleEntityTypeConfiguration.cs b/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/UserLocationRuleEntityTypeConfiguration.cs deleted file mode 100644 index 84840d3a5..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/EntityConfigurations/UserLocationRuleEntityTypeConfiguration.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.EntityConfigurations -{ - class UserLocationRuleEntityTypeConfiguration - : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.Property(r => r.LocationId) - .HasColumnName("LocationId") - .IsRequired(); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Exceptions/MarketingDomainException.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Exceptions/MarketingDomainException.cs deleted file mode 100644 index 68ccd9e52..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Exceptions/MarketingDomainException.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions -{ - using System; - - /// - /// Exception type for app exceptions - /// - public class MarketingDomainException : Exception - { - public MarketingDomainException() - { } - - public MarketingDomainException(string message) - : base(message) - { } - - public MarketingDomainException(string message, Exception innerException) - : base(message, innerException) - { } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs deleted file mode 100644 index d013597d9..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters -{ - public class AuthorizeCheckOperationFilter : IOperationFilter - { - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - // Check for authorize attribute - var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType().Any() || - context.MethodInfo.GetCustomAttributes(true).OfType().Any(); - - if (!hasAuthorize) return; - - operation.Responses.TryAdd("401", new OpenApiResponse { Description = "Unauthorized" }); - operation.Responses.TryAdd("403", new OpenApiResponse { Description = "Forbidden" }); - - var oAuthScheme = new OpenApiSecurityScheme - { - Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" } - }; - - operation.Security = new List - { - new OpenApiSecurityRequirement - { - [ oAuthScheme ] = new [] { "marketingapi" } - } - }; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index 19c5ab038..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -1,68 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters -{ - using AspNetCore.Mvc; - using global::Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions; - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Mvc.Filters; - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults; - using Microsoft.Extensions.Hosting; - using Microsoft.Extensions.Logging; - using System.Net; - - public class HttpGlobalExceptionFilter : IExceptionFilter - { - private readonly IWebHostEnvironment env; - private readonly ILogger logger; - - public HttpGlobalExceptionFilter(IWebHostEnvironment env, ILogger logger) - { - this.env = env; - this.logger = logger; - } - - public void OnException(ExceptionContext context) - { - logger.LogError(new EventId(context.Exception.HResult), - context.Exception, - context.Exception.Message); - - if (context.Exception.GetType() == typeof(MarketingDomainException)) - { - var json = new JsonErrorResponse - { - Messages = new[] { context.Exception.Message } - }; - - // Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1 - //It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information - context.Result = new BadRequestObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; - } - else - { - var json = new JsonErrorResponse - { - Messages = new[] { "An error occur.Try it again." } - }; - - if (env.IsDevelopment()) - { - json.DeveloperMessage = context.Exception; - } - - // Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1 - // It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information - context.Result = new InternalServerErrorObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; - } - context.ExceptionHandled = true; - } - - private class JsonErrorResponse - { - public string[] Messages { get; set; } - - public object DeveloperMessage { get; set; } - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContext.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContext.cs deleted file mode 100644 index e06106b5e..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContext.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure -{ - using System; - using System.IO; - using EntityConfigurations; - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Design; - using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - using Microsoft.Extensions.Configuration; - - public class MarketingContext : DbContext - { - public MarketingContext(DbContextOptions options) : base(options) - { - } - - public DbSet Campaigns { get; set; } - - public DbSet Rules { get; set; } - - protected override void OnModelCreating(ModelBuilder builder) - { - builder.ApplyConfiguration(new CampaignEntityTypeConfiguration()); - builder.ApplyConfiguration(new RuleEntityTypeConfiguration()); - builder.ApplyConfiguration(new UserLocationRuleEntityTypeConfiguration()); - } - } - - public class MarketingContextDesignFactory : IDesignTimeDbContextFactory - { - public MarketingContext CreateDbContext(string[] args) - { - IConfigurationRoot configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables() - .Build(); - - var connectionString = configuration["ConnectionString"]; - var optionsBuilder = new DbContextOptionsBuilder() - .UseSqlServer(connectionString); - return new MarketingContext(optionsBuilder.Options); - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs deleted file mode 100644 index ac800909e..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure -{ - using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - using Microsoft.Extensions.Logging; - using Polly; - using Polly.Retry; - using System; - using System.Collections.Generic; - using System.Data.SqlClient; - using System.Linq; - using System.Threading.Tasks; - - public class MarketingContextSeed - { - public async Task SeedAsync(MarketingContext context,ILogger logger,int retries = 3) - { - var policy = CreatePolicy(retries, logger, nameof(MarketingContextSeed)); - - await policy.ExecuteAsync(async () => - { - if (!context.Campaigns.Any()) - { - await context.Campaigns.AddRangeAsync( - GetPreconfiguredMarketings()); - - await context.SaveChangesAsync(); - } - }); - } - - private List GetPreconfiguredMarketings() - { - return new List - { - new Campaign - { - Name = ".NET Bot Black Hoodie 50% OFF", - Description = "Campaign Description 1", - From = DateTime.Now, - To = DateTime.Now.AddDays(7), - PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/campaigns/1/pic", - PictureName = "1.png", - Rules = new List - { - new UserLocationRule - { - Description = "Campaign is only for United States users.", - LocationId = 1 - } - } - }, - new Campaign - { - Name = "Roslyn Red T-Shirt 3x2", - Description = "Campaign Description 2", - From = DateTime.Now.AddDays(-7), - To = DateTime.Now.AddDays(14), - PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/campaigns/2/pic", - PictureName = "2.png", - Rules = new List - { - new UserLocationRule - { - Description = "Campaign is only for Seattle users.", - LocationId = 3 - } - } - } - }; - } - - private AsyncRetryPolicy CreatePolicy(int retries, ILogger logger, string prefix) - { - return Policy.Handle(). - WaitAndRetryAsync( - retryCount: retries, - sleepDurationProvider: retry => TimeSpan.FromSeconds(5), - onRetry: (exception, timeSpan, retry, ctx) => - { - logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries); - } - ); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.Designer.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.Designer.cs deleted file mode 100644 index b4696a8f3..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.Designer.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations -{ - [DbContext(typeof(MarketingContext))] - [Migration("20170615163431_Init")] - partial class Init - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2") - .HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:Sequence:.rule_hilo", "'rule_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "campaign_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("From") - .HasColumnName("From"); - - b.Property("Name") - .IsRequired() - .HasColumnName("Name"); - - b.Property("PictureUri") - .IsRequired() - .HasColumnName("PictureUri"); - - b.Property("To") - .HasColumnName("To"); - - b.HasKey("Id"); - - b.ToTable("Campaign"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("CampaignId"); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("RuleTypeId"); - - b.HasKey("Id"); - - b.HasIndex("CampaignId"); - - b.ToTable("Rule"); - - b.HasDiscriminator("RuleTypeId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.PurchaseHistoryRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("PurchaseHistoryRule"); - - b.HasDiscriminator().HasValue(2); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserLocationRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - b.Property("LocationId") - .HasColumnName("LocationId"); - - b.ToTable("UserLocationRule"); - - b.HasDiscriminator().HasValue(3); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserProfileRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("UserProfileRule"); - - b.HasDiscriminator().HasValue(1); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", "Campaign") - .WithMany("Rules") - .HasForeignKey("CampaignId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.cs deleted file mode 100644 index 92398f1a8..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170615163431_Init.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations -{ - public partial class Init : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateSequence( - name: "campaign_hilo", - incrementBy: 10); - - migrationBuilder.CreateSequence( - name: "rule_hilo", - incrementBy: 10); - - migrationBuilder.CreateTable( - name: "Campaign", - columns: table => new - { - Id = table.Column(nullable: false), - Description = table.Column(nullable: false), - From = table.Column(nullable: false), - Name = table.Column(nullable: false), - PictureUri = table.Column(nullable: false), - To = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Campaign", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Rule", - columns: table => new - { - Id = table.Column(nullable: false), - CampaignId = table.Column(nullable: false), - Description = table.Column(nullable: false), - RuleTypeId = table.Column(nullable: false), - LocationId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Rule", x => x.Id); - table.ForeignKey( - name: "FK_Rule_Campaign_CampaignId", - column: x => x.CampaignId, - principalTable: "Campaign", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Rule_CampaignId", - table: "Rule", - column: "CampaignId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Rule"); - - migrationBuilder.DropTable( - name: "Campaign"); - - migrationBuilder.DropSequence( - name: "campaign_hilo"); - - migrationBuilder.DropSequence( - name: "rule_hilo"); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.Designer.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.Designer.cs deleted file mode 100644 index 342d1d02f..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.Designer.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations -{ - [DbContext(typeof(MarketingContext))] - [Migration("20170629102516_added-campaign-details")] - partial class addedcampaigndetails - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2") - .HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:Sequence:.rule_hilo", "'rule_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "campaign_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("DetailsUri"); - - b.Property("From") - .HasColumnName("From"); - - b.Property("Name") - .IsRequired() - .HasColumnName("Name"); - - b.Property("PictureName"); - - b.Property("PictureUri") - .IsRequired() - .HasColumnName("PictureUri"); - - b.Property("To") - .HasColumnName("To"); - - b.HasKey("Id"); - - b.ToTable("Campaign"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("CampaignId"); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("RuleTypeId"); - - b.HasKey("Id"); - - b.HasIndex("CampaignId"); - - b.ToTable("Rule"); - - b.HasDiscriminator("RuleTypeId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.PurchaseHistoryRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("PurchaseHistoryRule"); - - b.HasDiscriminator().HasValue(2); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserLocationRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - b.Property("LocationId") - .HasColumnName("LocationId"); - - b.ToTable("UserLocationRule"); - - b.HasDiscriminator().HasValue(3); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserProfileRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("UserProfileRule"); - - b.HasDiscriminator().HasValue(1); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", "Campaign") - .WithMany("Rules") - .HasForeignKey("CampaignId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.cs deleted file mode 100644 index 5b7c7ef6c..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/20170629102516_added-campaign-details.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations -{ - public partial class addedcampaigndetails : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DetailsUri", - table: "Campaign", - nullable: true); - - migrationBuilder.AddColumn( - name: "PictureName", - table: "Campaign", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DetailsUri", - table: "Campaign"); - - migrationBuilder.DropColumn( - name: "PictureName", - table: "Campaign"); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/MarketingContextModelSnapshot.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/MarketingContextModelSnapshot.cs deleted file mode 100644 index a79055954..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingMigrations/MarketingContextModelSnapshot.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.MarketingMigrations -{ - [DbContext(typeof(MarketingContext))] - partial class MarketingContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2") - .HasAnnotation("SqlServer:Sequence:.campaign_hilo", "'campaign_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:Sequence:.rule_hilo", "'rule_hilo', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "campaign_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("DetailsUri"); - - b.Property("From") - .HasColumnName("From"); - - b.Property("Name") - .IsRequired() - .HasColumnName("Name"); - - b.Property("PictureName"); - - b.Property("PictureUri") - .IsRequired() - .HasColumnName("PictureUri"); - - b.Property("To") - .HasColumnName("To"); - - b.HasKey("Id"); - - b.ToTable("Campaign"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "rule_hilo") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); - - b.Property("CampaignId"); - - b.Property("Description") - .IsRequired() - .HasColumnName("Description"); - - b.Property("RuleTypeId"); - - b.HasKey("Id"); - - b.HasIndex("CampaignId"); - - b.ToTable("Rule"); - - b.HasDiscriminator("RuleTypeId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.PurchaseHistoryRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("PurchaseHistoryRule"); - - b.HasDiscriminator().HasValue(2); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserLocationRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - b.Property("LocationId") - .HasColumnName("LocationId"); - - b.ToTable("UserLocationRule"); - - b.HasDiscriminator().HasValue(3); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.UserProfileRule", b => - { - b.HasBaseType("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule"); - - - b.ToTable("UserProfileRule"); - - b.HasDiscriminator().HasValue(1); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Rule", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Marketing.API.Model.Campaign", "Campaign") - .WithMany("Rules") - .HasForeignKey("CampaignId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingReadDataContext.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingReadDataContext.cs deleted file mode 100644 index b16968617..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingReadDataContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure -{ - using Microsoft.eShopOnContainers.Services.Marketing.API.Model; - using Microsoft.Extensions.Options; - using MongoDB.Driver; - - public class MarketingReadDataContext - { - private readonly IMongoDatabase _database = null; - - public MarketingReadDataContext(IOptions settings) - { - var client = new MongoClient(settings.Value.MongoConnectionString); - - if (client != null) - { - _database = client.GetDatabase(settings.Value.MongoDatabase); - } - } - - public IMongoCollection MarketingData - { - get - { - return _database.GetCollection("MarketingReadDataModel"); - } - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index 6f4ff16e2..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Primitives; -using System; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares -{ - class ByPassAuthMiddleware - { - private readonly RequestDelegate _next; - private string _currentUserId; - public ByPassAuthMiddleware(RequestDelegate next) - { - _next = next; - _currentUserId = null; - } - - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path == "/noauth") - { - var userid = context.Request.Query["userid"]; - if (!string.IsNullOrEmpty(userid)) - { - _currentUserId = userid; - } - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to {_currentUserId}"); - } - - else if (path == "/noauth/reset") - { - _currentUserId = null; - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to none. Token required for protected endpoints."); - } - else - { - var currentUserId = _currentUserId; - - var authHeader = context.Request.Headers["Authorization"]; - if (authHeader != StringValues.Empty) - { - var header = authHeader.FirstOrDefault(); - if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length) - { - currentUserId = header.Substring("Email ".Length); - } - } - - - if (!string.IsNullOrEmpty(currentUserId)) - { - var user = new ClaimsIdentity(new[] { - new Claim("emails", currentUserId), - new Claim("name", "Test user"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"), - new Claim("nonce", Guid.NewGuid().ToString()), - new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), - new Claim("sub", currentUserId), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} - , "ByPassAuth"); - - context.User = new ClaimsPrincipal(user); - } - - await _next.Invoke(context); - } - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/IMarketingDataRepository.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/IMarketingDataRepository.cs deleted file mode 100644 index 12a4bf2f8..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/IMarketingDataRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Repositories -{ - using Model; - using System.Threading.Tasks; - - public interface IMarketingDataRepository - { - Task GetAsync(string userId); - Task UpdateLocationAsync(MarketingData marketingData); - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/MarketingDataRepository.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/MarketingDataRepository.cs deleted file mode 100644 index 4e531a84c..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Repositories/MarketingDataRepository.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.eShopOnContainers.Services.Marketing.API.Model; -using Microsoft.Extensions.Options; -using MongoDB.Driver; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Repositories -{ - public class MarketingDataRepository - : IMarketingDataRepository - { - private readonly MarketingReadDataContext _context; - - public MarketingDataRepository(IOptions settings) - { - _context = new MarketingReadDataContext(settings); - } - - public async Task GetAsync(string userId) - { - var filter = Builders.Filter.Eq("UserId", userId); - return await _context.MarketingData - .Find(filter) - .FirstOrDefaultAsync(); - } - - public async Task UpdateLocationAsync(MarketingData marketingData) - { - var filter = Builders.Filter.Eq("UserId", marketingData.UserId); - var update = Builders.Update - .Set("Locations", marketingData.Locations) - .CurrentDate("UpdateDate"); - - await _context.MarketingData - .UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = true }); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Services/IIdentityService.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Services/IIdentityService.cs deleted file mode 100644 index 42df49ebc..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Services/IIdentityService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services -{ - public interface IIdentityService - { - string GetUserIdentity(); - } -} diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Services/IdentityService.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Services/IdentityService.cs deleted file mode 100644 index 82ce214be..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Services/IdentityService.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services -{ - using AspNetCore.Http; - using System; - - public class IdentityService : IIdentityService - { - private IHttpContextAccessor _context; - - public IdentityService(IHttpContextAccessor context) - { - _context = context ?? throw new ArgumentNullException(nameof(context)); - } - - public string GetUserIdentity() - { - return _context.HttpContext.User.FindFirst("sub").Value; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs b/src/Services/Marketing/Marketing.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs deleted file mode 100644 index b73e7b659..000000000 --- a/src/Services/Marketing/Marketing.API/IntegrationEvents/Events/UserLocationUpdatedIntegrationEvent.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.IntegrationEvents.Events -{ - using Marketing.API.Model; - using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - using System.Collections.Generic; - - public class UserLocationUpdatedIntegrationEvent : IntegrationEvent - { - public string UserId { get; set; } - - public List LocationList { get; set; } - - public UserLocationUpdatedIntegrationEvent(string userId, List locationList) - { - UserId = userId; - LocationList = locationList; - } - } -} diff --git a/src/Services/Marketing/Marketing.API/IntegrationEvents/Handlers/UserLocationUpdatedIntegrationEventHandler.cs b/src/Services/Marketing/Marketing.API/IntegrationEvents/Handlers/UserLocationUpdatedIntegrationEventHandler.cs deleted file mode 100644 index 3d5e62e45..000000000 --- a/src/Services/Marketing/Marketing.API/IntegrationEvents/Handlers/UserLocationUpdatedIntegrationEventHandler.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.IntegrationEvents.Handlers -{ - using Marketing.API.IntegrationEvents.Events; - using Marketing.API.Model; - using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Repositories; - using Microsoft.Extensions.Logging; - using Serilog.Context; - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - - public class UserLocationUpdatedIntegrationEventHandler - : IIntegrationEventHandler - { - private readonly IMarketingDataRepository _marketingDataRepository; - private readonly ILogger _logger; - - public UserLocationUpdatedIntegrationEventHandler( - IMarketingDataRepository repository, - ILogger logger) - { - _marketingDataRepository = repository ?? throw new ArgumentNullException(nameof(repository)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } - - public async Task Handle(UserLocationUpdatedIntegrationEvent @event) - { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - - var userMarketingData = await _marketingDataRepository.GetAsync(@event.UserId); - userMarketingData = userMarketingData ?? - new MarketingData() { UserId = @event.UserId }; - - userMarketingData.Locations = MapUpdatedUserLocations(@event.LocationList); - await _marketingDataRepository.UpdateLocationAsync(userMarketingData); - } - } - - private List MapUpdatedUserLocations(List newUserLocations) - { - var result = new List(); - newUserLocations.ForEach(location => { - result.Add(new Location() - { - LocationId = location.LocationId, - Code = location.Code, - Description = location.Description - }); - }); - - return result; - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj deleted file mode 100644 index bc3116fc3..000000000 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - netcoreapp3.1 - ..\..\..\..\docker-compose.dcproj - Microsoft.eShopOnContainers.Services.Marketing.API - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; - false - true - aspnet-Marketing.API-20161122013619 - - /subscriptions/6c22bb55-0221-4ce4-9bf1-3c4a10a7294c/resourcegroups/eshop-log/providers/microsoft.insights/components/eshopappinsights - /subscriptions/6c22bb55-0221-4ce4-9bf1-3c4a10a7294c/resourcegroups/eshop-log/providers/microsoft.insights/components/eshopappinsights - preview - - - - - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - - diff --git a/src/Services/Marketing/Marketing.API/MarketingSettings.cs b/src/Services/Marketing/Marketing.API/MarketingSettings.cs deleted file mode 100644 index 20e5d9c44..000000000 --- a/src/Services/Marketing/Marketing.API/MarketingSettings.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API -{ - public class MarketingSettings - { - public string ConnectionString { get; set; } - public string MongoConnectionString { get; set; } - public string MongoDatabase { get; set; } - public string ExternalCatalogBaseUrl { get; set; } - public string CampaignDetailFunctionUri { get; set; } - public string PicBaseUrl { get; set; } - public bool AzureStorageEnabled { get; set; } - } -} diff --git a/src/Services/Marketing/Marketing.API/Model/Campaign.cs b/src/Services/Marketing/Marketing.API/Model/Campaign.cs deleted file mode 100644 index 841580427..000000000 --- a/src/Services/Marketing/Marketing.API/Model/Campaign.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - using System; - using System.Collections.Generic; - - public class Campaign - { - public int Id { get; set; } - - public string Name { get; set; } - - public string Description { get; set; } - - public DateTime From { get; set; } - - public DateTime To { get; set; } - - public string PictureName { get; set; } - - public string PictureUri { get; set; } - - public string DetailsUri { get; set; } - - public List Rules { get; set; } - - - public Campaign() - { - Rules = new List(); - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Model/Location.cs b/src/Services/Marketing/Marketing.API/Model/Location.cs deleted file mode 100644 index 6738e1dcf..000000000 --- a/src/Services/Marketing/Marketing.API/Model/Location.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - public class Location - { - public int LocationId { get; set; } - public string Code { get; set; } - public string Description { get; set; } - } -} diff --git a/src/Services/Marketing/Marketing.API/Model/MarketingData.cs b/src/Services/Marketing/Marketing.API/Model/MarketingData.cs deleted file mode 100644 index 638bffac6..000000000 --- a/src/Services/Marketing/Marketing.API/Model/MarketingData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MongoDB.Bson; -using MongoDB.Bson.Serialization.Attributes; -using System; -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - public class MarketingData - { - [BsonIgnoreIfDefault] - [BsonRepresentation(BsonType.ObjectId)] - public string Id { get; set; } - public string UserId { get; set; } - public List Locations { get; set; } - public DateTime UpdateDate { get; set; } - } -} diff --git a/src/Services/Marketing/Marketing.API/Model/Rule.cs b/src/Services/Marketing/Marketing.API/Model/Rule.cs deleted file mode 100644 index 6f9f23ef5..000000000 --- a/src/Services/Marketing/Marketing.API/Model/Rule.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - public abstract class Rule - { - public int Id { get; set; } - - public int CampaignId { get; set; } - - public Campaign Campaign { get; set; } - - public string Description { get; set; } - } - - - public class UserProfileRule : Rule - { - } - - public class PurchaseHistoryRule : Rule - { - } - - public class UserLocationRule : Rule - { - public int LocationId { get; set; } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Model/RuleType.cs b/src/Services/Marketing/Marketing.API/Model/RuleType.cs deleted file mode 100644 index 1fa569cbb..000000000 --- a/src/Services/Marketing/Marketing.API/Model/RuleType.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions; - using System; - using System.Collections.Generic; - using System.Linq; - - public sealed class RuleType - { - public static readonly RuleType UserProfileRule = new RuleType(1, nameof(UserProfileRule)); - public static readonly RuleType PurchaseHistoryRule = new RuleType(2, nameof(UserProfileRule)); - public static readonly RuleType UserLocationRule = new RuleType(3, nameof(UserProfileRule)); - - public readonly int Id; - public readonly string Name; - - private RuleType(int id, string name) - { - Id = id; - Name = name; - } - - public static IEnumerable List() => - new[] { UserProfileRule, PurchaseHistoryRule, UserLocationRule }; - - public static RuleType FromName(string name) - { - var state = List() - .SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); - - if (state == null) - { - throw new MarketingDomainException($"Possible values for RuleType: {String.Join(",", List().Select(s => s.Name))}"); - } - - return state; - } - - public static RuleType From(int id) - { - var state = List().SingleOrDefault(s => s.Id == id); - - if (state == null) - { - throw new MarketingDomainException($"Possible values for RuleType: {String.Join(",", List().Select(s => s.Name))}"); - } - - return state; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs b/src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs deleted file mode 100644 index e6d7fe305..000000000 --- a/src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model -{ - public class UserLocationDetails - { - public int LocationId { get; set; } - public string Code { get; set; } - public string Description { get; set; } - } -} diff --git a/src/Services/Marketing/Marketing.API/Pics/1.png b/src/Services/Marketing/Marketing.API/Pics/1.png deleted file mode 100644 index 22a6a946f..000000000 Binary files a/src/Services/Marketing/Marketing.API/Pics/1.png and /dev/null differ diff --git a/src/Services/Marketing/Marketing.API/Pics/2.png b/src/Services/Marketing/Marketing.API/Pics/2.png deleted file mode 100644 index e23063bc4..000000000 Binary files a/src/Services/Marketing/Marketing.API/Pics/2.png and /dev/null differ diff --git a/src/Services/Marketing/Marketing.API/Program.cs b/src/Services/Marketing/Marketing.API/Program.cs deleted file mode 100644 index a76ad5349..000000000 --- a/src/Services/Marketing/Marketing.API/Program.cs +++ /dev/null @@ -1,100 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API -{ - using AspNetCore.Hosting; - using Microsoft.AspNetCore; - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Logging; - using Serilog; - using System; - using System.IO; - - public class Program - { - public static readonly string Namespace = typeof(Program).Namespace; - public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); - - public static int Main(string[] args) - { - var configuration = GetConfiguration(); - - Log.Logger = CreateSerilogLogger(configuration); - - try - { - Log.Information("Configuring web host ({ApplicationContext})...", AppName); - var host = BuildWebHost(configuration, args); - - Log.Information("Applying migrations ({ApplicationContext})...", AppName); - host.MigrateDbContext((context, services) => - { - var logger = services.GetService>(); - - new MarketingContextSeed() - .SeedAsync(context, logger) - .Wait(); - }); - - Log.Information("Starting web host ({ApplicationContext})...", AppName); - host.Run(); - - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); - return 1; - } - finally - { - Log.CloseAndFlush(); - } - } - - private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) => - WebHost.CreateDefaultBuilder(args) - .CaptureStartupErrors(false) - .ConfigureAppConfiguration(x => x.AddConfiguration(configuration)) - .UseStartup() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseWebRoot("Pics") - .UseSerilog() - .Build(); - - private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) - { - var seqServerUrl = configuration["Serilog:SeqServerUrl"]; - var logstashUrl = configuration["Serilog:LogstashgUrl"]; - return new LoggerConfiguration() - .MinimumLevel.Verbose() - .Enrich.WithProperty("ApplicationContext", AppName) - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl) - .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl) - .ReadFrom.Configuration(configuration) - .CreateLogger(); - } - - private static IConfiguration GetConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables(); - - var config = builder.Build(); - - if (config.GetValue("UseVault", false)) - { - builder.AddAzureKeyVault( - $"https://{config["Vault:Name"]}.vault.azure.net/", - config["Vault:ClientId"], - config["Vault:ClientSecret"]); - } - - return builder.Build(); - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Properties/launchSettings.json b/src/Services/Marketing/Marketing.API/Properties/launchSettings.json deleted file mode 100644 index dea046099..000000000 --- a/src/Services/Marketing/Marketing.API/Properties/launchSettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:63455/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Marketing.API": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:52059" - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs deleted file mode 100644 index a7386a532..000000000 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ /dev/null @@ -1,362 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API -{ - using AspNetCore.Builder; - using AspNetCore.Hosting; - using AspNetCore.Http; - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Azure.ServiceBus; - using BuildingBlocks.EventBus; - using BuildingBlocks.EventBus.Abstractions; - using BuildingBlocks.EventBusRabbitMQ; - using BuildingBlocks.EventBusServiceBus; - using EntityFrameworkCore; - using Extensions.Configuration; - using Extensions.DependencyInjection; - using Extensions.Logging; - using HealthChecks.UI.Client; - using Infrastructure; - using Infrastructure.Filters; - using Infrastructure.Repositories; - using Infrastructure.Services; - using IntegrationEvents.Events; - using Marketing.API.IntegrationEvents.Handlers; - using Microsoft.AspNetCore.Authentication.JwtBearer; - using Microsoft.AspNetCore.Diagnostics.HealthChecks; - using Microsoft.AspNetCore.Mvc; - using Microsoft.EntityFrameworkCore.Diagnostics; - using Microsoft.eShopOnContainers.Services.Marketing.API.Controllers; - using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares; - using Microsoft.Extensions.Diagnostics.HealthChecks; - using Microsoft.OpenApi.Models; - using RabbitMQ.Client; - using System; - using System.Collections.Generic; - using System.IdentityModel.Tokens.Jwt; - using System.Reflection; - - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - - // This method gets called by the runtime. Use this method to add services to the container. - public virtual IServiceProvider ConfigureServices(IServiceCollection services) - { - RegisterAppInsights(services); - - // Add framework services. - services.AddCustomHealthCheck(Configuration); - services - .AddControllers() - // Added for functional tests - .AddApplicationPart(typeof(LocationsController).Assembly) - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); - services.Configure(Configuration); - - ConfigureAuthService(services); - - services.AddEntityFrameworkSqlServer() - .AddDbContext(options => - { - options.UseSqlServer(Configuration["ConnectionString"], - sqlServerOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name); - //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency - sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); - }); - - // Changing default behavior when client evaluation occurs to throw. - // Default in EF Core would be to log a warning when client evaluation is performed. - options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)); - //Check Client vs. Server evaluation: https://docs.microsoft.com/en-us/ef/core/querying/client-eval - }); - - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var logger = sp.GetRequiredService>(); - - var serviceBusConnectionString = Configuration["EventBusConnection"]; - var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); - - return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger); - }); - } - else - { - services.AddSingleton(sp => - { - var logger = sp.GetRequiredService>(); - - var factory = new ConnectionFactory() - { - HostName = Configuration["EventBusConnection"], - DispatchConsumersAsync = true - }; - - if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) - { - factory.UserName = Configuration["EventBusUserName"]; - } - - if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) - { - factory.Password = Configuration["EventBusPassword"]; - } - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); - }); - } - - // Add framework services. - - AddCustomSwagger(services); - services.AddCors(options => - { - options.AddPolicy("CorsPolicy", - builder => builder - .SetIsOriginAllowed((host) => true) - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials()); - }); - - RegisterEventBus(services); - - services.AddTransient(); - services.AddSingleton(); - services.AddTransient(); - - services.AddOptions(); - - //configure autofac - var container = new ContainerBuilder(); - container.Populate(services); - - return new AutofacServiceProvider(container.Build()); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - //loggerFactory.AddAzureWebAppDiagnostics(); - //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); - - var pathBase = Configuration["PATH_BASE"]; - - if (!string.IsNullOrEmpty(pathBase)) - { - app.UsePathBase(pathBase); - } - - app.UseRouting(); - app.UseCors("CorsPolicy"); - ConfigureAuth(app); - - app.UseEndpoints(endpoints => - { - endpoints.MapDefaultControllerRoute(); - endpoints.MapControllers(); - endpoints.MapHealthChecks("/hc", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - endpoints.MapHealthChecks("/liveness", new HealthCheckOptions - { - Predicate = r => r.Name.Contains("self") - }); - }); - - app.UseSwagger() - .UseSwaggerUI(setup => - { - setup.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Marketing.API V1"); - setup.OAuthClientId("marketingswaggerui"); - setup.OAuthAppName("Marketing Swagger UI"); - }); - - ConfigureEventBus(app); - } - - private void AddCustomSwagger(IServiceCollection services) - { - services.AddSwaggerGen(options => - { - options.DescribeAllEnumsAsStrings(); - options.SwaggerDoc("v1", new OpenApiInfo - { - Title = "eShopOnContainers - Marketing HTTP API", - Version = "v1", - Description = "The Marketing Service HTTP API" - }); - - options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme - { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows() - { - Implicit = new OpenApiOAuthFlow() - { - AuthorizationUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/token"), - Scopes = new Dictionary() - { - { "marketing", "Marketing API" } - } - } - } - }); - - options.OperationFilter(); - }); - } - - private void RegisterAppInsights(IServiceCollection services) - { - services.AddApplicationInsightsTelemetry(Configuration); - services.AddApplicationInsightsKubernetesEnricher(); - } - - private void ConfigureAuthService(IServiceCollection services) - { - // prevent from mapping "sub" claim to nameidentifier. - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); - - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - - }).AddJwtBearer(options => - { - options.Authority = Configuration.GetValue("IdentityUrl"); - options.Audience = "marketing"; - options.RequireHttpsMetadata = false; - }); - } - - private void RegisterEventBus(IServiceCollection services) - { - var subscriptionClientName = Configuration["SubscriptionClientName"]; - - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var serviceBusPersisterConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - return new EventBusServiceBus(serviceBusPersisterConnection, logger, - eventBusSubcriptionsManager, subscriptionClientName, iLifetimeScope); - }); - } - else - { - services.AddSingleton(sp => - { - var rabbitMQPersistentConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); - }); - } - - services.AddSingleton(); - services.AddTransient(); - } - - private void ConfigureEventBus(IApplicationBuilder app) - { - var eventBus = app.ApplicationServices.GetRequiredService(); - eventBus.Subscribe(); - } - - protected virtual void ConfigureAuth(IApplicationBuilder app) - { - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - - app.UseAuthentication(); - app.UseAuthorization(); - } - } - - public static class CustomExtensionMethods - { - public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) - { - var hcBuilder = services.AddHealthChecks(); - - hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); - - hcBuilder - .AddSqlServer( - configuration["ConnectionString"], - name: "MarketingDB-check", - tags: new string[] { "marketingdb" }) - .AddMongoDb( - configuration["MongoConnectionString"], - name: "MarketingDB-mongodb-check", - tags: new string[] { "mongodb" }); - - var accountName = configuration.GetValue("AzureStorageAccountName"); - var accountKey = configuration.GetValue("AzureStorageAccountKey"); - if (!string.IsNullOrEmpty(accountName) && !string.IsNullOrEmpty(accountKey)) - { - hcBuilder - .AddAzureBlobStorage( - $"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix=core.windows.net", - name: "marketing-storage-check", - tags: new string[] { "marketingstorage" }); - } - - if (configuration.GetValue("AzureServiceBusEnabled")) - { - hcBuilder - .AddAzureServiceBusTopic( - configuration["EventBusConnection"], - topicName: "eshop_event_bus", - name: "marketing-servicebus-check", - tags: new string[] { "servicebus" }); - } - else - { - hcBuilder - .AddRabbitMQ( - $"amqp://{configuration["EventBusConnection"]}", - name: "marketing-rabbitmqbus-check", - tags: new string[] { "rabbitmqbus" }); - } - - return services; - } - } -} diff --git a/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs b/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs deleted file mode 100644 index 73225b4cf..000000000 --- a/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel -{ - using System.Collections.Generic; - - public class PaginatedItemsViewModel where TEntity : class - { - public int PageIndex { get; private set; } - - public int PageSize { get; private set; } - - public long Count { get; private set; } - - public IEnumerable Data { get; private set; } - - public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable data) - { - this.PageIndex = pageIndex; - this.PageSize = pageSize; - this.Count = count; - this.Data = data; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/appsettings.json b/src/Services/Marketing/Marketing.API/appsettings.json deleted file mode 100644 index d4a58cc8e..000000000 --- a/src/Services/Marketing/Marketing.API/appsettings.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "Serilog": { - "SeqServerUrl": null, - "LogstashgUrl": null, - "MinimumLevel": { - "Default": "Information", - "Override": { - "Microsoft": "Warning", - "Microsoft.eShopOnContainers": "Information", - "System": "Warning" - } - } - }, - "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word", - "MongoConnectionString": "mongodb://nosql.data", - "MongoDatabase": "MarketingDb", - "IdentityUrl": "http://localhost:5105", - "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", - "AzureServiceBusEnabled": false, - "SubscriptionClientName": "Marketing", - "AzureStorageEnabled": false, - "ApplicationInsights": { - "InstrumentationKey": "" - }, - "EventBusRetryCount": 5, - "UseVault": false, - "Vault": { - "Name": "eshop", - "ClientId": "your-clien-id", - "ClientSecret": "your-client-secret" - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/azds.yaml b/src/Services/Marketing/Marketing.API/azds.yaml deleted file mode 100644 index 5d6418f83..000000000 --- a/src/Services/Marketing/Marketing.API/azds.yaml +++ /dev/null @@ -1,56 +0,0 @@ -kind: helm-release -apiVersion: 1.1 -build: - context: ..\..\..\.. - dockerfile: Dockerfile -install: - chart: ../../../../k8s/helm/marketing-api - set: - replicaCount: 1 - image: - tag: $(tag) - pullPolicy: Never - ingress: - annotations: - kubernetes.io/ingress.class: traefik-azds - hosts: - - $(spacePrefix)eshop$(hostSuffix) - inf: - k8s: - dns: $(spacePrefix)eshop$(hostSuffix) - values: - - values.dev.yaml? - - secrets.dev.yaml? - - inf.yaml - - app.yaml -configurations: - develop: - build: - useGitIgnore: true - dockerfile: Dockerfile.develop - args: - BUILD_CONFIGURATION: ${BUILD_CONFIGURATION:-Debug} - container: - sync: - - '**/Pages/**' - - '**/Views/**' - - '**/wwwroot/**' - - '!**/*.{sln,csproj}' - command: - - dotnet - - run - - --no-restore - - --no-build - - --no-launch-profile - - -c - - ${BUILD_CONFIGURATION:-Debug} - iterate: - processesToKill: - - dotnet - - vsdbg - buildCommands: - - - dotnet - - build - - --no-restore - - -c - - ${BUILD_CONFIGURATION:-Debug} diff --git a/src/Services/Marketing/Marketing.API/values.dev.yaml b/src/Services/Marketing/Marketing.API/values.dev.yaml deleted file mode 100644 index eaed45149..000000000 --- a/src/Services/Marketing/Marketing.API/values.dev.yaml +++ /dev/null @@ -1,3 +0,0 @@ -ingress: - enabled: true - tls: [] \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.FunctionalTests/AutoAuthorizeMiddleware.cs b/src/Services/Marketing/Marketing.FunctionalTests/AutoAuthorizeMiddleware.cs deleted file mode 100644 index 31fa194cb..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/AutoAuthorizeMiddleware.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Http; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Marketing.FunctionalTests -{ - class AutoAuthorizeMiddleware - { - private readonly RequestDelegate _next; - - public AutoAuthorizeMiddleware(RequestDelegate rd) - { - _next = rd; - } - - public async Task Invoke(HttpContext httpContext) - { - var identity = new ClaimsIdentity("cookies"); - identity.AddClaim(new Claim("sub", "1234")); - - httpContext.User.AddIdentity(identity); - - await _next.Invoke(httpContext); - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarioBase.cs b/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarioBase.cs deleted file mode 100644 index c2c46dfa2..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarioBase.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Marketing.FunctionalTests -{ - public class CampaignScenarioBase : MarketingScenarioBase - { - public static class Get - { - public static string Campaigns = CampaignsUrlBase; - - public static string CampaignBy(int id) - => $"{CampaignsUrlBase}/{id}"; - } - - public static class Post - { - public static string AddNewCampaign = CampaignsUrlBase; - } - - public static class Put - { - public static string CampaignBy(int id) - => $"{CampaignsUrlBase}/{id}"; - } - - public static class Delete - { - public static string CampaignBy(int id) - => $"{CampaignsUrlBase}/{id}"; - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarios.cs b/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarios.cs deleted file mode 100644 index 3742b80c6..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/CampaignScenarios.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Microsoft.eShopOnContainers.Services.Marketing.API.Dto; -using Newtonsoft.Json; -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace Marketing.FunctionalTests -{ - [Collection("Sequential")] - public class CampaignScenarios - : CampaignScenarioBase - { - [Fact] - public async Task Get_get_all_campaigns_and_response_ok_status_code() - { - using (var server = CreateServer()) - { - var response = await server.CreateClient() - .GetAsync(Get.Campaigns); - - response.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Get_get_campaign_by_id_and_response_ok_status_code() - { - var campaignId = 2; - using (var server = CreateServer()) - { - var response = await server.CreateClient() - .GetAsync(Get.CampaignBy(campaignId)); - - response.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Get_get_campaign_by_id_and_response_not_found_status_code() - { - using (var server = CreateServer()) - { - var response = await server.CreateClient() - .GetAsync(Get.CampaignBy(int.MaxValue)); - - Assert.True(response.StatusCode == HttpStatusCode.NotFound); - } - } - - [Fact] - public async Task Post_add_new_campaign_and_response_ok_status_code() - { - using (var server = CreateServer()) - { - var fakeCampaignDto = GetFakeCampaignDto(); - var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - var response = await server.CreateClient() - .PostAsync(Post.AddNewCampaign, content); - - response.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Delete_delete_campaign_and_response_not_content_status_code() - { - using (var server = CreateServer()) - { - var fakeCampaignDto = GetFakeCampaignDto(); - var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - - //add campaign - var campaignResponse = await server.CreateClient() - .PostAsync(Post.AddNewCampaign, content); - - if (int.TryParse(campaignResponse.Headers.Location.Segments[3], out int id)) - { - var response = await server.CreateClient() - .DeleteAsync(Delete.CampaignBy(id)); - - Assert.True(response.StatusCode == HttpStatusCode.NoContent); - } - - campaignResponse.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Put_update_campaign_and_response_not_content_status_code() - { - using (var server = CreateServer()) - { - var fakeCampaignDto = GetFakeCampaignDto(); - var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - - //add campaign - var campaignResponse = await server.CreateClient() - .PostAsync(Post.AddNewCampaign, content); - - if (int.TryParse(campaignResponse.Headers.Location.Segments[3], out int id)) - { - fakeCampaignDto.Description = "FakeCampaignUpdatedDescription"; - content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - var response = await server.CreateClient() - .PutAsync(Put.CampaignBy(id), content); - - Assert.True(response.StatusCode == HttpStatusCode.Created); - } - - campaignResponse.EnsureSuccessStatusCode(); - } - } - - private static CampaignDTO GetFakeCampaignDto() - { - return new CampaignDTO() - { - Name = "FakeCampaignName", - Description = "FakeCampaignDescription", - From = DateTime.Now, - To = DateTime.Now.AddDays(7), - PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/campaigns/0/pic" - }; - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj b/src/Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj deleted file mode 100644 index f166db7b5..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - netcoreapp3.1 - - false - - - - - - - - - Always - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - - diff --git a/src/Services/Marketing/Marketing.FunctionalTests/MarketingScenarioBase.cs b/src/Services/Marketing/Marketing.FunctionalTests/MarketingScenarioBase.cs deleted file mode 100644 index 025934220..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/MarketingScenarioBase.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Microsoft.eShopOnContainers.Services.Marketing.API; -using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using System; -using System.IO; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; - -namespace Marketing.FunctionalTests -{ - public class MarketingScenarioBase - { - public static string CampaignsUrlBase => "api/v1/campaigns"; - - public TestServer CreateServer() - { - var path = Assembly.GetAssembly(typeof(MarketingScenarioBase)) - .Location; - - var hostBuilder = new WebHostBuilder() - .UseContentRoot(Path.GetDirectoryName(path)) - .ConfigureAppConfiguration(cb => - { - cb.AddJsonFile("appsettings.json", optional: false) - .AddEnvironmentVariables(); - }) - .CaptureStartupErrors(true) - .UseStartup(); - - var testServer = new TestServer(hostBuilder); - - testServer.Host - .MigrateDbContext((context, services) => - { - var logger = services.GetService>(); - - new MarketingContextSeed() - .SeedAsync(context, logger) - .Wait(); - }); - - return testServer; - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/MarketingTestStartup.cs b/src/Services/Marketing/Marketing.FunctionalTests/MarketingTestStartup.cs deleted file mode 100644 index 87d0fb991..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/MarketingTestStartup.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Routing; -using Microsoft.eShopOnContainers.Services.Marketing.API; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace Marketing.FunctionalTests -{ - public class MarketingTestsStartup : Startup - { - public MarketingTestsStartup(IConfiguration env) : base(env) - { - } - - public override IServiceProvider ConfigureServices(IServiceCollection services) - { - // Added to avoid the Authorize data annotation in test environment. - // Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json - services.Configure(Configuration); - return base.ConfigureServices(services); - } - - protected override void ConfigureAuth(IApplicationBuilder app) - { - if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant()) - { - app.UseMiddleware(); - } - else - { - base.ConfigureAuth(app); - } - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/Properties/launchSettings.json b/src/Services/Marketing/Marketing.FunctionalTests/Properties/launchSettings.json deleted file mode 100644 index 5a92d63ac..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:7496/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Marketing.FunctionalTests": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:7497/" - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarioBase.cs b/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarioBase.cs deleted file mode 100644 index 495b3d292..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarioBase.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Marketing.FunctionalTests -{ - public class UserLocationRoleScenariosBase : MarketingScenarioBase - { - private const string EndpointLocationName = "locations"; - public static class Get - { - public static string UserLocationRulesByCampaignId(int campaignId) - => GetUserLocationRolesUrlBase(campaignId); - - public static string UserLocationRuleByCampaignAndUserLocationRuleId(int campaignId, - int userLocationRuleId) - => $"{GetUserLocationRolesUrlBase(campaignId)}/{userLocationRuleId}"; - } - - public static class Post - { - public static string AddNewuserLocationRule(int campaignId) - => GetUserLocationRolesUrlBase(campaignId); - } - - public static class Put - { - public static string UserLocationRoleBy(int campaignId, - int userLocationRuleId) - => $"{GetUserLocationRolesUrlBase(campaignId)}/{userLocationRuleId}"; - } - - public static class Delete - { - public static string UserLocationRoleBy(int campaignId, - int userLocationRuleId) - => $"{GetUserLocationRolesUrlBase(campaignId)}/{userLocationRuleId}"; - } - - - private static string GetUserLocationRolesUrlBase(int campaignId) - => $"{CampaignsUrlBase}/{campaignId}/{EndpointLocationName}"; - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarios.cs b/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarios.cs deleted file mode 100644 index fe76923e0..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/UserLocationRoleScenarios.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.eShopOnContainers.Services.Marketing.API.Dto; -using Newtonsoft.Json; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace Marketing.FunctionalTests -{ - [Collection("Sequential")] - public class UserLocationRoleScenarios - : UserLocationRoleScenariosBase - { - [Fact] - public async Task Get_get_all_user_location_rules_by_campaignId_and_response_ok_status_code() - { - var campaignId = 1; - - using (var server = CreateServer()) - { - var response = await server.CreateClient() - .GetAsync(Get.UserLocationRulesByCampaignId(campaignId)); - - response.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Post_add_new_user_location_rule_and_response_ok_status_code() - { - var campaignId = 2; - - using (var server = CreateServer()) - { - var fakeCampaignDto = GetFakeUserLocationRuleDto(); - var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - var response = await server.CreateClient() - .PostAsync(Post.AddNewuserLocationRule(campaignId), content); - - response.EnsureSuccessStatusCode(); - } - } - - [Fact] - public async Task Delete_delete_user_location_role_and_response_not_content_status_code() - { - var campaignId = 2; - - using (var server = CreateServer()) - { - var fakeCampaignDto = GetFakeUserLocationRuleDto(); - var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json"); - - //add user location role - var campaignResponse = await server.CreateClient() - .PostAsync(Post.AddNewuserLocationRule(campaignId), content); - - if (int.TryParse(campaignResponse.Headers.Location.Segments[6], out int userLocationRuleId)) - { - var response = await server.CreateClient() - .DeleteAsync(Delete.UserLocationRoleBy(campaignId, userLocationRuleId)); - - Assert.True(response.StatusCode == HttpStatusCode.NoContent); - } - - campaignResponse.EnsureSuccessStatusCode(); - } - } - - private static UserLocationRuleDTO GetFakeUserLocationRuleDto() - { - return new UserLocationRuleDTO - { - LocationId = 20, - Description = "FakeUserLocationRuleDescription" - }; - } - } -} diff --git a/src/Services/Marketing/Marketing.FunctionalTests/appsettings.json b/src/Services/Marketing/Marketing.FunctionalTests/appsettings.json deleted file mode 100644 index 11a1e090d..000000000 --- a/src/Services/Marketing/Marketing.FunctionalTests/appsettings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word", - "MongoConnectionString": "mongodb://localhost:27017", - "MongoDatabase": "MarketingDb", - "IdentityUrl": "http://localhost:5105", - "isTest": "true", - "EventBusConnection": "localhost", - "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", - "SubscriptionClientName": "Marketing", - "SuppressCheckForUnhandledSecurityMetadata":true -} diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 01d607e61..f4570c71e 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -213,8 +213,6 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("profile"); options.Scope.Add("orders"); options.Scope.Add("basket"); - options.Scope.Add("marketing"); - options.Scope.Add("locations"); options.Scope.Add("webshoppingagg"); options.Scope.Add("orders.signalrhub"); }); diff --git a/src/Web/WebSPA/AppSettings.cs b/src/Web/WebSPA/AppSettings.cs index 037ed858f..beeef9d68 100644 --- a/src/Web/WebSPA/AppSettings.cs +++ b/src/Web/WebSPA/AppSettings.cs @@ -9,7 +9,6 @@ namespace eShopOnContainers.WebSPA { public string IdentityUrl { get; set; } public string BasketUrl { get; set; } - public string MarketingUrl { get; set; } public string PurchaseUrl { get; set; } public string SignalrHubUrl { get; set; } diff --git a/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts b/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts index eb2e46ddb..b9e43becb 100644 --- a/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts +++ b/src/Web/WebSPA/Client/modules/shared/models/configuration.model.ts @@ -1,6 +1,5 @@ export interface IConfiguration { identityUrl: string, - marketingUrl: string, purchaseUrl: string, signalrHubUrl: string, activateCampaignDetailFunction: boolean diff --git a/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts b/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts index 954ddfa84..795d30647 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/configuration.service.ts @@ -23,7 +23,6 @@ export class ConfigurationService { this.serverSettings = response as IConfiguration; console.log(this.serverSettings); this.storageService.store('identityUrl', this.serverSettings.identityUrl); - this.storageService.store('marketingUrl', this.serverSettings.marketingUrl); this.storageService.store('purchaseUrl', this.serverSettings.purchaseUrl); this.storageService.store('signalrHubUrl', this.serverSettings.signalrHubUrl); this.storageService.store('activateCampaignDetailFunction', this.serverSettings.activateCampaignDetailFunction); diff --git a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts index 13480fafd..cf8a3fd17 100644 --- a/src/Web/WebSPA/Client/modules/shared/services/security.service.ts +++ b/src/Web/WebSPA/Client/modules/shared/services/security.service.ts @@ -82,7 +82,7 @@ export class SecurityService { let client_id = 'js'; let redirect_uri = location.origin + '/'; let response_type = 'id_token token'; - let scope = 'openid profile orders basket marketing locations webshoppingagg orders.signalrhub'; + let scope = 'openid profile orders basket webshoppingagg orders.signalrhub'; let nonce = 'N' + Math.random() + '' + Date.now(); let state = Date.now() + '' + Math.random(); diff --git a/src/Web/WebSPA/appsettings.json b/src/Web/WebSPA/appsettings.json index d95c2b20a..4c70a7570 100644 --- a/src/Web/WebSPA/appsettings.json +++ b/src/Web/WebSPA/appsettings.json @@ -1,10 +1,8 @@ { "IdentityUrl": "http://localhost:5105", - "MarketingUrl": "http://localhost:5203", "CallBackUrl": "http://localhost:5104/", "PurchaseUrl": "http://localhost:5202", "PurchaseUrlHC": "http://localhost:5202/hc", - "MarketingUrlHC": "http://localhost:5203/hc", "IdentityUrlHC": "http://localhost:5105/hc", "SignalrHubUrl":"http://localhost:5202", "UseCustomizationData": true, diff --git a/src/docker-compose-tests.override.yml b/src/docker-compose-tests.override.yml index 24e50b57e..f08e09c85 100644 --- a/src/docker-compose-tests.override.yml +++ b/src/docker-compose-tests.override.yml @@ -29,8 +29,6 @@ services: - XamarinCallback=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105/xamarincallback - ConnectionString=${ESHOP_AZURE_IDENTITY_DB:-Server=sql-data-test;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word} - MvcClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5100 - - LocationApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5109 - - MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - MobileShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5120 @@ -181,34 +179,6 @@ services: - --logger - trx;LogFileName=/tests/ordering-unit-test-results.xml - marketing-api-functional-test: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=${ESHOP_AZURE_MARKETING_DB:-Server=sql-data-test;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word} - - MongoConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosql-data-test} - - MongoDatabase=MarketingDb - - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq-test} - - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - - identityUrl=http://identity-api - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - - CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI} - - PicBaseUrl=${ESHOP_STORAGE_MARKETING_URL} - - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME} - - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY} - - AzureServiceBusEnabled=False - - AzureStorageEnabled=False - - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - - OrchestratorType=${ORCHESTRATOR_TYPE} - - UseLoadTest=${USE_LOADTEST:-False} - ports: - - "5110:80" - entrypoint: - - dotnet - - test - - --logger - - trx;LogFileName=/tests/marketing-functional-test-results.xml payment-api-test: environment: @@ -222,26 +192,3 @@ services: - OrchestratorType=${ORCHESTRATOR_TYPE} ports: - "5108:80" - - locations-api-functional-test: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosql-data-test} - - Database=LocationsDb - - identityUrl=http://identity-api - - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq-test} - - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - - AzureServiceBusEnabled=False - - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - - OrchestratorType=${ORCHESTRATOR_TYPE} - - UseLoadTest=${USE_LOADTEST:-False} - ports: - - "5109:80" - entrypoint: - - dotnet - - test - - --logger - - trx;LogFileName=/tests/locations-functional-test-results.xml \ No newline at end of file diff --git a/src/docker-compose-tests.yml b/src/docker-compose-tests.yml index 75daf5a2f..1daccc5c8 100644 --- a/src/docker-compose-tests.yml +++ b/src/docker-compose-tests.yml @@ -95,19 +95,6 @@ services: volumes: - ${BUILD_ARTIFACTSTAGINGDIRECTORY:-./tests-results/}:/tests - marketing-api-functional-test: - image: ${REGISTRY:-eshop}/marketing-api-test:${TAG:-latest} - build: - context: . - dockerfile: Services/Marketing/Marketing.API/Dockerfile - target: functionaltest - depends_on: - - sql-data-test - - nosql-data-test - - identity-api-test - - rabbitmq-test - volumes: - - ${BUILD_ARTIFACTSTAGINGDIRECTORY:-./tests-results/}:/tests payment-api-test: image: ${REGISTRY:-eshop}/payment-api-test:${TAG:-latest} @@ -115,16 +102,4 @@ services: context: . dockerfile: Services/Payment/Payment.API/Dockerfile depends_on: - - rabbitmq-test - - locations-api-functional-test: - image: ${REGISTRY:-eshop}/locations-api-test:${TAG:-latest} - build: - context: . - dockerfile: Services/Location/Locations.API/Dockerfile - target: functionaltest - depends_on: - - nosql-data-test - - rabbitmq-test - volumes: - - ${BUILD_ARTIFACTSTAGINGDIRECTORY:-./tests-results/}:/tests \ No newline at end of file + - rabbitmq-test \ No newline at end of file diff --git a/src/docker-compose-windows.prod.yml b/src/docker-compose-windows.prod.yml index e38767a03..a011256f9 100644 --- a/src/docker-compose-windows.prod.yml +++ b/src/docker-compose-windows.prod.yml @@ -48,8 +48,6 @@ services: - XamarinCallback=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105/xamarincallback - ConnectionStrings__DefaultConnection=${ESHOP_AZURE_IDENTITY_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word} - MvcClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5100 #Local: You need to open your local dev-machine firewall at range 5100-5110. - - LocationApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5109 - - MarketingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5110 - BasketApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5102 - UseCustomizationData=True @@ -88,12 +86,10 @@ services: - OrderingUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5102 - IdentityUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: You need to open your host's firewall at range 5100-5110. - BasketUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5103 - - MarketingUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5110 - CatalogUrlHC=http://catalog-api/hc - OrderingUrlHC=http://ordering-api/hc - IdentityUrlHC=http://identity-api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. - BasketUrlHC=http://basket-api/hc - - MarketingUrlHC=http://marketing-api/hc - UseCustomizationData=True ports: - "5104:80" @@ -106,29 +102,9 @@ services: - OrderingUrl=http://ordering-api - IdentityUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser. - BasketUrl=http://basket-api - - MarketingUrl=http://marketing-api - UseCustomizationData=True #Remote: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser. ports: - "5100:80" - - marketing-api: - environment: - - ASPNETCORE_ENVIRONMENT=Production - - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=${ESHOP_AZURE_MARKETING_DB:-Server=sqldata;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word} - - MongoConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosqldata} - - MongoDatabase=MarketingDb - - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - - identityUrl=http://identity-api #Local: You need to open your local dev-machine firewall at range 5100-5110. - - IdentityUrlExternal=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 - - CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI} - - PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/campaigns/[0]/pic/} - - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME} - - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY} - - AzureServiceBusEnabled=False - - AzureStorageEnabled=False - ports: - - "5110:80" sqldata: environment: @@ -149,8 +125,6 @@ services: - OrderingUrl=http://ordering-api/hc - BasketUrl=http://basket-api/hc - IdentityUrl=http://identity-api/hc - - LocationsUrl=http://locations-api/hc - - MarketingUrl=http://marketing-api/hc - mvc=http://webmvc/hc - spa=http://webspa/hc @@ -164,17 +138,4 @@ services: - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - AzureServiceBusEnabled=False ports: - - "5108:80" - - locations-api: - environment: - - ASPNETCORE_ENVIRONMENT=Production - - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosqldata} - - Database=LocationsDb - - identityUrl=http://identity-api #Local: You need to open your local dev-machine firewall at range 5100-5110. - - IdentityUrlExternal=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105 - - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - - AzureServiceBusEnabled=False - ports: - - "5109:80" \ No newline at end of file + - "5108:80" \ No newline at end of file diff --git a/src/docker-compose.override.yml b/src/docker-compose.override.yml index f8c20f596..8a0d6133b 100644 --- a/src/docker-compose.override.yml +++ b/src/docker-compose.override.yml @@ -259,12 +259,12 @@ services: - HealthChecksUI__HealthChecks__6__Uri=http://catalog-api/hc - HealthChecksUI__HealthChecks__7__Name=Identity HTTP Check - HealthChecksUI__HealthChecks__7__Uri=http://identity-api/hc - - HealthChecksUI__HealthChecks__10__Name=Payments HTTP Check - - HealthChecksUI__HealthChecks__10__Uri=http://payment-api/hc - - HealthChecksUI__HealthChecks__11__Name=Ordering SignalRHub HTTP Check - - HealthChecksUI__HealthChecks__11__Uri=http://ordering-signalrhub/hc - - HealthChecksUI__HealthChecks__12__Name=Ordering HTTP Background Check - - HealthChecksUI__HealthChecks__12__Uri=http://ordering-backgroundtasks/hc + - HealthChecksUI__HealthChecks__8__Name=Payments HTTP Check + - HealthChecksUI__HealthChecks__8__Uri=http://payment-api/hc + - HealthChecksUI__HealthChecks__9__Name=Ordering SignalRHub HTTP Check + - HealthChecksUI__HealthChecks__9__Uri=http://ordering-signalrhub/hc + - HealthChecksUI__HealthChecks__10__Name=Ordering HTTP Background Check + - HealthChecksUI__HealthChecks__10__Uri=http://ordering-backgroundtasks/hc - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - OrchestratorType=${ORCHESTRATOR_TYPE} ports: diff --git a/src/prepare-devspaces.ps1 b/src/prepare-devspaces.ps1 index 5b692e908..06d41c57c 100644 --- a/src/prepare-devspaces.ps1 +++ b/src/prepare-devspaces.ps1 @@ -1,13 +1,6 @@ # This script just copies app.yaml and inf.yaml files to all devspaces projects. # This is to workaround issue #56 - https://github.com/Azure/dev-spaces/issues/56 -Write-Host "Copying app.yaml and inf.yaml to Mobile.Bff.Marketing" -ForegroundColor Yellow -Copy-Item "..\k8s\helm\app.yaml" -Destination ".\ApiGateways\Mobile.Bff.Marketing\apigw" -Force -Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\ApiGateways\Mobile.Bff.Marketing\apigw" -Force - -Write-Host "Copying app.yaml and inf.yaml to Web.Bff.Marketing" -ForegroundColor Yellow -Copy-Item "..\k8s\helm\app.yaml" -Destination ".\ApiGateways\Web.Bff.Marketing\apigw" -Force -Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\ApiGateways\Web.Bff.Marketing\apigw" -Force Write-Host "Copying app.yaml and inf.yaml to Mobile.Bff.Shopping" -ForegroundColor Yellow Copy-Item "..\k8s\helm\app.yaml" -Destination ".\ApiGateways\Mobile.Bff.Shopping\apigw" -Force @@ -37,14 +30,6 @@ Write-Host "Copying app.yaml and inf.yaml to Identity API" -ForegroundColor Yell Copy-Item "..\k8s\helm\app.yaml" -Destination ".\Services\Identity\Identity.API" -Force Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\Services\Identity\Identity.API" -Force -Write-Host "Copying app.yaml and inf.yaml to Locations API" -ForegroundColor Yellow -Copy-Item "..\k8s\helm\app.yaml" -Destination ".\Services\Location\Locations.API" -Force -Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\Services\Location\Locations.API" -Force - -Write-Host "Copying app.yaml and inf.yaml to Marketing API" -ForegroundColor Yellow -Copy-Item "..\k8s\helm\app.yaml" -Destination ".\Services\Marketing\Marketing.API" -Force -Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\Services\Marketing\Marketing.API" -Force - Write-Host "Copying app.yaml and inf.yaml to Ordering API" -ForegroundColor Yellow Copy-Item "..\k8s\helm\app.yaml" -Destination ".\Services\Ordering\Ordering.API" -Force Copy-Item "..\k8s\helm\inf.yaml" -Destination ".\Services\Ordering\Ordering.API" -Force