feat: 🎸 Feature flag for oss and hcp binary (#1305)
* feat: 🎸 Feature flag for `oss` and `hcp` binary Create feature flag for `oss` and `hcp` to change specific input fields based on binary editions ✅ Closes: ICU * Update ui/admin/app/components/form/worker/create-worker-led/index.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * Update ui/admin/app/components/form/worker/create-worker-led/index.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * refactor: 💡 Quick refactor Refactor `create-worker-led/index.js`, and test. ✅ Closes: ICU-5903 * refactor: 💡 refactor for better readability Refactor code for better readability * refactor: 💡 rename filter function rename array filter function to be more descriptive ✅ Closes: ICU-5903 * changed params name for `convertCommaSeparatedValuesToArray` * add ending new line * Update ui/admin/app/components/form/worker/create-worker-led/index.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * refactor: 💡 yaml refactor yaml refactor * refactor: 💡 revert en-us.yaml file revert en-us.yaml file Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
1 parent
e6767b1e14
commit
3c49dc1c48
6 files changed
+152
-53
No files matched your search
@@ -5,42 +5,54 @@
|
||||
@showEditToggle={{false}}
|
||||
as |form|
|
||||
>
|
||||
<form.input
|
||||
@name='cluster_id'
|
||||
@value={{this.clusterId}}
|
||||
@label={{t 'resources.worker.form.cluster_id.label'}}
|
||||
@helperText={{t 'resources.worker.form.cluster_id.help'}}
|
||||
@linkText={{t 'actions.learn-more'}}
|
||||
@link={{doc-url 'worker.manage-workers'}}
|
||||
placeholder='69b6ddb3-ffec-42ab-a994-f43a6519470a'
|
||||
/>
|
||||
|
||||
<form.input
|
||||
@name='ip_address'
|
||||
@value={{this.ipAddress}}
|
||||
@label={{t 'resources.worker.form.ip_address.label'}}
|
||||
@helperText={{t 'resources.worker.form.ip_address.help'}}
|
||||
placeholder='127.0.0.1:9202'
|
||||
/>
|
||||
|
||||
<form.input
|
||||
@name='config_file_path'
|
||||
@value={{this.configFilePath}}
|
||||
@label={{t 'resources.worker.form.config_file_path.label'}}
|
||||
@helperText={{t 'resources.worker.form.config_file_path.help'}}
|
||||
placeholder='/home/ubuntu/boundary'
|
||||
/>
|
||||
|
||||
<form.input
|
||||
@name='worker_tags'
|
||||
@value={{this.workerTags}}
|
||||
@label={{t 'resources.worker.form.worker_tags.label'}}
|
||||
@helperText={{t 'resources.worker.form.worker_tags.help'}}
|
||||
placeholder='dev-worker, ubuntu'
|
||||
/>
|
||||
|
||||
<h3>{{t 'resources.worker.form.steps.1.title'}}</h3>
|
||||
<div class='worker-create-section'>
|
||||
{{#if (feature-flag 'byow-pki-hcp-cluster-id')}}
|
||||
<form.input
|
||||
@name='cluster_id'
|
||||
@value={{this.clusterId}}
|
||||
@label={{t 'resources.worker.form.cluster_id.label'}}
|
||||
@helperText={{t 'resources.worker.form.cluster_id.help'}}
|
||||
@linkText={{t 'actions.learn-more'}}
|
||||
@link={{doc-url 'worker.manage-workers'}}
|
||||
placeholder='69b6ddb3-ffec-42ab-a994-f43a6519470a'
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<form.input
|
||||
@name='ip_address'
|
||||
@value={{this.ipAddress}}
|
||||
@label={{t 'resources.worker.form.ip_address.label'}}
|
||||
@helperText={{t 'resources.worker.form.ip_address.help'}}
|
||||
placeholder='127.0.0.1:9202'
|
||||
/>
|
||||
|
||||
<form.input
|
||||
@name='config_file_path'
|
||||
@value={{this.configFilePath}}
|
||||
@label={{t 'resources.worker.form.config_file_path.label'}}
|
||||
@helperText={{t 'resources.worker.form.config_file_path.help'}}
|
||||
placeholder='/home/ubuntu/boundary'
|
||||
/>
|
||||
|
||||
{{#if (feature-flag 'byow-pki-upstream')}}
|
||||
<form.input
|
||||
@name='initial_upstreams'
|
||||
@value={{this.initialUpstreams}}
|
||||
@label={{t 'resources.worker.form.initial_upstreams.label'}}
|
||||
@helperText={{t 'resources.worker.form.initial_upstreams.help'}}
|
||||
placeholder='10.0.0.1, 10.0.0.2, 10.0.0.3'
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<form.input
|
||||
@name='worker_tags'
|
||||
@value={{this.workerTags}}
|
||||
@label={{t 'resources.worker.form.worker_tags.label'}}
|
||||
@helperText={{t 'resources.worker.form.worker_tags.help'}}
|
||||
placeholder='dev-worker, ubuntu'
|
||||
/>
|
||||
|
||||
<Rose::CodeEditor @codeValue={{this.createConfigText}} as |c|>
|
||||
<c.toolbar>
|
||||
<:action>
|
||||
|
||||
@@ -1,45 +1,94 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class FormWorkerCreateWorkerLedComponent extends Component {
|
||||
// =attributes
|
||||
// =services
|
||||
@service features;
|
||||
|
||||
// =attributes
|
||||
@tracked generatedWorkerAuthToken;
|
||||
@tracked clusterId;
|
||||
@tracked ipAddress;
|
||||
@tracked configFilePath;
|
||||
@tracked workerTags;
|
||||
@tracked initialUpstreams;
|
||||
|
||||
// =methods
|
||||
|
||||
convertCommaSeparatedValuesToArray(input) {
|
||||
return input
|
||||
.split(',')
|
||||
.filter((value) => value.trim())
|
||||
.map((value) => `"${value?.trim()}"`)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
// =properties
|
||||
|
||||
/**
|
||||
* Returns directory creation text for `<Rose::CodeEditor>`.
|
||||
* @type {string}
|
||||
*/
|
||||
get createConfigText() {
|
||||
return `mkdir ${this.configFilePath || '<path>'}/ ;\\
|
||||
return `mkdir ${this.configFilePath || '<path>'}/ ;
|
||||
touch ${this.configFilePath || '<path>'}/pki-worker.hcl`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns config creation text for `<Rose::CodeEditor>`. The user will see
|
||||
* different outputs based on if they are using `hcp` or `oss` binaries.
|
||||
* @type {string}
|
||||
*/
|
||||
get workerConfigText() {
|
||||
return `hcp_boundary_cluster_id = "${this.clusterId || '<config_id>'}"
|
||||
const clusterText = `hcp_boundary_cluster_id = "${
|
||||
this.clusterId || '<config_id>'
|
||||
}"`;
|
||||
|
||||
listener "tcp" {
|
||||
const tagsText = `tags {
|
||||
type = [${
|
||||
this.workerTags ? this.convertCommaSeparatedValuesToArray(this.workerTags) : '"<tag1>", "<tag2>"'
|
||||
}]
|
||||
}`;
|
||||
const upstreamText = `
|
||||
initial_upstreams = [${
|
||||
this.initialUpstreams
|
||||
? this.convertCommaSeparatedValuesToArray(this.initialUpstreams)
|
||||
: '"<upstream1>", "</upstream2>", "<upstream3>"'
|
||||
}]`;
|
||||
|
||||
const listenerText = `listener "tcp" {
|
||||
address = "0.0.0.0:9202"
|
||||
purpose = "proxy"
|
||||
}
|
||||
}`;
|
||||
|
||||
const workerText = `
|
||||
worker {
|
||||
public_addr = "${this.ipAddress || '<public_ip_address>'}"
|
||||
auth_storage_path = "${this.configFilePath || '<path>'}/worker1"
|
||||
tags {
|
||||
type = [${
|
||||
this.workerTags
|
||||
? this.workerTags
|
||||
.split(',')
|
||||
.filter((tag) => tag.trim())
|
||||
.map((tag) => `"${tag?.trim()}"`)
|
||||
.join(', ')
|
||||
: '"<tag1>", "<tag2>"'
|
||||
}]
|
||||
${
|
||||
this.features.isEnabled('byow-pki-upstream')
|
||||
? `${tagsText}${upstreamText}`
|
||||
: `${tagsText}`
|
||||
}
|
||||
}`;
|
||||
|
||||
if (this.features.isEnabled('byow-pki-hcp-cluster-id')) {
|
||||
return `${clusterText}
|
||||
|
||||
${listenerText}
|
||||
${workerText}`;
|
||||
} else {
|
||||
return `${listenerText}
|
||||
${workerText}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns boundary installation command and start worker server command
|
||||
* for `<Rose::CodeEditor>`.
|
||||
* @type {string}
|
||||
*/
|
||||
get installBoundaryText() {
|
||||
return `curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - ;\\
|
||||
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" ;\\
|
||||
@@ -47,6 +96,10 @@ sudo apt-get update && sudo apt-get install boundary ;\\
|
||||
boundary server -config="${this.configFilePath || '<path>'}/pki-worker.hcl"`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `shell` configuration object for `<Rose::CodeEditor>`.
|
||||
* @type {Object}
|
||||
*/
|
||||
get shellCodeEditor() {
|
||||
return {
|
||||
mode: 'shell',
|
||||
@@ -56,7 +109,10 @@ boundary server -config="${this.configFilePath || '<path>'}/pki-worker.hcl"`;
|
||||
styleActiveLine: false,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `hcl` configuration object for `<Rose::CodeEditor>`.
|
||||
* @type {Object}
|
||||
*/
|
||||
get hclCodeEditor() {
|
||||
return {
|
||||
mode: 'hcl',
|
||||
|
||||
Reference in new issue
Block a user