Skip to content

Commit

Permalink
working go example
Browse files Browse the repository at this point in the history
  • Loading branch information
twingate-blee committed Sep 5, 2024
1 parent 02e6009 commit e3c956c
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 314 deletions.
10 changes: 5 additions & 5 deletions examples/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module twingate_go_example

go 1.22.0

require (
github.com/Twingate/pulumi-twingate/sdk/v3 v3.0.0-20240901083905-0004a52a6be4
github.com/pulumi/pulumi/sdk/v3 v3.130.0
)
//github.com/Twingate/pulumi-twingate/sdk/v3 v3.0.0-20240901083905-0004a52a6be4
require github.com/pulumi/pulumi/sdk/v3 v3.130.0

// uncomment the following line to use the local version of the sdk
// replace github.com/Twingate/pulumi-twingate/sdk/v3 => ../../sdk
replace github.com/Twingate/pulumi-twingate/sdk/v3/go/twingate => ../../sdk/go/twingate

require github.com/Twingate/pulumi-twingate/sdk/v3/go/twingate v0.0.0-00010101000000-000000000000

require (
dario.cat/mergo v1.0.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions examples/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/Twingate/pulumi-twingate/sdk/v3 v3.0.0-20240901083905-0004a52a6be4 h1:HaCn7saM16LtdPWjfxj9HwMUnuuOlyMcFsTecvkYxo0=
github.com/Twingate/pulumi-twingate/sdk/v3 v3.0.0-20240901083905-0004a52a6be4/go.mod h1:Mwz4/ZELlZfwMT4L937MNcKHdXVdKzSvhWN/r4KBUZQ=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
Expand Down
78 changes: 37 additions & 41 deletions examples/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,48 +87,44 @@ func main() {

ctx.Export("resource_id", resource.ID())

// This is commented out because it throws an error. The issue is upstream in the pulumi provider.
// twingate:index:TwingateDNSFilteringProfile (dns_profile):
// error: [pf/tfbridge] unknown resource token: twingate:index/twingateDNSFilteringProfile:TwingateDNSFilteringProfile

// Create a Twingate DNS Filtering Profile
// _, err = twingate.NewTwingateDNSFilteringProfile(ctx, "dns_profile", &twingate.TwingateDNSFilteringProfileArgs{
// Name: pulumi.String("Go Pulumi DNS Filtering Profile"),
// Priority: pulumi.Float64(2),
// FallbackMethod: pulumi.String("AUTO"),
// Groups: pulumi.StringArray{group.ID()},

// AllowedDomains: &twingate.TwingateDNSFilteringProfileAllowedDomainsArgs{
// IsAuthoritative: pulumi.Bool(false),
// Domains: pulumi.StringArray{
// pulumi.String("twingate.com"),
// pulumi.String("zoom.us"),
// },
// },

// DeniedDomains: &twingate.TwingateDNSFilteringProfileDeniedDomainsArgs{
// IsAuthoritative: pulumi.Bool(true),
// Domains: pulumi.StringArray{
// pulumi.String("evil.example"),
// },
// },

// ContentCategories: &twingate.TwingateDNSFilteringProfileContentCategoriesArgs{
// BlockAdultContent: pulumi.Bool(true),
// },

// SecurityCategories: &twingate.TwingateDNSFilteringProfileSecurityCategoriesArgs{
// BlockDnsRebinding: pulumi.Bool(false),
// BlockNewlyRegisteredDomains: pulumi.Bool(false),
// },

// PrivacyCategories: &twingate.TwingateDNSFilteringProfilePrivacyCategoriesArgs{
// BlockDisguisedTrackers: pulumi.Bool(true),
// },
// })
// if err != nil {
// return err
// }
_, err = twingate.NewTwingateDNSFilteringProfile(ctx, "dns_profile", &twingate.TwingateDNSFilteringProfileArgs{
Name: pulumi.String("Go Pulumi DNS Filtering Profile"),
Priority: pulumi.Float64(2),
FallbackMethod: pulumi.String("AUTO"),
Groups: pulumi.StringArray{group.ID()},

AllowedDomains: &twingate.TwingateDNSFilteringProfileAllowedDomainsArgs{
IsAuthoritative: pulumi.Bool(false),
Domains: pulumi.StringArray{
pulumi.String("twingate.com"),
pulumi.String("zoom.us"),
},
},

DeniedDomains: &twingate.TwingateDNSFilteringProfileDeniedDomainsArgs{
IsAuthoritative: pulumi.Bool(true),
Domains: pulumi.StringArray{
pulumi.String("evil.example"),
},
},

ContentCategories: &twingate.TwingateDNSFilteringProfileContentCategoriesArgs{
BlockAdultContent: pulumi.Bool(true),
},

SecurityCategories: &twingate.TwingateDNSFilteringProfileSecurityCategoriesArgs{
BlockDnsRebinding: pulumi.Bool(false),
BlockNewlyRegisteredDomains: pulumi.Bool(false),
},

PrivacyCategories: &twingate.TwingateDNSFilteringProfilePrivacyCategoriesArgs{
BlockDisguisedTrackers: pulumi.Bool(true),
},
})
if err != nil {
return err
}

return nil
})
Expand Down
264 changes: 1 addition & 263 deletions provider/cmd/pulumi-resource-twingate/bridge-metadata.json
Original file line number Diff line number Diff line change
@@ -1,263 +1 @@
{
"auto-aliasing": {
"resources": {
"twingate_connector": {
"current": "twingate:index/twingateConnector:TwingateConnector",
"majorVersion": 3
},
"twingate_connector_tokens": {
"current": "twingate:index/twingateConnectorTokens:TwingateConnectorTokens",
"majorVersion": 3
},
"twingate_dns_filtering_profile": {
"current": "twingate:index/twingateDNSFilteringProfile:TwingateDNSFilteringProfile",
"majorVersion": 3,
"fields": {
"allowed_domains": {
"fields": {
"domains": {
"maxItemsOne": false
}
}
},
"denied_domains": {
"fields": {
"domains": {
"maxItemsOne": false
}
}
},
"groups": {
"maxItemsOne": false
}
}
},
"twingate_group": {
"current": "twingate:index/twingateGroup:TwingateGroup",
"majorVersion": 3,
"fields": {
"user_ids": {
"maxItemsOne": false
}
}
},
"twingate_remote_network": {
"current": "twingate:index/twingateRemoteNetwork:TwingateRemoteNetwork",
"majorVersion": 3
},
"twingate_resource": {
"current": "twingate:index/twingateResource:TwingateResource",
"majorVersion": 3,
"fields": {
"access_group": {
"maxItemsOne": false
},
"access_service": {
"maxItemsOne": false
},
"protocols": {
"fields": {
"tcp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
},
"udp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
}
}
}
}
},
"twingate_service_account": {
"current": "twingate:index/twingateServiceAccount:TwingateServiceAccount",
"majorVersion": 3
},
"twingate_service_account_key": {
"current": "twingate:index/twingateServiceAccountKey:TwingateServiceAccountKey",
"majorVersion": 3
},
"twingate_user": {
"current": "twingate:index/twingateUser:TwingateUser",
"majorVersion": 3
}
},
"datasources": {
"twingate_connector": {
"current": "twingate:index/getTwingateConnector:getTwingateConnector",
"majorVersion": 3
},
"twingate_connectors": {
"current": "twingate:index/getTwingateConnectors:getTwingateConnectors",
"majorVersion": 3,
"fields": {
"connectors": {
"maxItemsOne": false
}
}
},
"twingate_dns_filtering_profile": {
"current": "twingate:index/getTwingateDNSFilteringProfile:getTwingateDNSFilteringProfile",
"majorVersion": 3,
"fields": {
"allowed_domains": {
"fields": {
"domains": {
"maxItemsOne": false
}
}
},
"denied_domains": {
"fields": {
"domains": {
"maxItemsOne": false
}
}
},
"groups": {
"maxItemsOne": false
}
}
},
"twingate_group": {
"current": "twingate:index/getTwingateGroup:getTwingateGroup",
"majorVersion": 3
},
"twingate_groups": {
"current": "twingate:index/getTwingateGroups:getTwingateGroups",
"majorVersion": 3,
"fields": {
"groups": {
"maxItemsOne": false
},
"types": {
"maxItemsOne": false
}
}
},
"twingate_remote_network": {
"current": "twingate:index/getTwingateRemoteNetwork:getTwingateRemoteNetwork",
"majorVersion": 3
},
"twingate_remote_networks": {
"current": "twingate:index/getTwingateRemoteNetworks:getTwingateRemoteNetworks",
"majorVersion": 3,
"fields": {
"remote_networks": {
"maxItemsOne": false
}
}
},
"twingate_resource": {
"current": "twingate:index/getTwingateResource:getTwingateResource",
"majorVersion": 3,
"fields": {
"protocols": {
"fields": {
"tcp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
},
"udp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
}
}
}
}
},
"twingate_resources": {
"current": "twingate:index/getTwingateResources:getTwingateResources",
"majorVersion": 3,
"fields": {
"resources": {
"maxItemsOne": false,
"elem": {
"fields": {
"protocols": {
"fields": {
"tcp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
},
"udp": {
"fields": {
"ports": {
"maxItemsOne": false
}
}
}
}
}
}
}
}
}
},
"twingate_security_policies": {
"current": "twingate:index/getTwingateSecurityPolicies:getTwingateSecurityPolicies",
"majorVersion": 3,
"fields": {
"security_policies": {
"maxItemsOne": false
}
}
},
"twingate_security_policy": {
"current": "twingate:index/getTwingateSecurityPolicy:getTwingateSecurityPolicy",
"majorVersion": 3
},
"twingate_service_accounts": {
"current": "twingate:index/getTwingateServiceAccounts:getTwingateServiceAccounts",
"majorVersion": 3,
"fields": {
"service_accounts": {
"maxItemsOne": false,
"elem": {
"fields": {
"key_ids": {
"maxItemsOne": false
},
"resource_ids": {
"maxItemsOne": false
}
}
}
}
}
},
"twingate_user": {
"current": "twingate:index/getTwingateUser:getTwingateUser",
"majorVersion": 3
},
"twingate_users": {
"current": "twingate:index/getTwingateUsers:getTwingateUsers",
"majorVersion": 3,
"fields": {
"roles": {
"maxItemsOne": false
},
"users": {
"maxItemsOne": false
}
}
}
}
},
"auto-settings": {}
}
{}
Loading

0 comments on commit e3c956c

Please sign in to comment.