Skip to content

Commit

Permalink
Add content
Browse files Browse the repository at this point in the history
  • Loading branch information
qbart committed Nov 6, 2022
1 parent 30e185b commit aec3618
Show file tree
Hide file tree
Showing 20 changed files with 508 additions and 0 deletions.
7 changes: 7 additions & 0 deletions content/en/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Oh, Krab!"
description: "Krab is a PostgreSQL tool based on HCL syntax. Its aim is to provide fine control for your databases in every environment."
lead: "Krab is a PostgreSQL tool based on HCL syntax. Its aim is to provide fine control for your databases in every environment."
images: []
---

8 changes: 8 additions & 0 deletions content/en/blog/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "Blog"
description: "The Doks Blog."
date: 2020-10-06T08:49:55+00:00
lastmod: 2020-10-06T08:49:55+00:00
draft: false
images: []
---
17 changes: 17 additions & 0 deletions content/en/blog/say-hello-to-doks/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Say hello to Doks 👋"
description: "Introducing Doks, a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default."
excerpt: "Introducing Doks, a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default."
date: 2020-11-04T09:19:42+01:00
lastmod: 2020-11-04T09:19:42+01:00
draft: false
weight: 50
images: []
categories: ["News"]
tags: ["security", "performance", "SEO"]
contributors: ["Henk Verlinde"]
pinned: false
homepage: false
---

Introducing Doks, a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default.
7 changes: 7 additions & 0 deletions content/en/docs/commands/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Commands"
description: "Commands"
lead: ""
images: []
weight: 400
---
29 changes: 29 additions & 0 deletions content/en/docs/commands/action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: "Action"
description: "Action"
lead: ""
draft: false
images: []
menu:
docs:
parent: "commands"
identifier: "commands-action"
toc: true
---

Actions are genarated from configuration and grouped by namespace.

## Usage

```bash
krab action namespace name [arguments]
```

## Example

For [view refresh action]({{< ref "docs/configuration/resources/action#example" >}}) you would use:

```bash
krab action view refresh -name my-view-name
```

7 changes: 7 additions & 0 deletions content/en/docs/commands/migrate/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Migrate"
description: "Migrate"
lead: ""
images: []
weight: 10
---
36 changes: 36 additions & 0 deletions content/en/docs/commands/migrate/down.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "Migrate down"
description: "Migrate down"
lead: ""
draft: false
images: []
menu:
docs:
parent: "migrate"
toc: true
---

The `migrate down` command rollbacks selected migration.

After successful operation its `version` is removed from the migration table.
At the beginning of an operation advisory lock is acquired to prevent other operations to run simultaneously.

## Usage

```bash
krab migrate down [set] [version]
```

### Options

- `set` - name of the set to migrate.
- `version` - migration version to rollback.

## Example

For `default` [migration set]({{< ref "docs/configuration/resources/migration-set" >}}) and [migration]({{< ref "docs/configuration/resources/migration" >}}) version `20060102150405` you would use:

```bash
krab migrate down default 20060102150405
```

34 changes: 34 additions & 0 deletions content/en/docs/commands/migrate/status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Migrate status"
description: "Migrate status"
lead: ""
draft: false
images: []
menu:
docs:
parent: "migrate"
toc: true
---

The `migrate status` command displays currently applied/pending migrations.

## Usage

```bash
krab migrate status [set]
```

### Options

- `set` - name of the set to migrate.

### Example output

```bash
krab migrate status animals

✔ v1 create_animals
✔ v2 create_animals_view
- v3 seed_animals
```

42 changes: 42 additions & 0 deletions content/en/docs/commands/migrate/up.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "Migrate up"
description: "Migrate up"
lead: ""
draft: false
images: []
menu:
docs:
parent: "migrate"
toc: true
---

The `migrate up` command migrates all pending migration for a given migration set.

After successful migration its `version` is put into database migration table (by default `schema_migrations`).
At the beginning of an operation advisory lock is acquired to prevent other migrations to run simultaneously.

