Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ steps:
yarn lint
displayName: "YARN LINT"

- script: |
yarn md-lint
displayName: "YARN MARKDOWN LINT"

- script: |
yarn build
displayName: "YARN BUILD"
Expand Down
4 changes: 2 additions & 2 deletions guides/config-file.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# spk-config.yaml

The [`spk-config.yaml`](./spk-config.yaml) consists of three main sections:
The [`spk-config.yaml`](../spk-config.yaml) consists of three main sections:

1. `introspection`
2. `infra`
Expand Down Expand Up @@ -35,7 +35,7 @@ There are two options to create environment variables:
A recommended approach is to have a `.env` file in your folder **(make sure it's
gitignored!)** with all variables and their values.

[Sample `.env`](./.env.example):
[Sample `.env`](../.env.example):

```
INTROSPECTION_STORAGE_ACCESS_KEY="access key"
Expand Down
4 changes: 2 additions & 2 deletions guides/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ ts-node src/index.ts project init # same as running `./spk project init`

### Implementing Commands

Refer to this [doc](./guides/command-implementation.md) for guidelines for
implementing commands.
Refer to this [doc](./command-implementation.md) for guidelines for implementing
commands.

### Running Tests

Expand Down
4 changes: 1 addition & 3 deletions guides/infra/spk-infra-generation-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ orchestrator for your Infrastructure Generation workflow using `spk infra`.
[here](https://github.com/yradsmikham/spk-infra-hld). You should be able to
create your Infra HLD repo using a scaffolding process via `spk` (i.e.
`spk infra scaffold`). For more information on how to do that, please refer
to the
[Cloud Infra Management](https://github.com/CatalystCode/spk/blob/master/docs/cloud-infra-management.md#scaffold)
doc.
to the [Cloud Infra Management](../cloud-infra-management.md) doc.

## Setup

Expand Down
4 changes: 2 additions & 2 deletions guides/infra/spk-infra-under-the-hood.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ directory):

`spk` will extend the capability to clone private repositories using personal
access tokens (PAT). For more information, please refer to this
[section](https://github.com/CatalystCode/spk/blob/master/docs/cloud-infra-management.md#authentication)
of Cloud Infra Management.
[section](../cloud-infra-management.md#authentication-private-repos) of Cloud
Infra Management.

## Future Considerations

Expand Down
2 changes: 1 addition & 1 deletion guides/infra/spk-terragrunt-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ scaffolding and generation detailed in the
4. [Multiple Template Environments](#multiple-template-environments)
5. [Embedding in SPK](#embedding-in-spk)
6. [Issues with Terragrunt Approach](#issues-with-terragrunt-approach)
7. [`spk infra` Vision](/SPK-Infra.md)
7. [`spk infra` Vision](./spk-terragrunt-day-2-scenarios.md)

## Prerequisites

Expand Down
2 changes: 1 addition & 1 deletion guides/manual-guide-to-rings.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide presumes that you have set up your `spk` project, and installed all
necessary pipelines created via `spk project init` (the lifecycle pipeline),
`spk service create` (build update hld pipeline), and `spk hld init` (manifest
generation pipeline), and followed the
[guidelines for creating helm charts](./building-helm-charts-for-spk).
[guidelines for creating helm charts](./building-helm-charts-for-spk.md).

In `spk`, we offer the concept of a `ring` - a way to route inbound traffic to
_revisions_ of a service on a Kubernetes cluster via request headers. For
Expand Down
10 changes: 5 additions & 5 deletions guides/project-service-management-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This document describes the workflow for deploying a set of services
An overview of how these different pieces fit together from an automation
perspective:

![spk resources](/guides/images/spk-resource-diagram.png "Bedrock SPK Resources")
![spk resources](./images/spk-resource-diagram.png "Bedrock SPK Resources")

## Requirements

Expand Down Expand Up @@ -134,7 +134,7 @@ applied to the Kubernetes cluster by Flux.
```

**NOTE** `spk hld` command documentation can be found
[here](/guides/hld-management.md).
[here](./hld-management.md).

### Materialized Manifests Repository

Expand Down Expand Up @@ -225,7 +225,7 @@ application repositories
run `install-lifecycle-pipeline` once for each repo.

**NOTE** `spk project` command documentation can be found
[here](/guides/project-management.md).
[here](./project-management.md).

#### Adding a Service to a Application Repository

Expand All @@ -249,7 +249,7 @@ application repositories
definition in Azure Devops.

