-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cc 7145 hcp link status api (#20330)
* feat: add api call to hcp/link endpoint * updated * updated * update approach to get the linking status * updated application template * feat: add api call to hcp/link endpoint * updated * updated * update approach to get the linking status * updated application template * update purple banner links * Hook up the linked check to the purple banner * fixed lint issue * Updated tests for new link status API calls as args instead of from service --------- Co-authored-by: Chris Hut <tophernuts@gmail.com>
- Loading branch information
1 parent
37ebaa6
commit 049ca10
Showing
8 changed files
with
119 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import RepositoryService from 'consul-ui/services/repository'; | ||
import dataSource from 'consul-ui/decorators/data-source'; | ||
|
||
export default class HcpLinkService extends RepositoryService { | ||
@dataSource('/:partition/:ns/:dc/hcp-link') | ||
async fetch({ partition, ns, dc }, { uri }, request) { | ||
let result; | ||
try { | ||
result = ( | ||
await request` | ||
GET /api/hcp/v2/link/global | ||
` | ||
)((headers, body) => { | ||
return { | ||
meta: { | ||
version: 2, | ||
uri: uri, | ||
}, | ||
body: { | ||
isLinked: (body.status['consul.io/hcp/link']['conditions'] || []).some( | ||
(condition) => condition.type === 'linked' && condition.state === 'STATE_TRUE' | ||
), | ||
}, | ||
headers, | ||
}; | ||
}); | ||
} catch (e) { | ||
// set linked to false if the global link is not found | ||
if (e.statusCode === 404) { | ||
result = Promise.resolve({ isLinked: false }); | ||
} else { | ||
result = Promise.resolve(null); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"status": { | ||
"consul.io/hcp/link": { | ||
"conditions": [ | ||
{ | ||
"message": "Successfully linked to cluster 'organization/f53e5646-6529-4698-ae29-d74f8bd22a01/project/6994bb7a-5561-4d5c-8bb0-cf40177e5b77/hashicorp.consul.global-network-manager.cluster/mkam-vm'", | ||
"reason": "SUCCESS", | ||
"state": "STATE_FALSE", | ||
"type": "linked" | ||
} | ||
], | ||
"observedGeneration":"01HMA2VPHVKNF6QR8TD07KDN5K", | ||
"updatedAt":"2024-01-16T21:29:25.923140Z" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters