Skip to content

Commit

Permalink
Adding cloud reset password link to cloud filebeat instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Apr 7, 2020
1 parent 994aa63 commit 51e76f4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. 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.
*/
import { i18n } from '@kbn/i18n';

export const cloudPasswordAndResetLink = i18n.translate(
'home.tutorials.common.cloud.passwordAndResetLink',
{
defaultMessage:
'Where {passwordTemplate} is the password of the `elastic` user.' +
`\\{#config.cloud.resetPasswordUrl\\}
If you've forgotten the password, use Cloud console to [reset your password](\\{config.cloud.resetPasswordUrl\\}).
\\{/config.cloud.resetPasswordUrl\\}`,
values: { passwordTemplate: '`<password>`' },
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { INSTRUCTION_VARIANT } from '../../../common/instruction_variant';
import { createTrycloudOption1, createTrycloudOption2 } from './onprem_cloud_instructions';
import { getSpaceIdForBeatsTutorial } from './get_space_id_for_beats_tutorial';
import { Platform, TutorialContext } from '../../services/tutorials/lib/tutorials_registry_types';
import { cloudPasswordAndResetLink } from './cloud_instructions';

export const createFilebeatInstructions = (context?: TutorialContext) => ({
INSTALL: {
Expand Down Expand Up @@ -299,13 +300,7 @@ export const createFilebeatCloudInstructions = () => ({
},
}),
commands: ['cloud.id: "{config.cloud.id}"', 'cloud.auth: "elastic:<password>"'],
textPost: i18n.translate(
'home.tutorials.common.filebeatCloudInstructions.config.osxTextPost',
{
defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user.',
values: { passwordTemplate: '`<password>`' },
}
),
textPost: cloudPasswordAndResetLink,
},
DEB: {
title: i18n.translate('home.tutorials.common.filebeatCloudInstructions.config.debTitle', {
Expand All @@ -318,13 +313,7 @@ export const createFilebeatCloudInstructions = () => ({
},
}),
commands: ['cloud.id: "{config.cloud.id}"', 'cloud.auth: "elastic:<password>"'],
textPost: i18n.translate(
'home.tutorials.common.filebeatCloudInstructions.config.debTextPost',
{
defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user.',
values: { passwordTemplate: '`<password>`' },
}
),
textPost: cloudPasswordAndResetLink,
},
RPM: {
title: i18n.translate('home.tutorials.common.filebeatCloudInstructions.config.rpmTitle', {
Expand All @@ -337,13 +326,7 @@ export const createFilebeatCloudInstructions = () => ({
},
}),
commands: ['cloud.id: "{config.cloud.id}"', 'cloud.auth: "elastic:<password>"'],
textPost: i18n.translate(
'home.tutorials.common.filebeatCloudInstructions.config.rpmTextPost',
{
defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user.',
values: { passwordTemplate: '`<password>`' },
}
),
textPost: cloudPasswordAndResetLink,
},
WINDOWS: {
title: i18n.translate('home.tutorials.common.filebeatCloudInstructions.config.windowsTitle', {
Expand All @@ -359,13 +342,7 @@ export const createFilebeatCloudInstructions = () => ({
}
),
commands: ['cloud.id: "{config.cloud.id}"', 'cloud.auth: "elastic:<password>"'],
textPost: i18n.translate(
'home.tutorials.common.filebeatCloudInstructions.config.windowsTextPost',
{
defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user.',
values: { passwordTemplate: '`<password>`' },
}
),
textPost: cloudPasswordAndResetLink,
},
},
});
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/cloud/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';

interface CloudConfigType {
id?: string;
resetPasswordUrl?: string;
}

interface CloudSetupDependencies {
Expand All @@ -26,13 +27,13 @@ export class CloudPlugin implements Plugin<CloudSetup> {
constructor(private readonly initializerContext: PluginInitializerContext) {}

public async setup(core: CoreSetup, { home }: CloudSetupDependencies) {
const { id } = this.initializerContext.config.get<CloudConfigType>();
const { id, resetPasswordUrl } = this.initializerContext.config.get<CloudConfigType>();
const isCloudEnabled = getIsCloudEnabled(id);

if (home) {
home.environment.update({ cloud: isCloudEnabled });
if (isCloudEnabled) {
home.tutorials.setVariable('cloud', { id });
home.tutorials.setVariable('cloud', { id, resetPasswordUrl });
}
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/cloud/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
id: schema.maybe(schema.string()),
apm: schema.maybe(apmConfigSchema),
resetPasswordUrl: schema.maybe(schema.string()),
});

export type CloudConfigType = TypeOf<typeof configSchema>;

export const config: PluginConfigDescriptor<CloudConfigType> = {
exposeToBrowser: {
id: true,
resetPasswordUrl: true,
},
schema: configSchema,
};

0 comments on commit 51e76f4

Please sign in to comment.