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

Add support for managing VPC peering. #169

Merged
merged 1 commit into from
May 31, 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
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