ui: Unix Domain Socket support (#10287)

This commit adds UI support for Unix Domain Sockets for upstream and downstreams (see #9981 and #10252)
This commit is contained in:
John Cowen 2021-05-26 17:52:25 +01:00 committed by hc-github-team-consul-core
parent dd280ee2b2
commit 206e414908
7 changed files with 97 additions and 19 deletions

3
.changelog/10287.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:feature
ui: Add Unix Domain Socket support
```

View File

@ -62,6 +62,15 @@ as |item index|>
{{/if}} {{/if}}
</dd> </dd>
</dl> </dl>
{{else if item.Service.SocketPath}}
<dl class="socket" data-test-socket>
<dt {{tooltip}}>
Socket Path
</dt>
<dd>
{{item.Service.SocketPath}}
</dd>
</dl>
{{/if}} {{/if}}
<TagList @item={{item.Service}} /> <TagList @item={{item.Service}} />
</BlockSlot> </BlockSlot>

View File

@ -37,8 +37,36 @@
</dd> </dd>
</dl> </dl>
{{/if}} {{/if}}
{{#if item.LocalBindSocketPath}}
{{#let (if item.LocalBindSocketMode
(hash
label=(concat '(Local bind mode)')
value=(concat '(Mode:' item.LocalBindSocketMode ')')
)
(hash
label=""
value=""
)
)
as |mode|}}
<dl class="local-bind-socket">
<dt>
<span>
Local bind socket {{mode.label}}
</span>
</dt>
<dd>
<CopyButton
@value={{item.LocalBindSocketPath}}
@name="Socket path"
/>
{{item.LocalBindSocketPath}}
</dd>
</dl>
{{/let}}
{{else}}
{{#if (gt item.LocalBindPort 0)}} {{#if (gt item.LocalBindPort 0)}}
{{#let (concat (or item.LocalBindAddress '127.0.0.1') ':' item.LocalBindPort) as |combinedAddress|}} {{#let (concat (or item.LocalBindAddress '127.0.0.1') ':' item.LocalBindPort) as |combinedAddress|}}
<dl class="local-bind-address"> <dl class="local-bind-address">
<dt> <dt>
<span> <span>
@ -53,7 +81,9 @@
{{combinedAddress}} {{combinedAddress}}
</dd> </dd>
</dl> </dl>
{{/let}} {{/let}}
{{/if}}
{{/if}} {{/if}}
</div> </div>
</li> </li>

View File

@ -45,6 +45,7 @@ export default class ServiceInstance extends Model {
// If the ID is blank fallback to the Service.Service (the Name) // If the ID is blank fallback to the Service.Service (the Name)
@or('Service.{ID,Service}') ID; @or('Service.{ID,Service}') ID;
@or('Service.Address', 'Node.Service') Address; @or('Service.Address', 'Node.Service') Address;
@attr('string') SocketPath;
@alias('Service.Tags') Tags; @alias('Service.Tags') Tags;
@alias('Service.Meta') Meta; @alias('Service.Meta') Meta;

View File

@ -32,6 +32,9 @@
%icon-definition.address dt::before { %icon-definition.address dt::before {
@extend %with-public-default-mask, %as-pseudo; @extend %with-public-default-mask, %as-pseudo;
} }
%icon-definition.socket dt::before {
@extend %with-port-mask, %as-pseudo;
}
%icon-definition.mesh dt::before { %icon-definition.mesh dt::before {
@extend %with-mesh-mask, %as-pseudo; @extend %with-mesh-mask, %as-pseudo;
} }

View File

@ -36,6 +36,9 @@ ${typeof location.search.ns !== 'undefined' ? `
"ServicePort": ${fake.random.number({min: 21000, max: 21255})}, "ServicePort": ${fake.random.number({min: 21000, max: 21255})},
"ServiceEnableTagOverride": false, "ServiceEnableTagOverride": false,
"ServiceProxy": { "ServiceProxy": {
"Config": {
"protocol": "http"
},
"Expose": { "Expose": {
"Checks": true, "Checks": true,
"Paths": [ "Paths": [
@ -50,15 +53,22 @@ ${range(env('CONSUL_EXPOSED_COUNT', 3)).map((i) => `
] ]
}, },
"Mode": "${fake.helpers.randomize(['', 'direct', 'transparent'])}", "Mode": "${fake.helpers.randomize(['', 'direct', 'transparent'])}",
"TransparentProxy": {},
"DestinationServiceName": "${location.pathname.slice(4)}" "DestinationServiceName": "${location.pathname.slice(4)}"
${ location.pathname.slice(4) === "service-0" ? ` ${ location.pathname.slice(4) === "service-0" ? `
, ,
"DestinationServiceID": "${location.pathname.slice(4)}-with-id", "DestinationServiceID": "${location.pathname.slice(4)}-with-id",
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"LocalServiceAddress": "${fake.internet.ip()}", "LocalServiceAddress": "${fake.internet.ip()}",
"LocalServicePort": ${fake.random.number({min: 0, max: 65535})} "LocalServicePort": ${fake.random.number({min: 0, max: 65535})}
` : `
"LocalServiceSocketMode": "0600",
"LocalServiceSocketPath": "/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}"
` }
` `
: ``} : ``}
}, },
"ServiceSocketPath": "",
"ServiceProxyDestination": "${location.pathname.slice(4)}", "ServiceProxyDestination": "${location.pathname.slice(4)}",
"ServiceWeights": { "ServiceWeights": {
"Passing": 1, "Passing": 1,

View File

@ -71,21 +71,38 @@ ${typeof location.search.ns !== 'undefined' ? `
) )
} }
], ],
"Weights": {
"Passing": 1,
"Warning": 1
},
${ fake.random.number({min: 1, max: 10}) > 2 ? ` ${ fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": { "Meta": {
"consul-dashboard-url": "${fake.internet.protocol()}://${fake.internet.domainName()}/?id={{Service}}", "consul-dashboard-url": "${fake.internet.protocol()}://${fake.internet.domainName()}/?id={{Service}}",
"external-source": "${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}" "external-source": "${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"
}, },
` : `` } ` : `
"Meta": null,
` }
${ false ? `
"Address":"${fake.internet.ip()}", "Address":"${fake.internet.ip()}",
"Port":${fake.random.number({min: 0, max: 65535})}, "Port":${fake.random.number({min: 0, max: 65535})},
` : `
"Address":"",
"SocketPath": "/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}",
` }
"Connect": {},
${kind !== '' ? ` ${kind !== '' ? `
"Kind": "${kind}", "Kind": "${kind}",
` : `` } ` : `` }
"Proxy": { "Proxy": {
${proxy !== -1 && sidecar === -1 ? ` ${proxy !== -1 && sidecar === -1 ? `
"DestinationServiceName": "${service.substr(0, proxy)}", "DestinationServiceName": "${service.substr(0, proxy)}",
` : ``} ` : `
"Expose": {},
"MeshGateway": {},
"Mode": "",
"TransparentProxy": ""
`}
${sidecar !== -1 ? ` ${sidecar !== -1 ? `
"DestinationServiceName": "${service.substr(0, sidecar)}", "DestinationServiceName": "${service.substr(0, sidecar)}",
"DestinationServiceID": "${service.substr(0, sidecar)}-ID", "DestinationServiceID": "${service.substr(0, sidecar)}-ID",
@ -113,8 +130,13 @@ ${range(env('CONSUL_EXPOSED_COUNT', 3)).map((i) => `
"DestinationName": "${fake.hacker.noun()}", "DestinationName": "${fake.hacker.noun()}",
"DestinationNamespace": "${fake.hacker.noun()}", "DestinationNamespace": "${fake.hacker.noun()}",
"DestinationType": "${fake.helpers.randomize(['service', 'prepared_query'])}", "DestinationType": "${fake.helpers.randomize(['service', 'prepared_query'])}",
${ false ? `
"LocalBindAddress": "${fake.internet.ip()}", "LocalBindAddress": "${fake.internet.ip()}",
"LocalBindPort": ${fake.random.number({min: 0, max: 65535})} "LocalBindPort": ${fake.random.number({min: 0, max: 65535})}
` : `
"LocalBindSocketMode": "0600",
"LocalBindSocketPath": "/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}"
` }
} }
`)} `)}
] ]