Skip to content

Commit ae57fe6

Browse files
tas50claude
andcommitted
✨ Convert firewall network field to typed resource reference
network string → network() gcp.project.computeService.network Enables MQL traversal like firewall.network.name instead of raw URL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3a80d55 commit ae57fe6

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

providers/gcp/resources/compute.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,18 @@ func (g *mqlGcpProjectComputeService) disks() ([]any, error) {
975975
return res, result
976976
}
977977

978+
type mqlGcpProjectComputeServiceFirewallInternal struct {
979+
cacheNetworkUrl string
980+
}
981+
982+
func (g *mqlGcpProjectComputeServiceFirewall) network() (*mqlGcpProjectComputeServiceNetwork, error) {
983+
if g.cacheNetworkUrl == "" {
984+
g.Network.State = plugin.StateIsNull | plugin.StateIsSet
985+
return nil, nil
986+
}
987+
return getNetworkByUrl(g.cacheNetworkUrl, g.MqlRuntime)
988+
}
989+
978990
func (g *mqlGcpProjectComputeServiceFirewall) id() (string, error) {
979991
if g.Id.Error != nil {
980992
return "", g.Id.Error
@@ -1098,13 +1110,13 @@ func (g *mqlGcpProjectComputeService) firewalls() ([]any, error) {
10981110
"denied": llx.ArrayData(deniedDict, types.Dict),
10991111
"targetTags": llx.ArrayData(convert.SliceAnyToInterface(firewall.TargetTags), types.String),
11001112
"loggingEnabled": llx.BoolData(firewall.LogConfig != nil && firewall.LogConfig.Enable),
1101-
"network": llx.StringData(firewall.Network),
11021113
})
11031114
if err != nil {
11041115
return err
1105-
} else {
1106-
res = append(res, mqlFirewall)
11071116
}
1117+
mqlFw := mqlFirewall.(*mqlGcpProjectComputeServiceFirewall)
1118+
mqlFw.cacheNetworkUrl = firewall.Network
1119+
res = append(res, mqlFirewall)
11081120
}
11091121
return nil
11101122
}); err != nil {

providers/gcp/resources/gcp.lr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,8 @@ private gcp.project.computeService.firewall @defaults("name") {
11121112
targetTags []string
11131113
// Whether firewall logging is enabled for this rule
11141114
loggingEnabled bool
1115-
// URL of the network resource for this firewall rule
1116-
network string
1115+
// Network resource for this firewall rule
1116+
network() gcp.project.computeService.network
11171117
}
11181118

11191119
// Google Cloud (GCP) Compute VPC network resource

providers/gcp/resources/gcp.lr.go

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)