# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{- define "genProcessId" }}
{{- with $processName := . }}
{{- with $serviceId := "service" | b64enc | printf "%s.1" }}
{{- with $instanceId := "test-instance" | b64enc | printf "%s_%s" $serviceId }}
{{- printf "%s" (sha256enc (printf "%s_%s" $processName $instanceId)) }}
{{- end }}
{{- end }}
{{- end }}
{{- end}}

debuggingtrace: null
nodes:
{{- contains .nodes }}
- id: {{template "genProcessId" "service"}}
  name: service
  serviceid: {{ b64enc "service" }}.1
  servicename: service
  serviceinstanceid: {{ b64enc "service" }}.1_{{ b64enc "test-instance" }}
  serviceinstancename: test-instance
  isreal: true
- id: {{template "genProcessId" "UNKNOWN_REMOTE"}}
  name: UNKNOWN_REMOTE
  serviceid: {{ b64enc "service" }}.1
  servicename: service
  serviceinstanceid: {{ b64enc "service" }}.1_{{ b64enc "test-instance" }}
  serviceinstancename: test-instance
  isreal: false
{{- end }}
calls:
{{- contains .calls }}
- source: {{template "genProcessId" "service"}}
  sourcecomponents:
  {{- contains .sourcecomponents }}
  - http
  {{- end }}
  target: {{template "genProcessId" "UNKNOWN_REMOTE"}}
  targetcomponents: []
  id: {{template "genProcessId" "service"}}-{{template "genProcessId" "UNKNOWN_REMOTE"}}
  detectpoints:
    - CLIENT
- source: {{template "genProcessId" "UNKNOWN_REMOTE"}}
  sourcecomponents: []
  target: {{template "genProcessId" "service"}}
  targetcomponents:
    {{- contains .targetcomponents }}
    - http
    {{- end }}
  id: {{template "genProcessId" "UNKNOWN_REMOTE"}}-{{template "genProcessId" "service"}}
  detectpoints:
    - SERVER
{{- end }}