mirror of
https://github.com/status-im/consul.git
synced 2025-01-26 05:29:55 +00:00
bfbc0ee4fd
* Revert "feat: add alert to link to hcp modal to ask a user refresh a page; up… (#20682)" This reverts commit dd833d9a3649402e23ced070121e0d0c131f610e. * Revert "chor: change cluster name param to have datacenter.name as default value (#20644)" This reverts commit 8425cd0f9017f640cce711dc32e0fa0d136899d8. * Revert "chor: adds informative error message when acls disabled and read-only… (#20600)" This reverts commit 9d712ccfc7a67193423f1a102ac2b9d3c6dc3733. * Revert "Cc 7147 link to hcp modal (#20474)" This reverts commit 8c05e57ac1fdc27ea74040e2dfc35192ac6d067b. * Revert "Add nav bar item to show HCP link status and encourage folks to link (#20370)" This reverts commit 22e6ce0df10091bc66ee7fbf8e5d1c0f158ab5a9. * Revert "Cc 7145 hcp link status api (#20330)" This reverts commit 049ca102c41fbf646b07e34f5f69f652de9fbc6c. * Revert "💜 Cc 7187/purple banner for linking existing clusters (#20275)" This reverts commit 5119667cd16c527af111c339594a08354b7a5cb0.
80 lines
1.8 KiB
JavaScript
80 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Service from '@ember/service';
|
|
import { env } from 'consul-ui/env';
|
|
|
|
export default class EnvService extends Service {
|
|
// deprecated
|
|
// TODO: Remove this elsewhere in the app and use var instead
|
|
env(key) {
|
|
return this.var(key);
|
|
}
|
|
|
|
var(key) {
|
|
return env(key);
|
|
}
|
|
}
|
|
/**
|
|
* Stub class that can be used in testing when we want to test
|
|
* interactions with the EnvService. We can use `EnvStub.stubEnv` to setup
|
|
* an Env-Service that returns certain values we need to execute our tests.
|
|
*
|
|
* Example:
|
|
*
|
|
* ```js
|
|
* // some-test.js
|
|
* test('testing interaction with Env-service', async function(assert) {
|
|
* this.owner.register('service:env', class Stub extends EnvStub {
|
|
* . stubEnv = {
|
|
* CONSUL_ACLS_ENABLED: true
|
|
* }
|
|
* })
|
|
* })
|
|
* ```
|
|
*/
|
|
export class EnvStub extends EnvService {
|
|
var(key) {
|
|
const { stubEnv } = this;
|
|
|
|
const stubbed = stubEnv[key];
|
|
|
|
if (stubbed) {
|
|
return stubbed;
|
|
} else {
|
|
return super.var(...arguments);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper function to allow stubbing out data that is accessed by the application
|
|
* based on the Env-service. You will need to call this before the env-service gets
|
|
* initialized because it overrides the env-service injection on the owner.
|
|
*
|
|
* Example:
|
|
*
|
|
* ```js
|
|
* test('test something env related', async function(assert) {
|
|
* setupTestEnv(this.owner, {
|
|
* CONSUL_ACLS_ENABLED: true
|
|
* });
|
|
*
|
|
* // ...
|
|
* })
|
|
* ```
|
|
*
|
|
* @param {*} owner - the owner of the test instance (usually `this.owner`)
|
|
* @param {*} stubEnv - an object that holds the stubbed env-data
|
|
*/
|
|
export function setupTestEnv(owner, stubEnv) {
|
|
owner.register(
|
|
'service:env',
|
|
class Stub extends EnvStub {
|
|
stubEnv = stubEnv;
|
|
}
|
|
);
|
|
}
|