Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] [docs] fix direct branch injection into docs links (#116794) #117230

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions x-pack/plugins/apm/server/deprecations/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { kibanaPackageJson } from '@kbn/dev-utils';

import { GetDeprecationsContext } from '../../../../../src/core/server';
import { CloudSetup } from '../../../cloud/server';
import { getDeprecations } from './';
Expand All @@ -19,7 +21,7 @@ const deprecationContext = {
describe('getDeprecations', () => {
describe('when fleet is disabled', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({ branch: 'master' });
const deprecationsCallback = getDeprecations({ branch: 'main' });
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).toEqual([]);
});
Expand All @@ -28,7 +30,7 @@ describe('getDeprecations', () => {
describe('when running on cloud with legacy apm-server', () => {
it('returns deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
Expand All @@ -38,13 +40,20 @@ describe('getDeprecations', () => {
});
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).not.toEqual([]);
// TODO: remove when docs support "main"
if (kibanaPackageJson.branch === 'main') {
for (const { documentationUrl } of deprecations) {
expect(documentationUrl).toMatch(/\/master\//);
expect(documentationUrl).not.toMatch(/\/main\//);
}
}
});
});

describe('when running on cloud with fleet', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
Expand All @@ -60,7 +69,7 @@ describe('getDeprecations', () => {
describe('when running on prem', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
branch: 'main',
cloudSetup: { isCloudEnabled: false } as unknown as CloudSetup,
fleet: {
start: () => ({ agentPolicyService: { get: () => undefined } }),
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/apm/server/deprecations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function getDeprecations({
const isCloudEnabled = !!cloudSetup?.isCloudEnabled;

const hasCloudAgentPolicy = !isEmpty(cloudAgentPolicy);
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;

if (isCloudEnabled && !hasCloudAgentPolicy) {
deprecations.push({
Expand All @@ -48,7 +50,7 @@ export function getDeprecations({
defaultMessage:
'Running the APM Server binary directly is considered a legacy option and is deprecated since 7.16. Switch to APM Server managed by an Elastic Agent instead. Read our documentation to learn more.',
}),
documentationUrl: `https://www.elastic.co/guide/en/apm/server/${branch}/apm-integration.html`,
documentationUrl: `https://www.elastic.co/guide/en/apm/server/${docBranch}/apm-integration.html`,
level: 'warning',
correctiveActions: {
manualSteps: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import { ReportingCore } from '../';
import { deprecations } from '../lib/deprecations';

const REPORTING_USER_ROLE_NAME = 'reporting_user';
const getDocumentationUrl = (branch: string) =>
`https://www.elastic.co/guide/en/kibana/${branch}/kibana-privileges.html`;
const getDocumentationUrl = (branch: string) => {
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;
return `https://www.elastic.co/guide/en/kibana/${docBranch}/kibana-privileges.html`;
};

interface ExtraDependencies {
reportingCore: ReportingCore;
Expand Down
13 changes: 10 additions & 3 deletions x-pack/plugins/security/server/config_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
// Deprecation warning for the old array-based format of `xpack.security.authc.providers`.
(settings, _fromPath, addDeprecation, { branch }) => {
if (Array.isArray(settings?.xpack?.security?.authc?.providers)) {
// TODO: remove when docs support "main"
const docsBranch = branch === 'main' ? 'master' : 'main';
addDeprecation({
configPath: 'xpack.security.authc.providers',
title: i18n.translate('xpack.security.deprecations.authcProvidersTitle', {
Expand All @@ -43,7 +45,7 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
defaultMessage: 'Use the new object format instead of an array of provider types.',
}),
level: 'warning',
documentationUrl: `https://www.elastic.co/guide/en/kibana/${branch}/security-settings-kb.html#authentication-security-settings`,
documentationUrl: `https://www.elastic.co/guide/en/kibana/${docsBranch}/security-settings-kb.html#authentication-security-settings`,
correctiveActions: {
manualSteps: [
i18n.translate('xpack.security.deprecations.authcProviders.manualSteps1', {
Expand All @@ -59,6 +61,9 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
}
},
(settings, _fromPath, addDeprecation, { branch }) => {
// TODO: remove when docs support "main"
const docsBranch = branch === 'main' ? 'master' : 'main';

const hasProviderType = (providerType: string) => {
const providers = settings?.xpack?.security?.authc?.providers;
if (Array.isArray(providers)) {
Expand Down Expand Up @@ -86,7 +91,7 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
values: { tokenProvider },
}),
level: 'warning',
documentationUrl: `https://www.elastic.co/guide/en/kibana/${branch}/security-settings-kb.html#authentication-security-settings`,
documentationUrl: `https://www.elastic.co/guide/en/kibana/${docsBranch}/security-settings-kb.html#authentication-security-settings`,
correctiveActions: {
manualSteps: [
i18n.translate('xpack.security.deprecations.basicAndTokenProviders.manualSteps1', {
Expand All @@ -100,6 +105,8 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
}
},
(settings, _fromPath, addDeprecation, { branch }) => {
// TODO: remove when docs support "main"
const docsBranch = branch === 'main' ? 'master' : 'main';
const samlProviders = (settings?.xpack?.security?.authc?.providers?.saml ?? {}) as Record<
string,
any
Expand All @@ -119,7 +126,7 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
defaultMessage: 'This setting is no longer used.',
}),
level: 'warning',
documentationUrl: `https://www.elastic.co/guide/en/kibana/${branch}/security-settings-kb.html#authentication-security-settings`,
documentationUrl: `https://www.elastic.co/guide/en/kibana/${docsBranch}/security-settings-kb.html#authentication-security-settings`,
correctiveActions: {
manualSteps: [
i18n.translate('xpack.security.deprecations.maxRedirectURLSize.manualSteps1', {
Expand Down
15 changes: 12 additions & 3 deletions x-pack/plugins/security/server/deprecations/kibana_user_role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ async function getUsersDeprecations(
return [];
}

// TODO: remove when docs support "main"
const docsBranch = packageInfo.branch === 'main' ? 'master' : packageInfo.branch;

return [
{
title: getDeprecationTitle(),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${docsBranch}/built-in-roles.html`,
correctiveActions: {
api: {
method: 'POST',
Expand Down Expand Up @@ -159,13 +162,16 @@ async function getRoleMappingsDeprecations(
return [];
}

// TODO: remove when docs support "main"
const docsBranch = packageInfo.branch === 'main' ? 'master' : packageInfo.branch;

return [
{
title: getDeprecationTitle(),
message: getDeprecationMessage(),
level: 'warning',
deprecationType: 'feature',
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${packageInfo.branch}/built-in-roles.html`,
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${docsBranch}/built-in-roles.html`,
correctiveActions: {
api: {
method: 'POST',
Expand Down Expand Up @@ -193,6 +199,9 @@ async function getRoleMappingsDeprecations(
function deprecationError(packageInfo: PackageInfo, error: Error): DeprecationsDetails[] {
const title = getDeprecationTitle();

// TODO: remove when docs support "main"
const docsBranch = packageInfo.branch === 'main' ? 'master' : packageInfo.branch;

if (getErrorStatusCode(error) === 403) {
return [
{
Expand All @@ -202,7 +211,7 @@ function deprecationError(packageInfo: PackageInfo, error: Error): DeprecationsD
message: i18n.translate('xpack.security.deprecations.kibanaUser.forbiddenErrorMessage', {
defaultMessage: 'You do not have enough permissions to fix this deprecation.',
}),
documentationUrl: `https://www.elastic.co/guide/en/kibana/${packageInfo.branch}/xpack-security.html#_required_permissions_7`,
documentationUrl: `https://www.elastic.co/guide/en/kibana/${docsBranch}/xpack-security.html#_required_permissions_7`,
correctiveActions: {
manualSteps: [
i18n.translate(
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/task_manager/server/lib/log_health_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export function logHealthMetrics(
}

const message = `Latest Monitored Stats: ${JSON.stringify(monitoredHealth)}`;
const docLink = `https://www.elastic.co/guide/en/kibana/${kibanaPackageJson.branch}/task-manager-health-monitoring.html`;
// TODO: remove when docs support "main"
const docsBranch = kibanaPackageJson.branch === 'main' ? 'master' : 'main';

const docLink = `https://www.elastic.co/guide/en/kibana/${docsBranch}/task-manager-health-monitoring.html`;
const detectedProblemMessage = `Task Manager detected a degradation in performance. This is usually temporary, and Kibana can recover automatically. If the problem persists, check the docs for troubleshooting information: ${docLink} .`;
if (enabled) {
const driftInSeconds = (monitoredHealth.stats.runtime?.value.drift.p99 ?? 0) / 1000;
Expand Down