Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Provider Release #2

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions docs/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: CrateDB
meta_desc: Provides an overview of the CrateDB Provider for Pulumi.
layout: package
---

The CrateDB provider for Pulumi can be used to provision the resources available in [CrateDB](https://www.cratedb.com/).

The CrateDB provider must be configured with credentials to deploy and update resources in CrateDB; see [Installation & Configuration](./installation-configuration) for instructions.

## Example

{{< chooser language "typescript,python,go" >}}
{{% choosable language typescript %}}

```typescript
import * as pulumi from "@pulumi/pulumi";
import * as cratedb from "@komminarlabs/cratedb";

// Create a new Bucket
export const database = new cratedb.Database("signals", {
name: "signals",
retentionPeriod: 604800,
});

// Get the id of the new bucket as an output
export const databaseId = database.id;
```

{{% /choosable %}}
{{% choosable language python %}}

```python
import komminarlabs_cratedb as cratedb

database = cratedb.Database(
"signals",
name="signals",
retention_period=604800,
)
```

{{% /choosable %}}
{{% choosable language go %}}

```go
package main

import (
"github.com/komminarlabs/pulumi-cratedb/sdk/go/cratedb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
signals, err := cratedb.NewDatabase(ctx, "signals", &cratedb.DatabaseArgs{
Name: pulumi.String("signals"),
RetentionPeriod: pulumi.Int(604800),
})
if err != nil {
return err
}

ctx.Export("databaseId", signals.ID())
return nil
})
}
```

{{% /choosable %}}

{{< /chooser >}}
33 changes: 33 additions & 0 deletions docs/installation-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: CrateDB Installation & Configuration
meta_desc: Information on how to install the CrateDB provider.
layout: package
---

## Installation

The Pulumi CrateDB provider is available as a package in all Pulumi languages:

* JavaScript/TypeScript: [`@komminarlabs/cratedb`](https://www.npmjs.com/package/@komminarlabs/cratedb)
* Python: [`komminarlabs_cratedb`](https://pypi.org/project/komminarlabs_cratedb/)
* Go: [`github.com/komminarlabs/pulumi-cratedb/sdk/go/cratedb`](https://pkg.go.dev/github.com/komminarlabs/pulumi-cratedb/sdk/go/cratedb)
* .NET: [`KomminarLabs.CrateDB`](https://www.nuget.org/packages/KomminarLabs.CrateDB)


## Configuration

The following configuration points are available for the `cratedb` provider:

- `cratedb:api_key` (environment: `CRATEDB_API_KEY`) - The API key
- `cratedb:api_secret` (environment: `CRATEDB_API_SECRET`) - The API secret
- `cratedb:url` (environment: `CRATEDB_URL`) - The CrateDB Cloud URL

### Provider Binary

The CrateDB provider binary is a third party binary. It can be installed using the `pulumi plugin` command.

```bash
pulumi plugin install resource cratedb <version> --server github://api.github.com/komminarlabs
```

Replace the version string `<version>` with your desired version.
1 change: 1 addition & 0 deletions provider/cmd/pulumi-resource-cratedb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schema.go
Empty file.
45 changes: 45 additions & 0 deletions provider/cmd/pulumi-resource-cratedb/bridge-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"auto-aliasing": {
"resources": {
"cratedb_cluster": {
"current": "cratedb:index/cluster:Cluster",
"fields": {
"ip_whitelist": {
"maxItemsOne": false
}
}
},
"cratedb_organization": {
"current": "cratedb:index/organization:Organization"
},
"cratedb_project": {
"current": "cratedb:index/project:Project"
}
},
"datasources": {
"cratedb_cluster": {
"current": "cratedb:index/getCluster:getCluster",
"fields": {
"ip_whitelist": {
"maxItemsOne": false
}
}
},
"cratedb_organization": {
"current": "cratedb:index/getOrganization:getOrganization"
},
"cratedb_organizations": {
"current": "cratedb:index/getOrganizations:getOrganizations",
"fields": {
"organizations": {
"maxItemsOne": false
}
}
},
"cratedb_project": {
"current": "cratedb:index/getProject:getProject"
}
}
},
"auto-settings": {}
}
49 changes: 49 additions & 0 deletions provider/cmd/pulumi-resource-cratedb/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//go:build ignore

package main

import (
"encoding/json"
"errors"
"io/fs"
"io/ioutil"
"log"
"os"

"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
)

func main() {
version, found := os.LookupEnv("VERSION")
if !found {
log.Fatal("version not found")
}

schemaContents, err := ioutil.ReadFile("./schema.json")
if err != nil {
log.Fatal(err)
}

var packageSpec schema.PackageSpec
err = json.Unmarshal(schemaContents, &packageSpec)
if err != nil {
log.Fatalf("cannot deserialize schema: %v", err)
}

packageSpec.Version = version
versionedContents, err := json.Marshal(packageSpec)
if err != nil {
log.Fatalf("cannot reserialize schema: %v", err)
}

// Clean up schema.go as it may be present & gitignored and tolerate an error if the file isn't present.
err = os.Remove("./schema.go")
if err != nil && !errors.Is(err, fs.ErrNotExist) {
log.Fatal(err)
}

err = ioutil.WriteFile("./schema-embed.json", versionedContents, 0600)
if err != nil {
log.Fatal(err)
}
}
24 changes: 24 additions & 0 deletions provider/cmd/pulumi-resource-cratedb/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:generate go run ./generate.go

package main

import (
"context"

_ "embed"

"github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"

cratedb "github.com/komminarlabs/pulumi-cratedb/provider"
)

//go:embed schema-embed.json
var pulumiSchema []byte

//go:embed bridge-metadata.json
var bridgeMetadata []byte

func main() {
meta := tfbridge.ProviderMetadata{PackageSchema: pulumiSchema, BridgeMetadata: bridgeMetadata}
tfbridge.Main(context.Background(), "cratedb", cratedb.Provider(), meta)
}
1 change: 1 addition & 0 deletions provider/cmd/pulumi-resource-cratedb/schema-embed.json

Large diffs are not rendered by default.

Loading