{{<alert icon="💡">}}
Migrations are executed in the order defined by migration set, NOT lexicographically.
<br>
When migration table does not exist, it will be created.
{{</alert>}}


## Usage

```bash
krab migrate up [set]
```

### Options

- `set` - name of the set to migrate.

## Example

For `default` [migration set]({{< ref "docs/configuration/resources/migration-set" >}}) you would use:

```bash
krab migrate up default
```

27 changes: 27 additions & 0 deletions content/en/docs/commands/version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Version"
description: "Version"
lead: ""
draft: false
images: []
menu:
docs:
parent: "commands"
toc: true
---

The `version` command prints the version of Krab.

## Usage

```sh
krab version
```

## Example

```sh
$ krab version
krab 0.5.0
Build a2aa572cd37e64c38f16925c1152a2bed1fc4c0a 2021-07-04
```
7 changes: 7 additions & 0 deletions content/en/docs/configuration/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Configuration"
description: "Configuration"
lead: ""
images: []
weight: 200
---
15 changes: 15 additions & 0 deletions content/en/docs/configuration/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Environment variables"
description: "Environment variables"
lead: ""
draft: false
images: []
menu:
docs:
parent: "configuration"
weight: 20
toc: true
---

- `KRAB_DIR` - directory to load configuration from, if not defined, it defaults to the current working directory
- `DATABASE_URL` - PostgreSQL connection string to use when executing actions
17 changes: 17 additions & 0 deletions content/en/docs/configuration/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Overview"
description: "Overview"
lead: ""
draft: false
images: []
menu:
docs:
parent: "configuration"
weight: 10
toc: true
---

Krab by default will load and parse all the configuration files at `KRAB_DIR` path.
File names should end with `.krab.hcl` extension, otherwise they won't be loaded.

Every command that touches database is required to provide `DATABASE_URL` environment variable.
60 changes: 60 additions & 0 deletions content/en/docs/configuration/resource-arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "Resource arguments"
description: "Resource arguments"
lead: ""
draft: false
images: []
menu:
docs:
parent: "configuration"
weight: 30
toc: true
---

Some resources accept arguments block that allows to parametrize command.

Arguments blocks are optional and can expand configuration in a flexible ways.

```hcl
resource ["label" ["label"...]] {
arguments {
arg "one" {
description = "Some argument description"
}
arg "two" {
description = "Argument with specified type"
type = "string" # default
}
}
}
```

- `arg "name"` - argument name
- `description` - summary of an argument
- `type` - currently can only be a `string` type
- arguments are required to pass into command

### Arguments usage

Krab uses Go lang templates to replace values. For full documentation refer to [official documentation](https://pkg.go.dev/text/template).
For arguments support refer to specific resource documentation.

Arguments are not quoted by default unless stated otherwise ⚠️.

Example:

```
sql = "CREATE SCHEMA {{ quote_ident .Args.name }}"
```

All arguments must be prefixed with `.Args`.


### Built-in functions

There are built-in functions that allow to operate on arguments before final template is rendered.

- `quote_ident` - quotes identifiers in database, for example: table/column names
- `quote` - quotes values in database

7 changes: 7 additions & 0 deletions content/en/docs/functions/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Functions"
description: "Functions"
lead: ""
images: []
weight: 300
---
21 changes: 21 additions & 0 deletions content/en/docs/functions/file-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "File system"
description: "Functions releated to file system"
lead: "Functions that can be used in krab configuration files."
draft: false
images: []
menu:
docs:
parent: "functions"
weight: 310
toc: true
---

## file_read

`file_read` reads a file at the given path and returns its content as a string.

```hcl
sql = file_read("path")
```

7 changes: 7 additions & 0 deletions content/en/docs/get-started/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title : "Get started"
description: "Get started."
lead: ""
images: []
weight: 100
---
Loading

0 comments on commit aec3618

Please sign in to comment.