Skip to content

Commit

Permalink
Install Test Storage Backend for Hub when USE_TEST_SETUP=true (#655)
Browse files Browse the repository at this point in the history
- Install Test Storage Backend for Hub when USE_TEST_SETUP=true
- Generate documentation for Populator
  • Loading branch information
pkosiec authored Mar 10, 2022
1 parent 955dd17 commit 990d46b
Show file tree
Hide file tree
Showing 28 changed files with 441 additions and 131 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,19 @@ gen-go-source-code:
go generate -x ./...
.PHONY: gen-go-source-code

gen-docs: gen-docs-cli ## Generate all documentation
gen-docs: gen-docs-cli gen-docs-populator ## Generate all documentation
.PHONY: gen-docs

gen-docs-cli:
rm -f ./cmd/cli/docs/*
go run cmd/cli/main.go gen-usage-docs
.PHONY: gen-docs-cli

gen-docs-populator:
rm -f ./cmd/populator/docs/*
go run cmd/populator/main.go gen-usage-docs
.PHONY: gen-docs-populator

###############
# Development #
###############
Expand Down
20 changes: 2 additions & 18 deletions cmd/cli/cmd/docs.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
package cmd

import (
"fmt"
"path/filepath"
"strings"

"capact.io/capact/internal/frontmatter"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

const (
docsTargetDir = "./cmd/cli/docs"

frontmatterFormat = `---
title: %s
---
`
)

// NewDocs returns a cobra.Command for generating Capact CLI documentation.
Expand All @@ -30,14 +21,7 @@ func NewDocs() *cobra.Command {
root.DisableAutoGenTag = true

defaultLinkHandler := func(s string) string { return s }
return doc.GenMarkdownTreeCustom(root, docsTargetDir, frontmatterFilePrepender, defaultLinkHandler)
return doc.GenMarkdownTreeCustom(root, docsTargetDir, frontmatter.FilePrepender, defaultLinkHandler)
},
}
}

func frontmatterFilePrepender(filePath string) string {
fileName := filepath.Base(filePath)
fileNameWithoutExt := strings.TrimSuffix(fileName, filepath.Ext(fileName))
title := strings.Replace(fileNameWithoutExt, "_", " ", -1)
return fmt.Sprintf(frontmatterFormat, title)
}
2 changes: 1 addition & 1 deletion cmd/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewInstall() *cobra.Command {
flags.StringVar(&opts.Namespace, "namespace", capact.Namespace, "Capact namespace.")
flags.StringVar(&opts.Environment, "environment", capact.KindEnv, "Capact environment.")
flags.StringSliceVar(&opts.InstallComponents, "install-component", capact.Components.All(), "Components names that should be installed. Takes comma-separated list.")
flags.StringSliceVar(&opts.BuildImages, "build-image", capact.Images.All(), "Local images names that should be build when using @local version. Takes comma-separated list.")
flags.StringSliceVar(&opts.BuildImages, "build-image", capact.Images.DefaultList(), "Local images names that should be build when using @local version. Takes comma-separated list.")
flags.BoolVar(&opts.Parameters.IncreaseResourceLimits, "increase-resource-limits", true, "Enables higher resource requests and limits for components.")
flags.DurationVar(&opts.Timeout, "timeout", 10*time.Minute, `Maximum time during which the upgrade process is being watched, where "0" means "infinite". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`)
flags.BoolVar(&opts.UpdateHostsFile, "update-hosts-file", true, "Updates /etc/hosts with entry for Capact GraphQL Gateway.")
Expand Down
27 changes: 27 additions & 0 deletions cmd/populator/cmd/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"capact.io/capact/internal/frontmatter"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

const (
docsTargetDir = "./cmd/populator/docs"
)

// NewDocs returns a cobra.Command for generating Populator documentation.
func NewDocs(cliName string) *cobra.Command {
return &cobra.Command{
Use: "gen-usage-docs",
Hidden: true,
Short: "Generate usage documentation",
RunE: func(cmd *cobra.Command, args []string) error {
root := NewRoot(cliName)
root.DisableAutoGenTag = true

defaultLinkHandler := func(s string) string { return s }
return doc.GenMarkdownTreeCustom(root, docsTargetDir, frontmatter.FilePrepender, defaultLinkHandler)
},
}
}
1 change: 1 addition & 0 deletions cmd/populator/cmd/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func NewRegister(cliName string) *cobra.Command {

hub.AddCommand(
NewCapactInstallation(cliName),
NewTestStorageBackend(cliName),
NewOCFManifests(cliName),
)
return hub
Expand Down
28 changes: 28 additions & 0 deletions cmd/populator/cmd/register/test-storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package register

import (
"capact.io/capact/internal/cli/testing"
"github.com/docker/cli/cli"
"github.com/spf13/cobra"

"capact.io/capact/internal/cli/heredoc"
)

// NewTestStorageBackend returns a cobra.Command for populating storage backend TypeInstance for testing purposes.
func NewTestStorageBackend(cliName string) *cobra.Command {
return &cobra.Command{
Use: "test-storage-backend",
Short: "Produces and uploads TypeInstances which describe storage backend for testing purposes",
Example: heredoc.WithCLIName(`
<cli> test-storage-backend
`, cliName),
Args: cli.RequiresMaxArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
storageRegister, err := testing.NewStorageBackendRegister()
if err != nil {
return err
}
return storageRegister.RegisterTypeInstances(cmd.Context())
},
}
}
1 change: 1 addition & 0 deletions cmd/populator/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewRoot(cliName string) *cobra.Command {

rootCmd.AddCommand(
register.NewRegister(cliName),
NewDocs(cliName),
)

return rootCmd
Expand Down
22 changes: 22 additions & 0 deletions cmd/populator/docs/populator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: populator
---

## populator



```
populator [flags]
```

### Options

```
-h, --help help for populator
```

### SEE ALSO

* [populator register](populator_register.md) - This command consists of multiple subcommands which allows you to register Capact resources

21 changes: 0 additions & 21 deletions cmd/populator/docs/populator_register-capact-installation.md

This file was deleted.

76 changes: 0 additions & 76 deletions cmd/populator/docs/populator_register-ocf-manifests.md

This file was deleted.

21 changes: 21 additions & 0 deletions cmd/populator/docs/populator_register.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: populator register
---

## populator register

This command consists of multiple subcommands which allows you to register Capact resources

### Options

```
-h, --help help for register
```

### SEE ALSO

* [populator](populator.md) -
* [populator register capact-installation](populator_register_capact-installation.md) - Produces and uploads TypeInstances which describe Capact installation
* [populator register ocf-manifests](populator_register_ocf-manifests.md) - Populates locally available manifests into Neo4j database
* [populator register test-storage-backend](populator_register_test-storage-backend.md) - Produces and uploads TypeInstances which describe storage backend for testing purposes

29 changes: 29 additions & 0 deletions cmd/populator/docs/populator_register_capact-installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: populator register capact-installation
---

## populator register capact-installation

Produces and uploads TypeInstances which describe Capact installation

```
populator register capact-installation [flags]
```

### Examples

```
populator capact-installation
```

### Options

```
-h, --help help for capact-installation
```

### SEE ALSO

* [populator register](populator_register.md) - This command consists of multiple subcommands which allows you to register Capact resources

30 changes: 30 additions & 0 deletions cmd/populator/docs/populator_register_ocf-manifests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: populator register ocf-manifests
---

## populator register ocf-manifests

Populates locally available manifests into Neo4j database

```
populator register ocf-manifests [MANIFEST_PATH] [flags]
```

### Examples

```
APP_JSON_PUBLISH_ADDR=http://{HOST_IP} populator .
```

### Options

```
-h, --help help for ocf-manifests
--source strings Manifests location
```

### SEE ALSO

* [populator register](populator_register.md) - This command consists of multiple subcommands which allows you to register Capact resources

29 changes: 29 additions & 0 deletions cmd/populator/docs/populator_register_test-storage-backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: populator register test-storage-backend
---

## populator register test-storage-backend

Produces and uploads TypeInstances which describe storage backend for testing purposes

```
populator register test-storage-backend [flags]
```

### Examples

```
populator test-storage-backend
```

### Options

```
-h, --help help for test-storage-backend
```

### SEE ALSO

* [populator register](populator_register.md) - This command consists of multiple subcommands which allows you to register Capact resources

4 changes: 4 additions & 0 deletions deploy/kubernetes/charts/capact/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ dependencies:
- name: dashboard
version: "0.0.1"
repository: "file://charts/dashboard"
- name: test-storage-backend
version: "0.0.1"
repository: "file://charts/test-storage-backend"
condition: testStorageBackend.enabled
Loading

0 comments on commit 990d46b

Please sign in to comment.