Skip to content

Commit a965a9a

Browse files
authored
Merge pull request #1654 from breml/rename-incus-generate
Rename incus-generate and incus-doc
2 parents bd92072 + d487a00 commit a965a9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+60
-60
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ update-protobuf:
127127

128128
.PHONY: update-schema
129129
update-schema:
130-
cd cmd/generate-database && $(GO) build -o $(GOPATH)/bin/incus-generate -tags "$(TAG_SQLITE3)" $(DEBUG) && cd -
130+
cd cmd/generate-database && $(GO) build -o $(GOPATH)/bin/generate-database -tags "$(TAG_SQLITE3)" $(DEBUG) && cd -
131131
$(GO) generate ./...
132132
gofmt -s -w ./internal/server/db/
133133
goimports -w ./internal/server/db/
@@ -143,8 +143,8 @@ endif
143143
.PHONY: update-metadata
144144
update-metadata: build
145145
@echo "Generating golang documentation metadata"
146-
cd cmd/generate-config && CGO_ENABLED=0 $(GO) build -o $(GOPATH)/bin/incus-doc
147-
$(GOPATH)/bin/incus-doc . --json ./internal/server/metadata/configuration.json --txt ./doc/config_options.txt
146+
cd cmd/generate-config && CGO_ENABLED=0 $(GO) build -o $(GOPATH)/bin/generate-config
147+
$(GOPATH)/bin/generate-config . --json ./internal/server/metadata/configuration.json --txt ./doc/config_options.txt
148148

149149
.PHONY: doc-setup
150150
doc-setup: client

cmd/generate-config/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# incus-doc
1+
# generate-config
22

33
A small CLI to parse comments in a Golang codebase meant to be used for a documentation tool (like Sphinx for example).
44

55
It parses the comments from the AST and extracts their documentation.
66

77
# Usage
88

9-
$ incus-doc -h
10-
Usage of incus-doc:
9+
$ generate-config -h
10+
Usage of generate-config:
1111
-e value
1212
Path that will be excluded from the process
1313

@@ -78,7 +78,7 @@ A comment is formatted this way:
7878

7979
The go-swagger spec from source generator can only handles `swagger:meta` (global file/package level documentation), `swagger:route` (API endpoints), `swagger:params` (function parameters), `swagger:operation` (method documentation), `swagger:response` (API response content documentation), `swagger:model` (struct documentation) generation. In our use case, we would want a config variable spec generator that can bundle any key-value data pairs alongside metadata to build a sense of hierarchy and identity (we want to associate a unique key to each gendoc comment group that will also be displayed in the generated documentation)
8080

81-
In a swagger fashion, `incus-doc` can associate metadata key-value pairs (here for example, `group` and `key`) to data key-value pairs. As a result, it can generate a YAML tree out of the code documentation and also a Markdown document.
81+
In a swagger fashion, `generate-config` can associate metadata key-value pairs (here for example, `group` and `key`) to data key-value pairs. As a result, it can generate a YAML tree out of the code documentation and also a Markdown document.
8282

8383
## Output
8484

