VSChina / magic-modules

Magic Modules: Automagically generate Google Cloud Platform support for OSS
Apache License 2.0
1 stars 4 forks source link

MM doesn't support *int32 to int32 convert when setting schema directly. #33

Closed hund030 closed 5 years ago

hund030 commented 5 years ago

generating codes: d.Set("scale_unit", int(p2SVpnGatewayProperties.VpnGatewayScaleUnit))

Error: azurerm\resource_arm_p2s_vpn_gateway.go:213:26: cannot convert p2SVpnGatewayProperties.VpnGatewayScaleUnit (type *int32) to type int make: *** [GNUmakefile:20: build] Error 2

houkms commented 5 years ago

This issue was fixed in PR #35

mybayern1974 commented 5 years ago

@hund030, could you please verify the fix and accordingly close this issue?

hund030 commented 5 years ago

@houkms , After fixed in PR #35 , the scale_unit property correctly convert to int32 but other int32 object who work well before now is converted to **int32. They are set within a flatten method, which is different from scale_unit set directly.

func flattenArmP2sVpnGatewayVpnClientConnectionHealth(input *network.VpnClientConnectionHealth) []interface{} {
    if input == nil {
        return make([]interface{}, 0)
    }

    result := make(map[string]interface{})

    result["allocated_ip_addresses"] = utils.FlattenStringSlice(input.AllocatedIPAddresses)
    if totalEgressBytesTransferred := input.TotalEgressBytesTransferred; totalEgressBytesTransferred != nil {
        result["total_egress_bytes_transferred"] = int(**totalEgressBytesTransferred)
    }
    if totalIngressBytesTransferred := input.TotalIngressBytesTransferred; totalIngressBytesTransferred != nil {
        result["total_ingress_bytes_transferred"] = int(**totalIngressBytesTransferred)
    }
    if vpnClientConnectionsCount := input.VpnClientConnectionsCount; vpnClientConnectionsCount != nil {
        result["vpn_client_connections_count"] = int(**vpnClientConnectionsCount)
    }

    return []interface{}{result}
}

Above totalIngressBytesTransferred and TotalEgressBytesTransferred are int64 and VpnClientConnectionsCount is int32

houkms commented 5 years ago

@hund030 Fixed in PR #38, please try it again.