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

fix(google): introduce explicit constructor and initialization of inner class members (backport #6184) #6185

Merged
merged 1 commit into from
Apr 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,26 @@ class GoogleApplication {
String name

View getView() {
new View()
new View(this)
}

@Canonical
class View implements Application {
String name = GoogleApplication.this.name
Map<String, String> attributes = [:]
String name
Map<String, String> attributes

/**
* Account name -> cluster names
*/
Map<String, Set<String>> clusterNames = [:].withDefault {[] as Set}
Map<String, Set<String>> clusterNames

List<Map<String, String>> instances

View(GoogleApplication googleApplication){
name = googleApplication.name
attributes = [:]
clusterNames = [:].withDefault {[] as Set}
instances = [[:] as Map<String,String>]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,26 @@ class GoogleCluster {

@JsonIgnore
View getView() {
new View()
new View(this)
}

@Canonical
class View implements Cluster {

View() {}
View(GoogleCluster googleCluster) {
name = googleCluster.name
accountName = googleCluster.accountName

serverGroups = [] as Set
loadBalancers = [] as Set
}

final String type = GoogleCloudProvider.ID

String name = GoogleCluster.this.name
String accountName = GoogleCluster.this.accountName
String name
String accountName

Set<GoogleServerGroup.View> serverGroups = [] as Set
Set<GoogleLoadBalancerView> loadBalancers = [] as Set
Set<GoogleServerGroup.View> serverGroups
Set<GoogleLoadBalancerView> loadBalancers
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GoogleHealthCheck {

@JsonIgnore
View getView() {
new View()
new View(this)
}

/**
Expand Down Expand Up @@ -98,18 +98,34 @@ class GoogleHealthCheck {

@Canonical
class View implements Serializable {
String name = GoogleHealthCheck.this.name
HealthCheckType healthCheckType = GoogleHealthCheck.this.healthCheckType
int interval = GoogleHealthCheck.this.checkIntervalSec
int timeout = GoogleHealthCheck.this.timeoutSec
int unhealthyThreshold = GoogleHealthCheck.this.unhealthyThreshold
int healthyThreshold = GoogleHealthCheck.this.healthyThreshold
int port = GoogleHealthCheck.this.port
String requestPath = GoogleHealthCheck.this.requestPath
String selfLink = GoogleHealthCheck.this.selfLink
String kind = GoogleHealthCheck.this.kind
String target = GoogleHealthCheck.this.target
String region = GoogleHealthCheck.this.region
String name
HealthCheckType healthCheckType
int interval
int timeout
int unhealthyThreshold
int healthyThreshold
int port
String requestPath
String selfLink
String kind
String target
String region

View(GoogleHealthCheck googleHealthCheck){
name = googleHealthCheck.name
healthCheckType = googleHealthCheck.healthCheckType
interval = googleHealthCheck.checkIntervalSec
timeout = googleHealthCheck.timeoutSec
unhealthyThreshold = googleHealthCheck.unhealthyThreshold
healthyThreshold = googleHealthCheck.healthyThreshold
port = googleHealthCheck.port
requestPath = googleHealthCheck.requestPath
selfLink = googleHealthCheck.selfLink
kind = googleHealthCheck.kind
target = googleHealthCheck.target
region = googleHealthCheck.region
}

}

static enum HealthCheckType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GoogleInstance implements GoogleLabeledResource {

@JsonIgnore
View getView() {
new View()
new View(this)
}

@Canonical
Expand All @@ -80,27 +80,50 @@ class GoogleInstance implements GoogleLabeledResource {
final String providerType = GoogleCloudProvider.ID
final String cloudProvider = GoogleCloudProvider.ID

String name = GoogleInstance.this.name
String gceId = GoogleInstance.this.gceId
String instanceId = GoogleInstance.this.name
String instanceType = GoogleInstance.this.instanceType
String cpuPlatform = GoogleInstance.this.cpuPlatform
Long launchTime = GoogleInstance.this.launchTime
String zone = GoogleInstance.this.zone
String region = GoogleInstance.this.region
Map placement = ["availabilityZone": GoogleInstance.this.zone]
List<NetworkInterface> networkInterfaces = GoogleInstance.this.networkInterfaces
Metadata metadata = GoogleInstance.this.metadata
List<? extends GenericJson> disks = GoogleInstance.this.disks
List<ServiceAccount> serviceAccounts = GoogleInstance.this.serviceAccounts
String selfLink = GoogleInstance.this.selfLink
String serverGroup = GoogleInstance.this.serverGroup
Tags tags = GoogleInstance.this.tags
Map<String, String> labels = GoogleInstance.this.labels
ConsulNode consulNode = GoogleInstance.this.consulNode
String name
String gceId
String instanceId
String instanceType
String cpuPlatform
Long launchTime
String zone
String region
Map placement
List<NetworkInterface> networkInterfaces
Metadata metadata
List<? extends GenericJson> disks
List<ServiceAccount> serviceAccounts
String selfLink
String serverGroup
Tags tags
Map<String, String> labels
ConsulNode consulNode
List<String> securityGroups

View(GoogleInstance googleInstance){
name = googleInstance.name
gceId = googleInstance.gceId
instanceId = googleInstance.name
instanceType = googleInstance.instanceType
cpuPlatform = googleInstance.cpuPlatform
launchTime = googleInstance.launchTime
zone = googleInstance.zone
region = googleInstance.region
placement = ["availabilityZone": googleInstance.zone]
networkInterfaces = googleInstance.networkInterfaces
metadata = googleInstance.metadata
disks = googleInstance.disks
serviceAccounts = googleInstance.serviceAccounts
selfLink = googleInstance.selfLink
serverGroup = googleInstance.serverGroup
tags = googleInstance.tags
labels = googleInstance.labels
consulNode = googleInstance.consulNode
securityGroups = googleInstance.securityGroups
}

List<Map<String, String>> getSecurityGroups() {
GoogleInstance.this.securityGroups.collect {
securityGroups.collect {
["groupName": it, "groupId": it]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class GoogleServerGroup implements GoogleLabeledResource {

@JsonIgnore
View getView() {
new View()
new View(this)
}

@Override
Expand All @@ -103,35 +103,67 @@ class GoogleServerGroup implements GoogleLabeledResource {
final String type = GoogleCloudProvider.ID
final String cloudProvider = GoogleCloudProvider.ID

String name = GoogleServerGroup.this.name
String region = GoogleServerGroup.this.region
Boolean regional = GoogleServerGroup.this.regional
String zone = GoogleServerGroup.this.zone
Set<String> zones = GoogleServerGroup.this.zones
Set<GoogleInstance.View> instances = GoogleServerGroup.this.instances.collect { it?.view }
Map<String, Object> asg = GoogleServerGroup.this.asg
Map<String, Object> launchConfig = GoogleServerGroup.this.launchConfig
Map<String, Integer> namedPorts = GoogleServerGroup.this.namedPorts
Set<String> securityGroups = GoogleServerGroup.this.securityGroups
Map buildInfo = GoogleServerGroup.this.buildInfo
Boolean disabled = GoogleServerGroup.this.disabled
String networkName = GoogleServerGroup.this.networkName
Boolean canIpForward = GoogleServerGroup.this.canIpForward
Boolean enableSecureBoot = GoogleServerGroup.this.enableSecureBoot
Boolean enableVtpm = GoogleServerGroup.this.enableVtpm
Boolean enableIntegrityMonitoring = GoogleServerGroup.this.enableIntegrityMonitoring
Set<String> instanceTemplateTags = GoogleServerGroup.this.instanceTemplateTags
Set<ServiceAccount> instanceTemplateServiceAccounts = GoogleServerGroup.this.instanceTemplateServiceAccounts
Map<String, String> instanceTemplateLabels = GoogleServerGroup.this.instanceTemplateLabels
String selfLink = GoogleServerGroup.this.selfLink
Boolean discovery = GoogleServerGroup.this.discovery
InstanceGroupManagerActionsSummary currentActions = GoogleServerGroup.this.currentActions
GoogleAutoscalingPolicy autoscalingPolicy = GoogleServerGroup.this.autoscalingPolicy
StatefulPolicy statefulPolicy = GoogleServerGroup.this.statefulPolicy
List<String> autoscalingMessages = GoogleServerGroup.this.autoscalingMessages
InstanceGroupManagerAutoHealingPolicy autoHealingPolicy = GoogleServerGroup.this.autoHealingPolicy
GoogleDistributionPolicy distributionPolicy = GoogleServerGroup.this.distributionPolicy
Boolean selectZones = GoogleServerGroup.this.selectZones
String name
String region
Boolean regional
String zone
Set<String> zones
Set<GoogleInstance.View> instances
Map<String, Object> asg
Map<String, Object> launchConfig
Map<String, Integer> namedPorts
Set<String> securityGroups
Map buildInfo
Boolean disabled
String networkName
Boolean canIpForward
Boolean enableSecureBoot
Boolean enableVtpm
Boolean enableIntegrityMonitoring
Set<String> instanceTemplateTags
Set<ServiceAccount> instanceTemplateServiceAccounts
Map<String, String> instanceTemplateLabels
String selfLink
Boolean discovery
InstanceGroupManagerActionsSummary currentActions
GoogleAutoscalingPolicy autoscalingPolicy
StatefulPolicy statefulPolicy
List<String> autoscalingMessages
InstanceGroupManagerAutoHealingPolicy autoHealingPolicy
GoogleDistributionPolicy distributionPolicy
Boolean selectZones

View(GoogleServerGroup googleServerGroup){
name = googleServerGroup.name
region = googleServerGroup.region
regional = googleServerGroup.regional
zone = googleServerGroup.zone
zones = googleServerGroup.zones
instances = googleServerGroup.instances.collect { it?.view }
asg = googleServerGroup.asg
launchConfig = googleServerGroup.launchConfig
namedPorts = googleServerGroup.namedPorts
securityGroups = googleServerGroup.securityGroups
buildInfo = googleServerGroup.buildInfo
disabled = googleServerGroup.disabled
networkName = googleServerGroup.networkName
canIpForward = googleServerGroup.canIpForward
enableSecureBoot = googleServerGroup.enableSecureBoot
enableVtpm = googleServerGroup.enableVtpm
enableIntegrityMonitoring = googleServerGroup.enableIntegrityMonitoring
instanceTemplateTags = googleServerGroup.instanceTemplateTags
instanceTemplateServiceAccounts = googleServerGroup.instanceTemplateServiceAccounts
instanceTemplateLabels = googleServerGroup.instanceTemplateLabels
selfLink = googleServerGroup.selfLink
discovery = googleServerGroup.discovery
currentActions = googleServerGroup.currentActions
autoscalingPolicy = googleServerGroup.autoscalingPolicy
statefulPolicy = googleServerGroup.statefulPolicy
autoscalingMessages = googleServerGroup.autoscalingMessages
autoHealingPolicy = googleServerGroup.autoHealingPolicy
distributionPolicy = googleServerGroup.distributionPolicy
selectZones = googleServerGroup.selectZones
}

@Override
Moniker getMoniker() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ class GoogleLoadBalancerHealth {

@JsonIgnore
View getView() {
new View()
new View(this)
}

class View extends GoogleHealth implements Health {
final Type type = Type.LoadBalancer
final HealthClass healthClass = null

List<LBHealthSummary> loadBalancers = GoogleLoadBalancerHealth.this.lbHealthSummaries
List<LBHealthSummary> loadBalancers

View(GoogleLoadBalancerHealth googleLoadBalancerHealth){
loadBalancers = googleLoadBalancerHealth.lbHealthSummaries
}

HealthState getState() {
GoogleLoadBalancerHealth.this.status?.toHeathState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,45 @@ class GoogleHttpLoadBalancer extends GoogleLoadBalancer {

@JsonIgnore
GoogleLoadBalancerView getView() {
new View()
new View(this)
}

@Canonical
class View extends GoogleLoadBalancerView {
GoogleLoadBalancerType loadBalancerType = GoogleHttpLoadBalancer.this.type
GoogleLoadBalancingScheme loadBalancingScheme = GoogleHttpLoadBalancer.this.loadBalancingScheme
GoogleLoadBalancerType loadBalancerType
GoogleLoadBalancingScheme loadBalancingScheme

String name = GoogleHttpLoadBalancer.this.name
String account = GoogleHttpLoadBalancer.this.account
String region = GoogleHttpLoadBalancer.this.region
Long createdTime = GoogleHttpLoadBalancer.this.createdTime
String ipAddress = GoogleHttpLoadBalancer.this.ipAddress
String ipProtocol = GoogleHttpLoadBalancer.this.ipProtocol
String portRange = GoogleHttpLoadBalancer.this.portRange
String name
String account
String region
Long createdTime
String ipAddress
String ipProtocol
String portRange

GoogleBackendService defaultService = GoogleHttpLoadBalancer.this.defaultService
List<GoogleHostRule> hostRules = GoogleHttpLoadBalancer.this.hostRules
String certificate = GoogleHttpLoadBalancer.this.certificate
String urlMapName = GoogleHttpLoadBalancer.this.urlMapName
GoogleBackendService defaultService
List<GoogleHostRule> hostRules
String certificate
String urlMapName

Set<LoadBalancerServerGroup> serverGroups

View(GoogleHttpLoadBalancer googleHttpLoadBalancer){
loadBalancerType = googleHttpLoadBalancer.type
loadBalancingScheme = googleHttpLoadBalancer.loadBalancingScheme
name = googleHttpLoadBalancer.name
account = googleHttpLoadBalancer.account
region = googleHttpLoadBalancer.region
createdTime = googleHttpLoadBalancer.createdTime
ipAddress = googleHttpLoadBalancer.ipAddress
ipProtocol = googleHttpLoadBalancer.ipProtocol
portRange = googleHttpLoadBalancer.portRange
defaultService = googleHttpLoadBalancer.defaultService
hostRules = googleHttpLoadBalancer.hostRules
certificate = googleHttpLoadBalancer.certificate
urlMapName = googleHttpLoadBalancer.urlMapName
serverGroups = new HashSet<>()
}

Set<LoadBalancerServerGroup> serverGroups = new HashSet<>()
}
}
Loading
Loading