cmd/generate-config/incus_doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func writeDocFile(inputJSONPath, outputTxtPath string) error {
296296

297297
sortedEntityKeys := getSortedKeysFromMap(jsonDoc.Configs)
298298
// create a string buffer
299-
buffer := bytes.NewBufferString("// Code generated by incus-doc; DO NOT EDIT.\n\n")
299+
buffer := bytes.NewBufferString("// Code generated by generate-config from the incus project; DO NOT EDIT.\n\n")
300300
for _, entityKey := range sortedEntityKeys {
301301
entityEntries := jsonDoc.Configs[entityKey]
302302
sortedGroupKeys := getSortedKeysFromMap(entityEntries.(map[string]any))

cmd/generate-config/incus_doc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/stretchr/testify/assert"
77
)
88

9-
// Test the alphabetical sorting of a `incus-doc` JSON structure.
9+
// Test the alphabetical sorting of a `generate-config` JSON structure.
1010
func TestJSONSorted(t *testing.T) {
1111
projectEntries := make(map[string]any)
1212
projectEntries["entityKey1"] = map[string]any{

cmd/generate-config/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ var exclude []string
1212
var jsonOutput string
1313
var txtOutput string
1414
var rootCmd = &cobra.Command{
15-
Use: "incus-doc",
16-
Short: "incus-doc - a simple tool to generate documentation for Incus",
17-
Long: "incus-doc - a simple tool to generate documentation for Incus. It outputs a YAML and a Markdown file that contain the content of all `gendoc:generate` statements in the project.",
15+
Use: "generate-config",
16+
Short: "generate-config - a simple tool to generate documentation for Incus",
17+
Long: "generate-config - a simple tool to generate documentation for Incus. It outputs a YAML and a Markdown file that contain the content of all `gendoc:generate` statements in the project.",
1818
Args: cobra.ExactArgs(1),
1919
Run: func(cmd *cobra.Command, args []string) {
2020
if len(args) != 1 {
@@ -42,9 +42,9 @@ func main() {
4242
rootCmd.Flags().StringVarP(&txtOutput, "txt", "t", "", "Output TXT file containing the generated documentation")
4343
err := rootCmd.Execute()
4444
if err != nil {
45-
fmt.Fprintf(os.Stderr, "incus-doc failed: %v", err)
45+
fmt.Fprintf(os.Stderr, "generate-config failed: %v", err)
4646
os.Exit(1)
4747
}
4848

49-
log.Println("incus-doc finished successfully")
49+
log.Println("generate-config finished successfully")
5050
}

cmd/generate-database/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# `incus-generate`
1+
# `generate-database`
22

33
## Introduction
44

5-
`incus-generate` is a database statement and associated `go` function generator
6-
for Incus and related projects. `incus-generate` utilizes `go`'s code generation
5+
`generate-database` is a database statement and associated `go` function generator
6+
for Incus and related projects. `generate-database` utilizes `go`'s code generation
77
directives (`//go:generate ...`) alongside go's [ast](https://pkg.go.dev/go/ast)
88
package for parsing the syntax tree for go structs and variables. We use
9-
`incus-generate` for the majority of our SQL statements and database interactions
9+
`generate-database` for the majority of our SQL statements and database interactions
1010
on the `go` side for consistency and predictability.
1111

1212
## Usage
@@ -18,12 +18,12 @@ establish the command, the target file, and ensure the file has been cleared of
1818
content:
1919

2020
```go
21-
//go:generate -command mapper incus-generate db mapper -t instances.mapper.go
21+
//go:generate -command mapper generate-database db mapper -t instances.mapper.go
2222
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
2323

2424
```
2525

26-
This will initiate a call to `incus-generate db mapper -t instances.mapper.go` on
26+
This will initiate a call to `generate-database db mapper -t instances.mapper.go` on
2727
each call to the go generation directive `mapper`.
2828

2929
### Generation Directive Arguments
@@ -136,7 +136,7 @@ type InstanceFilter struct {
136136
}
137137
```
138138

139-
`incus-generate` will handle parsing of structs differently based on the composition of the struct in four different ways.
139+
`generate-database` will handle parsing of structs differently based on the composition of the struct in four different ways.
140140

141141
Non-`EntityType` structs will only support `GetMany`, `Create`, `Update`, and `Delete` functions.
142142

@@ -154,7 +154,7 @@ including a comma separated list to `references=<OtherEntity>` in the code gener
154154
### ReferenceTable
155155

156156
A struct that contains a field named `ReferenceID` will be parsed this way.
157-
`incus-generate` will use this struct to generate more abstract SQL statements and functions of the form `<parent_table>_<this_table>`.
157+
`generate-database` will use this struct to generate more abstract SQL statements and functions of the form `<parent_table>_<this_table>`.
158158

159159
Real world invocation of these statements and functions should be done through an `EntityTable` `method` call with the tag `references=<ThisStruct>`. This `EntityTable` will replace the `<parent_table>` above.
160160

cmd/generate-database/file/write.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func Reset(path string, imports []string, buildComment string, iface bool) error
2727

2828
content := fmt.Sprintf(`%spackage %s
2929
30-
// The code below was generated by %s - DO NOT EDIT!
30+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
3131
3232
import (
33-
`, buildComment, os.Getenv("GOPACKAGE"), os.Args[0])
33+
`, buildComment, os.Getenv("GOPACKAGE"))
3434

3535
for _, uri := range imports {
3636
content += fmt.Sprintf("\t%q\n", uri)

cmd/generate-database/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// Return a new root command.
1010
func newRoot() *cobra.Command {
1111
cmd := &cobra.Command{
12-
Use: "incus-generate",
12+
Use: "generate-database",
1313
Short: "Code generation tool for Incus development",
1414
Long: `This is the entry point for all "go:generate" directives
1515
used in Incus' source code.`,

doc/config_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code generated by incus-doc; DO NOT EDIT.
1+
// Code generated by generate-config from the incus project; DO NOT EDIT.
22

33
<!-- config group cluster-cluster start -->
44
```{config:option} scheduler.instance cluster-cluster

internal/server/db/cluster/certificate_projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package cluster
44

55
// Code generation directives.
66
//
7-
//go:generate -command mapper incus-generate db mapper -t certificate_projects.mapper.go
7+
//go:generate -command mapper generate-database db mapper -t certificate_projects.mapper.go
88
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
99
//
1010
//go:generate mapper stmt -e certificate_project objects

internal/server/db/cluster/certificate_projects.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/certificates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// Code generation directives.
1717
//
18-
//go:generate -command mapper incus-generate db mapper -t certificates.mapper.go
18+
//go:generate -command mapper generate-database db mapper -t certificates.mapper.go
1919
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
2020
//
2121
//go:generate mapper stmt -e certificate objects

internal/server/db/cluster/certificates.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/cluster_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/lxc/incus/v6/shared/api"
88
)
99

10-
//go:generate -command mapper incus-generate db mapper -t cluster_groups.mapper.go
10+
//go:generate -command mapper generate-database db mapper -t cluster_groups.mapper.go
1111
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1212
//
1313
//go:generate mapper stmt -e cluster_group objects table=cluster_groups

internal/server/db/cluster/cluster_groups.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package cluster
44

55
// Code generation directives.
66
//
7-
//go:generate -command mapper incus-generate db mapper -t config.mapper.go
7+
//go:generate -command mapper generate-database db mapper -t config.mapper.go
88
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
99
//
1010
//go:generate mapper stmt -e config objects

internal/server/db/cluster/config.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/devices.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// Code generation directives.
1010
//
11-
//go:generate -command mapper incus-generate db mapper -t devices.mapper.go
11+
//go:generate -command mapper generate-database db mapper -t devices.mapper.go
1212
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1313
//
1414
//go:generate mapper stmt -e device objects

internal/server/db/cluster/devices.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// Code generation directives.
1111
//
12-
//go:generate -command mapper incus-generate db mapper -t images.mapper.go
12+
//go:generate -command mapper generate-database db mapper -t images.mapper.go
1313
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1414
//
1515
//go:generate mapper stmt -e image objects

internal/server/db/cluster/images.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/instance_profiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
// Code generation directives.
1212
//
13-
//go:generate -command mapper incus-generate db mapper -t instance_profiles.mapper.go
13+
//go:generate -command mapper generate-database db mapper -t instance_profiles.mapper.go
1414
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1515
//
1616
//go:generate mapper stmt -e instance_profile objects

internal/server/db/cluster/instance_profiles.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// Code generation directives.
1717
//
18-
//go:generate -command mapper incus-generate db mapper -t instances.mapper.go
18+
//go:generate -command mapper generate-database db mapper -t instances.mapper.go
1919
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
2020
//
2121
//go:generate mapper stmt -e instance objects

internal/server/db/cluster/instances.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/networks_integrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// Code generation directives.
1313
//
14-
//go:generate -command mapper incus-generate db mapper -t networks_integrations.mapper.go
14+
//go:generate -command mapper generate-database db mapper -t networks_integrations.mapper.go
1515
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1616
//
1717
//go:generate mapper stmt -e network_integration objects

internal/server/db/cluster/networks_integrations.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cluster
22

3-
//go:generate -command mapper incus-generate db mapper -t nodes.mapper.go
3+
//go:generate -command mapper generate-database db mapper -t nodes.mapper.go
44
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
55
//
66
//go:generate mapper stmt -e node id

internal/server/db/cluster/nodes.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/nodes_cluster_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cluster
22

33
// Code generation directives.
44
//
5-
//go:generate -command mapper incus-generate db mapper -t nodes_cluster_groups.mapper.go
5+
//go:generate -command mapper generate-database db mapper -t nodes_cluster_groups.mapper.go
66
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
77
//
88
//go:generate mapper stmt -e node_cluster_group objects table=nodes_cluster_groups

internal/server/db/cluster/nodes_cluster_groups.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/operations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// Code generation directives.
1010
//
11-
//go:generate -command mapper incus-generate db mapper -t operations.mapper.go
11+
//go:generate -command mapper generate-database db mapper -t operations.mapper.go
1212
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1313
//
1414
//go:generate mapper stmt -e operation objects

internal/server/db/cluster/operations.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

internal/server/db/cluster/profiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// Code generation directives.
1414
//
15-
//go:generate -command mapper incus-generate db mapper -t profiles.mapper.go
15+
//go:generate -command mapper generate-database db mapper -t profiles.mapper.go
1616
//go:generate mapper reset -i -b "//go:build linux && cgo && !agent"
1717
//
1818
//go:generate mapper stmt -e profile objects

internal/server/db/cluster/profiles.mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package cluster
44

5-
// The code below was generated by incus-generate - DO NOT EDIT!
5+
// The code below was generated by generate-database from the incus project - DO NOT EDIT!
66

77
import (
88
"context"

0 commit comments

Comments
 (0)