Skip to content

Commit

Permalink
Add support for managing VPC peering.
Browse files Browse the repository at this point in the history
Add support for managing VPC peering via the `cb network` command.

These changes provide the following subcommands:

* `cb network create-peering` - create a new VPC peering in the target
  network.
* `cb network delete-peering` - delete an existing VPC peering.
* `cb network get-peering` - show details of an existing VPC peering.
* `cb network list-peerings` - list all existing VPC peerings for the
  target network.
  • Loading branch information
abrightwell committed May 31, 2024
1 parent 763836f commit 55815b5
Show file tree
Hide file tree
Showing 9 changed files with 905 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `cb network` now manages firewall rules and supports the following
subcommands: `add-firewall-rule`, `list-firewall-rules`,
`remove-firewall-rule` and `update-firewall-rule`
`remove-firewall-rule` and `update-firewall-rule`.
- `cb network` now manages VPC peerings and supports the following subcommands:
`create-peering`, `delete-peering`, `get-peering` and `list-peerings`.

### Deprecated
- `cb firewall` deprecated in favor of `cb network`.
Expand Down
71 changes: 62 additions & 9 deletions spec/cb/completion_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ private class CompletionTestClient < CB::Client
[Factory.cluster]
end

def get_teams
[Factory.team(name: "my team", role: "manager")]
def get_firewall_rules(id)
[Factory.firewall_rule(id: "f1", rule: "1.2.3.4/32"), Factory.firewall_rule(id: "f2", rule: "4.5.6.7/24")]
end

def get_log_destinations(id)
[
Factory.log_destination(id: "logid", host: "host", port: 2020,
template: "template", description: "logdest descr"),
]
end

def get_networks(team)
[Factory.network]
end

def get_firewall_rules(id)
[Factory.firewall_rule(id: "f1", rule: "1.2.3.4/32"), Factory.firewall_rule(id: "f2", rule: "4.5.6.7/24")]
def list_peerings(network)
[Factory.peering]
end

def get_providers
Expand All @@ -40,11 +47,8 @@ private class CompletionTestClient < CB::Client
]
end

def get_log_destinations(id)
[
Factory.log_destination(id: "logid", host: "host", port: 2020,
template: "template", description: "logdest descr"),
]
def get_teams
[Factory.team(name: "my team", role: "manager")]
end
end

Expand Down Expand Up @@ -704,6 +708,55 @@ Spectator.describe CB::Completion do
expect(result).to have_option "--firewall-rule"
expect(result).to have_option "--rule"

# Network Peering Managments
result = parse("cb network create-peering ")
expect(result).to have_option "--format"
expect(result).to have_option "--network"
expect(result).to have_option "--platform"

result = parse("cb network create-peering --platform ")
expect(result).to eq ["aws", "gcp"]

result = parse("cb network create-peering --network abc --platform aws ")
expect(result).to have_option "--aws-account-id"
expect(result).to have_option "--aws-vpc-id"

result = parse("cb network create-peering --network abc --platform gcp ")
expect(result).to have_option "--gcp-project-id"
expect(result).to have_option "--gcp-vpc-name"

result = parse("cb network delete-peering ")
expect(result).to have_option "--format"
expect(result).to have_option "--network"
expect(result).to have_option "--peering"

result = parse("cb network delete-peering --network abc ")
expect(result).to have_option "--peering"

result = parse("cb network delete-peering --network abc --peering ")
expect(result).to eq ["yydi4alkebgsfldibaoo4kliii\tExample Peering"]

result = parse("cb network delete-peering --network abc --peering abc --format json ")
expect(result).to eq [] of String

result = parse("cb network get-peering ")
expect(result).to have_option "--format"
expect(result).to have_option "--network"
expect(result).to have_option "--peering"

result = parse("cb network get-peering --network abc ")
expect(result).to have_option "--peering"

result = parse("cb network get-peering --network abc --peering abc --format json ")
expect(result).to eq [] of String

result = parse("cb network list-peerings ")
expect(result).to have_option "--format"
expect(result).to have_option "--network"

result = parse("cb network list-peerings --network abc --format json ")
expect(result).to eq [] of String

# Network Management
result = parse("cb network info ")
expect(result).to have_option "--network"
Expand Down
Loading

0 comments on commit 55815b5

Please sign in to comment.