**NOTE** `spk service` command documentation can be found
[here](/guides/service-management.md).
[here](./service-management.md).

#### Helm Configuration for SPK

Expand Down Expand Up @@ -426,7 +426,7 @@ parameters to `spk service create --helm-config-git`:
```

**NOTE** `spk service` command documentation can be found
[here](/guides/service-management.md).
[here](./service-management.md).

## Helm Charts

Expand Down
10 changes: 5 additions & 5 deletions guides/service-introspection-onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Service Introspection shows information about a

Service introspection is used via the `spk deployment` commands. More
information about the commands is available in the command reference
[here](https://github.com/CatalystCode/spk/blob/master/docs/service-introspection.md).
[here](./service-introspection.md).

The following diagram shows the main components of service introspection.
![spk service introspection diagram](./images/service_introspection.png)
Expand Down Expand Up @@ -34,7 +34,7 @@ it or use an existing one.
**Option 1:**

Use the
[`spk deployment onboard`](https://github.com/CatalystCode/spk/blob/master/guides/service-introspection.md#onboard)
[`spk deployment onboard`](https://catalystcode.github.io/spk/commands/#master@deployment_onboard)
command.

**Option 2:**
Expand Down Expand Up @@ -248,10 +248,10 @@ After completing the steps in this guide, you should be able to:

- Validate and verify the `spk-config.yaml` settings and the service
introspection storage using
[`spk deployment validate`](https://github.com/CatalystCode/spk/blob/master/docs/service-introspection.md#validate)
[`spk deployment validate`](https://catalystcode.github.io/spk/commands/#master@deployment_validate)

- Get information about your deployment using
[`spk deployment get`](https://github.com/CatalystCode/spk/blob/master/docs/service-introspection.md#get)
[`spk deployment get`](https://catalystcode.github.io/spk/commands/#master@deployment_get)

- Launch the dashboard to visualize the data using
[`spk deployment dashboard`](https://github.com/CatalystCode/spk/blob/master/docs/service-introspection.md#dashboard)
[`spk deployment dashboard`](https://catalystcode.github.io/spk/commands/#master@deployment_dashboard)
2 changes: 1 addition & 1 deletion guides/service-introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Global options:
## Requirements

Fill out the service introspection settings in your spk config file, for example
`spk-config.yaml`. [Sample config file](./../../spk-config.yaml).
`spk-config.yaml`. [Sample config file](../spk-config.yaml).

```
introspection:
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build-cmd-docs": "ts-node tools/generateDoc.ts",
"lint": "eslint 'src/**/*.ts{,x}'",
"lint-fix": "eslint --fix 'src/**/*.ts{,x}'",
"md-lint": "ts-node tools/mdLint.ts",
"format": "prettier --write 'src/**/*.ts{,x}'",
"test": "jest --rootDir src --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html",
"test-watch": "jest --watchAll",
Expand Down Expand Up @@ -39,6 +40,7 @@
"jest-junit": "^10.0.0",
"jest-when": "^2.7.0",
"lint-staged": ">=10",
"markdown-link-check": "^3.8.0",
"mock-fs": "^4.10.2",
"nyc": "^14.1.1",
"pkg": "^4.4.0",
Expand Down
5 changes: 1 addition & 4 deletions src/lib/pipelines/variableGroup.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */
import {
VariableGroup,
VariableGroupParameters,
} from "azure-devops-node-api/interfaces/TaskAgentInterfaces";
import { VariableGroupParameters } from "azure-devops-node-api/interfaces/TaskAgentInterfaces";
import uuid from "uuid/v4";
import * as azdoClient from "../azdoClient";
import { readYaml } from "../../config";
Expand Down
14 changes: 7 additions & 7 deletions tools/generateDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import fs from "fs";
import path from "path";
import { CommandBuildElements } from "../src/lib/commandBuilder";

interface ICommand {
interface Command {
command: string;
subcommands: CommandBuildElements[];
}

interface ICommandElement extends CommandBuildElements {
interface CommandElement extends CommandBuildElements {
markdown?: string;
}

Expand All @@ -17,9 +17,9 @@ interface ICommandElement extends CommandBuildElements {
const getAllDecorators = (curDir: string): CommandBuildElements[] => {
const allFiles = fs.readdirSync(curDir);
const jsonFiles = allFiles.filter(f => f.endsWith(".json"));
const arrJson: ICommandElement[] = [];
const arrJson: CommandElement[] = [];
jsonFiles.forEach(fileName => {
const json = require(path.join(curDir, fileName)) as ICommandElement;
const json = require(path.join(curDir, fileName)) as CommandElement;
if (!json.disabled) {
const mdPath = path.join(
curDir,
Expand All @@ -35,7 +35,7 @@ const getAllDecorators = (curDir: string): CommandBuildElements[] => {
};

// get sub folders under commands folder.
const getSubDirectories = (curDir: string) => {
const getSubDirectories = (curDir: string): string[] => {
return fs
.readdirSync(curDir)
.map(f => path.join(curDir, f))
Expand All @@ -46,7 +46,7 @@ const getSubDirectories = (curDir: string) => {
// command object. e.g `spk infra generate` and
// `spk deployment dashboard`
const listCommands = (
allCommands: ICommand[]
allCommands: Command[]
): { [key: string]: CommandBuildElements } => {
const mainCommands: { [key: string]: CommandBuildElements } = {};
allCommands.forEach(cmd => {
Expand All @@ -68,7 +68,7 @@ const dir = path.join(process.cwd(), "src", "commands");
const commandDirs = getSubDirectories(dir);
commandDirs.unshift(dir); // this is needed because `spk init` is outside `commands` folder

const commands: ICommand[] = commandDirs
const commands: Command[] = commandDirs
.map(d => {
return {
command: path.basename(d),
Expand Down
6 changes: 3 additions & 3 deletions tools/locateAliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import path from "path";
import { CommandBuildElements } from "../src/lib/commandBuilder";

interface ICommandElement extends CommandBuildElements {
interface CommandElement extends CommandBuildElements {
markdown?: string;
}

Expand All @@ -12,9 +12,9 @@ interface ICommandElement extends CommandBuildElements {
const getAllDecorators = (curDir: string): CommandBuildElements[] => {
const allFiles = fs.readdirSync(curDir);
const jsonFiles = allFiles.filter(f => f.endsWith(".json"));
const arrJson: ICommandElement[] = [];
const arrJson: CommandElement[] = [];
jsonFiles.forEach(fileName => {
const json = require(path.join(curDir, fileName)) as ICommandElement;
const json = require(path.join(curDir, fileName)) as CommandElement;
arrJson.push(json);
});
return arrJson;
Expand Down
38 changes: 38 additions & 0 deletions tools/mdLint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import fs from "fs";
import path from "path";
import { exec } from "../src/lib/shell";

// get sub folders under commands folder.
const getMarkdownFiles = (curDir: string, mds: string[]): void => {
fs.readdirSync(curDir).forEach((f) => {
const p = path.join(curDir, f);
if (fs.lstatSync(p).isDirectory()) {
getMarkdownFiles(p, mds);
} else if (p.endsWith(".md")) {
mds.push(p);
}
});
};

const testMd = async (f: string): Promise<void> => {
try {
await exec("./node_modules/.bin/markdown-link-check", [f]);
} catch (e) {
console.log(`${f}: ${e.message}`);
process.exit(1);
}
};

(async (): Promise<void> => {
Copy link
Member

@bnookala bnookala Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this script file may be un-necessary:

See: https://github.com/tcort/markdown-link-check#check-links-from-a-local-markdown-folder-recursive

You can inline this into a package.json script instead of calling this custom script

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cannot because i need a status code 1 to stop the script. :-)
the inline approach always return 0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Dennis, not quite sure I understand what you're saying. Npm scripts will exit with 1 if if any of the commands fail:

  "scripts": {
    "i-will-fail": "false && true"
  },
npm run i-will-fail # will exit with code 1

are you thinking othewise?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can try it yourself and let me know what you get
add this to your package.json

  "md-lint": "find guides -name \\*.md -exec markdown-link-check {} \\",

or just ran (at the root of spk repo)

find guides -name \*.md -exec markdown-link-check {} \;

then

echo $?

there are errors reported by the tool and it is returning 0 status code.

Copy link
Member

@bnookala bnookala Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisseah try the suggestion here: tcort/markdown-link-check#57 (comment)

find guides -name \*.md | xargs -n 1 markdown-link-check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnookala
and what about people using windows?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisseah this isn't a run-time requirement - just a development requirement. I expect that developers who are running windows who also want to contribute to spk development should do their work in a WSL environment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then. We do not support windows runtime.

const dir = path.join(process.cwd(), "guides");
const mdFiles: string[] = [];
getMarkdownFiles(dir, mdFiles);
const promises: Promise<void>[] = [];

mdFiles.forEach((f) => {
promises.push(testMd(f));
});

await Promise.all(promises);
process.exit(0);
})();
Loading