Skip to content

Commit

Permalink
📝 add dev env instructions for beta v9 (#1733)
Browse files Browse the repository at this point in the history
Co-authored-by: Christoph Hartmann <[email protected]>
  • Loading branch information
vjeffrey and chris-rock authored Sep 14, 2023
1 parent 92834a4 commit d87a128
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ asns
Auths
autoaccept
autoscaler
awsconf
awsp
backupconfiguration
bigquery
BLOCKLIST
Expand Down
64 changes: 50 additions & 14 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

Before building from source, be sure to install:

- [Go 1.20.0+](https://golang.org/dl/)
- [Go 1.21.0+](https://golang.org/dl/)
- [Protocol Buffers v21+](https://github.com/protocolbuffers/protobuf/releases)

On macOS systems with Homebrew, run: `brew install go@1.19 protobuf`
On macOS systems with Homebrew, run: `brew install go@1.21 protobuf`

## Install from source

1. Verify that you have Go 1.19+ installed:
1. Verify that you have Go 1.21+ installed:

```
$ go version
```
```
$ go version
```

If `go` is not installed or an older version exists, follow instructions on [the Go website](https://golang.org/doc/install).

Expand All @@ -28,13 +28,15 @@ If `go` is not installed or an older version exists, follow instructions on [the
$ cd cnquery
```

3. Build and install:
3. Build and install on Unix-like systems

```sh
# Build all providers
make providers

#### Unix-like systems
```sh
# To install cnquery using Go into the $GOBIN directory:
make cnquery/install
```
# To install cnquery using Go into the $GOBIN directory:
make cnquery/install
```

## Develop cnquery, providers, or resources

Expand All @@ -52,6 +54,41 @@ make cnquery/generate

This generates and updates all required files for the build. At this point you can `make cnquery/install` again as outlined above.

## Debug providers

In v9 we introduced providers, which split up the providers into individual go modules. This make it more development more lightweight and speedy.

To debug a provider locally with cnquery:

1. Copy the resources json file `providers/TYPE/resources/TYPE.resources.json` to the `providers` top-level dir
2. Add the provider to `providers/builtin.go`

```
awsconf "go.mondoo.com/cnquery/providers/aws/config"
awsp "go.mondoo.com/cnquery/providers/aws/provider"
//go:embed aws.resources.json
var awsInfo []byte
awsconf.Config.ID: {
Runtime: &RunningProvider{
Name: awsconf.Config.Name,
ID: awsconf.Config.ID,
Plugin: awsp.Init(),
Schema: MustLoadSchema("aws", awsInfo),
isClosed: false,
},
Config: &awsconf.Config,
},
```

3. Change the local provider location in `go.mod`

`replace go.mondoo.com/cnquery/providers/aws => ./providers/aws`

4. Build the provider after making changes: `make providers/build/aws`
5. Run cnquery like you normally do (`go run apps/cnquery/cnquery.go shell aws`). You should see it note that it is "using builtin provider for X"

## Contribute changes

### Mark PRs with emojis
Expand All @@ -60,5 +97,4 @@ We love emojis in our commits. These are their meanings:

🛑 breaking 🐛 bugfix 🧹 cleanup/internals ⚡ speed 📄 docs
✨⭐🌟🌠 smaller or larger features 🐎 race condition
🌙 MQL 🌈 visual 🟢 fix tests 🎫 auth 🦅 falcon 🐳 container

🌙 MQL 🌈 visual 🟢 fix tests 🎫 auth 🦅 falcon 🐳 container
4 changes: 2 additions & 2 deletions providers-sdk/v1/inventory/inventory.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers-sdk/v1/inventory/inventory.proto
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ message OwnerReference {
string uid = 4;
}

// Invetory declares the all assets and their credentials
// Inventory declares the all assets and their credentials
message Inventory {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
Expand Down

0 comments on commit d87a128

Please sign in to comment.