Skip to content

Commit

Permalink
Generate specific Registry Documentation format by Release (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolte authored Aug 22, 2020
1 parent 09ce47d commit fd42e34
Show file tree
Hide file tree
Showing 34 changed files with 227 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/boring-cyborg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ labelPRBasedOnFilePath:
chore:
- .github/**
documentations:
- docs/**
- documentation/**
- mkdocs.yml
- .github/ISSUE_TEMPLATE/**
- .github/pull_request_template.md
- .github/pull_request_template.md
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ More informations about the Documentation process can be found at
https://nolte.github.io/terraform-provider-harbor/guides/development/#docs
--->
### Documentation
- [ ] Have you create or updated the provider documentation at ``./docs``?
- [ ] Have you create or updated the provider documentation at ``./documentation/provider_doc``?
- [ ] If **new** resources or datasource documentation happen, did you add this to the `mkdocs.yml` configuration?

### References
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/cicd-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release Flow

on:
push:
branches:
- "**"
jobs:
docs:
name: Publish the HTML Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install MarkdownPP mkdocs
- name: Install dependencies
run: |
cd ./documentation && go run mage.go -v GenerateDocumation
#- name: Deploy docs
# uses: mhausenblas/mkdocs-deploy-gh-pages@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 37 additions & 1 deletion .github/workflows/cicd-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,43 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
uses: actions/[email protected]
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install MarkdownPP mkdocs
- name: Install dependencies
run: |
cd ./documentation && go run mage.go -v GenerateDocumation
- uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
with:
add: 'docs'
force: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
with:
add: 'documentation/provider_doc'
force: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ terraform-provider-harbor_*
gen
bin
dist
docs

# Local .terraform directories
**/.terraform/*
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions documentation/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module main

go 1.14

require (
github.com/magefile/mage v1.10.0
github.com/otiai10/copy v1.2.0
)
10 changes: 10 additions & 0 deletions documentation/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g=
github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc=
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
11 changes: 11 additions & 0 deletions documentation/mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build ignore

package main

import (
"os"

"github.com/magefile/mage/mage"
)

func main() { os.Exit(mage.Main()) }
56 changes: 56 additions & 0 deletions documentation/magefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//+build mage

package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

"github.com/magefile/mage/sh"
copy "github.com/otiai10/copy"
)

func GenerateDocumation() error {
documentationTemplatesDir := "./provider_doc"
outputDir := "../docs"
mkdocsOut := "./mkdocs/gen"
file, err := ioutil.TempDir("", "example")
log.Printf("file %s", file)
if err != nil {
log.Fatal(err)
}

defer os.Remove(file)
err = filepath.Walk(documentationTemplatesDir,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
log.Print(path)
if strings.HasSuffix(path, ".mdpp") {
fmt.Println(path, info.Size())
targetPath := strings.ReplaceAll(filepath.Join(file, path), ".mdpp", ".md")
command := fmt.Sprintf("%s -o %s", path, targetPath)
os.MkdirAll(filepath.Dir(targetPath), 0700)
//log.Printf("Command %s", filepath.Dir(targetPath))
err = sh.Run("markdown-pp", strings.Split(command, " ")...)
if err != nil {
log.Fatal(err)
}
}
return nil
})
if err != nil {
log.Println(err)
}
copyCommand := fmt.Sprintf("%s/provider_doc", file)
err = copy.Copy(copyCommand, outputDir)
err = copy.Copy(copyCommand, mkdocsOut)

fmt.Printf("COPY: %s", copyCommand)
return err
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Please use the ```develop``` branch for new features and fixes.

### Releasing

The [Github Release](https://github.com/nolte/terraform-provider-harbor/releases) Assets will be automatic attach from the build job see ```.github/workflows/gorelease.yaml```. The Release Process use [goreleaser](https://goreleaser.com/) for create the the Binaries.
Each Release will be start, *at the moment*, from the ```develop``` branch.
The [Github Release](https://github.com/nolte/terraform-provider-harbor/releases) Assets will be automatic attach from the build job see ```.github/workflows/gorelease.yaml```. The Release Process use [goreleaser](https://goreleaser.com/) for create the the Binaries.
Each Release will be start, *at the moment*, from the ```develop``` branch.
The release description will be generated by [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) in a seperated workflow. Look to ``.github/workflows/release-drafter.yml`` for the Job, and ``.github/release-drafter.yml`` for the description configuration.

## Build

The Build scripted at the moment splitted into the GitHub Workflow Stuff and a combination of Makefiles and Shell Scripts, an Targets from the [nolte/plumbing](https://github.com/nolte/plumbing).
The Build scripted at the moment splitted into the GitHub Workflow Stuff and a combination of Makefiles and Shell Scripts, an Targets from the [nolte/plumbing](https://github.com/nolte/plumbing).
The ``Makefile/Magefile`` should be use for the local development, permanten using the full GitHub Workflows needs a lot of time.

You will get the compleat list of possible [Magefile](https://magefile.org/magefiles/) Targets with:
Expand Down Expand Up @@ -80,15 +80,23 @@ Since the Acception Tests Workflow is a matrix build, for better Tests again dif

At the moment the Swagger Json for generate the Api Client, look [./docs/adr/0001-use-swagger-for-generate-http-client.md](https://github.com/nolte/terraform-provider-harbor/blob/develop/docs/adr/0001-use-swagger-for-generate-http-client.md).

For manipulate the Swagger Json, and generating a useable go api client, we use [evanphx/json-patch](https://github.com/evanphx/json-patch) inside the buildprocess, for adding or replace different JSonStructures. So if you need new manipulations, change the `scripts/swagger-specs/patch.1.json` patch file. More informations about [jsonpatch](http://jsonpatch.com/).
For manipulate the Swagger Json, and generating a useable go api client, we use [evanphx/json-patch](https://github.com/evanphx/json-patch) inside the buildprocess, for adding or replace different JSonStructures. So if you need new manipulations, change the `scripts/swagger-specs/patch.1.json` patch file. More informations about [jsonpatch](http://jsonpatch.com/). The problem are tracked, [#12474](https://github.com/goharbor/harbor/issues/12474).

The problem are tracked, [#12474](https://github.com/goharbor/harbor/issues/12474).
## Docs

### Docs
The Documentation are presented in Different Formats, as [GitHub Page](https://nolte.github.io/terraform-provider-harbor/) , and for the [registry.terraform.io](https://registry.terraform.io/providers/nolte/harbor/latest/docs).

If you use the [VSCode DevContainer](#visual-studio-code-devcontainer), the [mkdocs](https://www.mkdocs.org/) container will be started automatical, as a sidecar container.
At the Development you ca access the current state from the Documentation at [127.0.0.1:8000](http://127.0.0.1:8000/).
For some extras, like Tasks List or Snippeds we use the [pymdown-extensions](https://facelessuser.github.io/pymdown-extensions/extensions/tasklist/) pack.

### GitHub Page

If you use the [VSCode DevContainer](#visual-studio-code-devcontainer), the [mkdocs](https://www.mkdocs.org/) container will be started automatical, as a sidecar container.
At the Development you ca access the current state from the Documentation at [127.0.0.1:8000](http://127.0.0.1:8000/).
For some extras, like Tasks List or Snippeds we use the [MarkdownPP](https://github.com/jreese/markdown-pp) project.


### Terraform Registry

The Focus from the Registy Documentation is the Provider self, for example `Resources` and `Datasources`. More informations about the Required Format at [terraform.io](https://www.terraform.io/docs/registry/providers/docs.html).


## Development Shortcuts
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
## Example Usage

```hcl
--8<--
examples/tf-acception-test-part-2/data_label.tf
--8<--
!INCLUDE "../examples/tf-acception-test-part-2/data_label.tf"

data "harbor_label" "label_2" {
id = 4
}

```

## Argument Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
## Example Usage

```hcl
--8<--
examples/tf-acception-test-part-2/data_project.tf
--8<--
!INCLUDE "../examples/tf-acception-test-part-2/data_project.tf"

data "harbor_project" "project_2" {
id = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
## Example Usage

```hcl
--8<--
examples/tf-acception-test-part-2/data_registry.tf
--8<--
!INCLUDE "../examples/tf-acception-test-part-2/data_registry.tf"

data "harbor_registry" "registry_2" {
id = 4
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Resource: harbor_label

Harbor Doc: [Managing Labels](https://goharbor.io/docs/1.10/working-with-projects/working-with-images/create-labels/)
Harbor Api: [/labels](https://demo.goharbor.io/#/Products/post_labels)
Harbor Doc: [Managing Labels](https://goharbor.io/docs/1.10/working-with-projects/working-with-images/create-labels/)
Harbor Api: [/labels](https://demo.goharbor.io/#/Products/post_labels)

## Example Usage

```hcl
--8<--
!INCLUDE "../examples/tf-acception-test/label.tf"

examples/tf-acception-test/label.tf
!INCLUDE "../examples/tf-acception-test-part-2/data_project.tf"

examples/tf-acception-test-part-2/data_project.tf
examples/tf-acception-test-part-2/label.tf
--8<--
!INCLUDE "../examples/tf-acception-test-part-2/label.tf"
```

## Argument Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Handle a [Harbor Project Resource](https://goharbor.io/docs/1.10/working-with-pr
## Example Usage

```hcl
--8<-- "examples/tf-acception-test/project.tf"
!INCLUDE "../examples/tf-acception-test/project.tf"
```

## Argument Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
## Example Usage

```hcl
--8<--
examples/tf-acception-test/project.tf
examples/tf-acception-test/usergroup.tf
examples/tf-acception-test/project_member.tf
--8<--
!INCLUDE "../examples/tf-acception-test/project.tf"

!INCLUDE "../examples/tf-acception-test/usergroup.tf"

!INCLUDE "../examples/tf-acception-test/project_member.tf"
```

## Argument Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Harbor Api: [Create](https://demo.goharbor.io/#/Products/post_registries)
## Example Usage

```hcl
--8<-- "examples/tf-acception-test/registry.tf"
!INCLUDE "../examples/tf-acception-test/registry.tf"
```

## Argument Reference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Resource: harbor_replication

Harbor Doc: [configuring-replication](https://goharbor.io/docs/2.0.0/administration/configuring-replication/)
Harbor Doc: [configuring-replication](https://goharbor.io/docs/2.0.0/administration/configuring-replication/)


## Example Usage

```hcl
--8<--
examples/tf-acception-test/project.tf
!INCLUDE "../examples/tf-acception-test/project.tf"

examples/tf-acception-test/registry.tf
!INCLUDE "../examples/tf-acception-test/registry.tf"

examples/tf-acception-test/replication.tf
--8<--
!INCLUDE "../examples/tf-acception-test/replication.tf"
```

## Argument Reference
Expand All @@ -39,7 +37,7 @@ The following arguments are supported:

* `override` - (Optional) Specify whether to override the resources at the destination if a resource with the same name exists. Default: `false`

* `enabled` - (Optional)
* `enabled` - (Optional)


## Attributes Reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ Harbor official documentation feature reference: https://goharbor.io/docs/2.0.0/
## Example Usage

```hcl
--8<--
examples/tf-acception-test/project.tf
!INCLUDE "../examples/tf-acception-test/project.tf"

examples/tf-acception-test/retention_policy.tf
--8<--
!INCLUDE "../examples/tf-acception-test/retention_policy.tf"
```

## Argument Reference
Expand Down
Loading

0 comments on commit fd42e34

Please sign in to comment.