Skip to content

Commit

Permalink
feat(provider/google): Finish support for source tags on security gro…
Browse files Browse the repository at this point in the history
…ups (firewall rules). (#1478)
  • Loading branch information
Matt Duftler authored and danielpeach committed Mar 1, 2017
1 parent d9407ee commit 6b80527
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Expand Up @@ -72,6 +72,10 @@ class UpsertGoogleSecurityGroupAtomicOperation extends GoogleAtomicOperation<Voi

task.updateStatus BASE_PHASE, "Updating existing firewall rule $firewallRuleName..."

if (description.sourceTags == null) {
firewall.sourceTags = origFirewall.sourceTags
}

if (description.targetTags == null) {
firewall.targetTags = origFirewall.targetTags
}
Expand Down
Expand Up @@ -35,12 +35,14 @@ class GoogleSecurityGroup implements SecurityGroup {
final String accountName
final String region
final String network
// Don't see an elegant way to encapsulate source tags in an inbound rule.
final List<String> sourceTags
final List<String> targetTags
final Set<Rule> inboundRules
final Set<Rule> outboundRules

@Override
SecurityGroupSummary getSummary() {
new GoogleSecurityGroupSummary(name: name, id: id, network: network, targetTags: targetTags)
new GoogleSecurityGroupSummary(name: name, id: id, network: network, sourceTags: sourceTags, targetTags: targetTags)
}
}
Expand Up @@ -16,15 +16,18 @@

package com.netflix.spinnaker.clouddriver.google.model

import com.fasterxml.jackson.annotation.JsonInclude
import com.netflix.spinnaker.clouddriver.model.SecurityGroupSummary
import groovy.transform.EqualsAndHashCode
import groovy.transform.Immutable

@Immutable
@EqualsAndHashCode(includes = ['id', 'network'], cache = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
class GoogleSecurityGroupSummary implements SecurityGroupSummary {
String name
String id
String network
String sourceTags
String targetTags
}
Expand Up @@ -113,6 +113,7 @@ class GoogleSecurityGroupProvider implements SecurityGroupProvider<GoogleSecurit
accountName: account,
region: region,
network: getLocalName(firewall.network),
sourceTags: firewall.sourceTags,
targetTags: firewall.targetTags,
inboundRules: inboundRules
)
Expand Down Expand Up @@ -170,13 +171,12 @@ class GoogleSecurityGroupProvider implements SecurityGroupProvider<GoogleSecurit
rangeRules.add(new IpRangeRule(range: sourceRange, portRanges: portRanges, protocol: ipProtocol))
}
} else {
// TODO(duftler): Add support for sourceTags.
rangeRules.add(new IpRangeRule(
range: new AddressableRange(ip: "", cidr: ""), portRanges: portRanges, protocol: ipProtocol))
}
}

rangeRules.sort()
return rangeRules.sort()
}

private String getLocalName(String fullUrl) {
Expand Down

0 comments on commit 6b80527

Please sign in to comment.