Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Add namespace permission grants #1

Closed
wants to merge 1 commit into from

Conversation

ypt
Copy link

@ypt ypt commented Dec 18, 2020

Update: here's the PR for the Streamnative repo: streamnative#23. I'll close this PR once the Streamnative one is merged.


Usage follows the description here: streamnative#8

resource "pulsar_namespace" "test" {
  ...
  permission_grant {
    role = "my-consumer"
    actions = ["consume"]
  }
}

Integrated Testing

Run Pulsar

docker run --rm -it \
  -p 6650:6650 \
  -p 8080:8080 \
  --name pulsar \
  apachepulsar/pulsar:2.7.0 \
  bin/pulsar standalone

Execute tests

make testacc

Manual Testing

Run Pulsar

docker run --rm -it \
  -p 6650:6650 \
  -p 8080:8080 \
  --name pulsar \
  apachepulsar/pulsar:2.7.0 \
  bin/pulsar standalone

build and install the provider

make build && mv terraform-provider-pulsar ~/.terraform.d/plugins/terraform-provider-pulsar

# or if you don't want to overwrite an existing provider
make build && mv terraform-provider-pulsar ~/.terraform.d/plugins/terraform-provider-pulsar2

Set up a test main.tf somewhere that looks like the following

provider "pulsar" { # or "pulsar2" if you renamed the provider
  web_service_url = "http://127.0.0.1:8080"
}

resource "pulsar_namespace" "test" {
  # Uncomment if you renamed the provider
  # provider = "pulsar2"

  tenant    = "public"
  namespace = "my-namespace-1"

  permission_grant {
    role = "my-role-1"
    actions = ["consume"]
  }

  permission_grant {
    role = "my-role-2"
    actions = ["consume", "produce"]
  }
}

Init Terraform and apply changes

terraform init
terraform plan
terraform apply

Get namespace permissions and see if they're what's expected

docker exec -it pulsar /pulsar/bin/pulsar-admin namespaces permissions public/my-namespace-1

Try adding, editing, removing permission grants in main.tf and reapply the Terraform and validate the results are as expected

Copy link

@rwstauner rwstauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few go nits but looks reasonable. i'm not very familiar with this repo so i'll look it over a little more and compare it to the rest of the codebase.

pulsar/resource_pulsar_namespace.go Outdated Show resolved Hide resolved
pulsar/resource_pulsar_namespace.go Outdated Show resolved Hide resolved
pulsar/resource_pulsar_namespace.go Outdated Show resolved Hide resolved
@ypt ypt force-pushed the add-namespace-permission-grants branch from 824f3a6 to 7969554 Compare December 21, 2020 16:35
@ypt ypt force-pushed the add-namespace-permission-grants branch from ef6348c to d59ee09 Compare December 21, 2020 17:33
Usage follows the description here: streamnative#8

```
resource "pulsar_namespace" "test" {
  ...
  permission_grant {
    role = "my-consumer"
    actions = ["consume"]
  }
}
```
@ypt ypt force-pushed the add-namespace-permission-grants branch from a9a996a to 2d14930 Compare December 22, 2020 16:06
@ypt
Copy link
Author

ypt commented Jan 6, 2021

Streamnative has approved and merged the analogous PR into their repo (streamnative#23) - so we can close this one now.

@ypt ypt closed this Jan 6, 2021
@ypt ypt deleted the add-namespace-permission-grants branch January 6, 2021 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants