@ -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]" | |||
} | |||
} | |||
} |
@ -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" | |||
} | |||
} | |||
} |
@ -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 | |||
``` | |||
@ -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 |
@ -1,5 +0,0 @@ | |||
apiVersion: v1 | |||
appVersion: "1.0" | |||
description: A Helm chart for Kubernetes | |||
name: apigwmm | |||
version: 0.1.0 |
@ -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 |
@ -1,2 +0,0 @@ | |||
eShop API Gateway for Mobile Marketing services installed | |||
---------------------------------------------------------- |
@ -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 -}} |
@ -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 <dns>/<name> */}} | |||
{{- 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 -}} |
@ -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 }} | |||
@ -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 }} | |||
@ -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 }} |
@ -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 }} |
@ -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 |
@ -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 |
@ -1,5 +0,0 @@ | |||
apiVersion: v1 | |||
appVersion: "1.0" | |||
description: A Helm chart for Kubernetes | |||
name: apigwwm | |||
version: 0.1.0 |
@ -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 |
@ -1,2 +0,0 @@ | |||
eShop API Gateway for Web Marketing services installed | |||
------------------------------------------------------ |
@ -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 -}} |
@ -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 <dns>/<name> */}} | |||
{{- 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 -}} |
@ -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 }} | |||
@ -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 -}} | |||
@ -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 }} |
@ -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 }} |
@ -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 |
@ -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 |
@ -1,5 +0,0 @@ | |||
apiVersion: v1 | |||
appVersion: "1.0" | |||
description: A Helm chart for Kubernetes | |||
name: locations-api | |||
version: 0.1.0 |
@ -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 | |||
@ -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 -}} |
@ -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 <dns>/<name> */}} | |||
{{- 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 -}} |
@ -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 }} |
@ -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 }} | |||
@ -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 }} |
@ -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 |
@ -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 |
@ -1,5 +0,0 @@ | |||
apiVersion: v1 | |||
appVersion: "1.0" | |||
description: A Helm chart for Kubernetes | |||
name: marketing-api | |||
version: 0.1.0 |
@ -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 | |||
@ -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 -}} |
@ -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 <dns>/<name> */}} | |||
{{- 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 -}} |
@ -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/ |
@ -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 }} | |||
@ -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 }} |
@ -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 |
@ -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: /<controller>/ | |||
public IActionResult Index() | |||
{ | |||
return new RedirectResult("~/swagger"); | |||
} | |||
} | |||
} |
@ -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<ActionResult<UserLocation>> GetUserLocationAsync(Guid userId) | |||
{ | |||
return await _locationsService.GetUserLocationAsync(userId.ToString()); | |||
} | |||
//GET api/v1/[controller]/ | |||
[Route("")] | |||
[HttpGet] | |||
[ProducesResponseType(typeof(List<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>), (int)HttpStatusCode.OK)] | |||
public async Task<ActionResult<List<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>>> 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<ActionResult<Microsoft.eShopOnContainers.Services.Locations.API.Model.Locations>> 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<ActionResult> CreateOrUpdateUserLocationAsync([FromBody]LocationRequest newLocReq) | |||
{ | |||
var userId = _identityService.GetUserIdentity(); | |||
var result = await _locationsService.AddOrUpdateUserLocationAsync(userId, newLocReq); | |||
if (!result) | |||
{ | |||
return BadRequest(); | |||
} | |||
return Ok(); | |||
} | |||
} | |||
} |
@ -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"] |
@ -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", "--"] |
@ -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; | |||
} | |||
} | |||
} |
@ -1,21 +0,0 @@ | |||
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions | |||
{ | |||
using System; | |||
/// <summary> | |||
/// Exception type for app exceptions | |||
/// </summary> | |||
public class LocationDomainException : Exception | |||
{ | |||
public LocationDomainException() | |||
{ } | |||
public LocationDomainException(string message) | |||
: base(message) | |||
{ } | |||
public LocationDomainException(string message, Exception innerException) | |||
: base(message, innerException) | |||
{ } | |||
} | |||
} |
@ -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<AuthorizeAttribute>().Any() || | |||
context.MethodInfo.GetCustomAttributes(true).OfType<AuthorizeAttribute>().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<OpenApiSecurityRequirement> | |||
{ | |||
new OpenApiSecurityRequirement | |||
{ | |||
[ oAuthScheme ] = new [] { "locationsapi" } | |||
} | |||
}; | |||
} | |||
} | |||
} |
@ -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<HttpGlobalExceptionFilter> logger; | |||
public HttpGlobalExceptionFilter(IHostEnvironment env, ILogger<HttpGlobalExceptionFilter> 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; } | |||
} | |||
} | |||
} |