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

Add explicit names for all C# namespaces #33

Merged
merged 2 commits into from
Dec 17, 2019
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ CHANGELOG
=========

## HEAD (Unreleased)
_(none)_
* Namespace names in .NET SDK are adjusted to PascalCase
([#33](https://github.com/pulumi/pulumi-datadog/pull/33)).

---

Expand Down
33 changes: 20 additions & 13 deletions resources.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog

import (
"strings"
"unicode"

"github.com/hashicorp/terraform/helper/schema"
Expand All @@ -14,32 +15,37 @@ const (
datadogPkg = "datadog"
// modules:
datadogMod = "index"
gcpMod = "gcp"
awsMod = "aws"
pdMod = "pagerduty"
gcpMod = "Gcp"
awsMod = "Aws"
pdMod = "PagerDuty"
)

// makeMember manufactures a type token for the package and the given module and type.
func makeMember(mod string, mem string) tokens.ModuleMember {
return tokens.ModuleMember(datadogPkg + ":" + mod + ":" + mem)
var namespaceMap = map[string]string{
datadogPkg: "Datadog",
}

// makeMember manufactures a type token for the package and the given module and type. It automatically
// uses the Datadog package and names the file by simply lower casing the resource's first character.
func makeMember(moduleTitle string, mem string) tokens.ModuleMember {
moduleName := strings.ToLower(moduleTitle)
namespaceMap[moduleName] = moduleTitle
fn := string(unicode.ToLower(rune(mem[0]))) + mem[1:]
token := moduleName + "/" + fn
return tokens.ModuleMember(datadogPkg + ":" + token + ":" + mem)
}

// makeType manufactures a type token for the package and the given module and type.
func makeType(mod string, typ string) tokens.Type {
return tokens.Type(makeMember(mod, typ))
}

// makeResource manufactures a standard resource token given a module and resource name. It
// automatically uses the main package and names the file by simply lower casing the resource's
// first character.
// makeResource manufactures a standard resource token given a module and resource name.
func makeResource(mod string, res string) tokens.Type {
fn := string(unicode.ToLower(rune(res[0]))) + res[1:]
return makeType(mod+"/"+fn, res)
return makeType(mod, res)
}

func makeDataSource(mod string, res string) tokens.ModuleMember {
fn := string(unicode.ToLower(rune(res[0]))) + res[1:]
return makeMember(mod+"/"+fn, res)
return makeMember(mod, res)
}

func Provider() tfbridge.ProviderInfo {
Expand Down Expand Up @@ -154,6 +160,7 @@ func Provider() tfbridge.ProviderInfo {
"Pulumi": "1.5.0-*",
"System.Collections.Immutable": "1.6.0",
},
Namespaces: namespaceMap,
},
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Pagerduty/Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.Datadog.Pagerduty
namespace Pulumi.Datadog.PagerDuty
{
/// <summary>
/// &gt; This content is derived from https://github.com/terraform-providers/terraform-provider-datadog/blob/master/website/docs/r/integration_pagerduty.html.markdown.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Pagerduty/ServiceObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.Datadog.Pagerduty
namespace Pulumi.Datadog.PagerDuty
{
/// <summary>
/// Provides access to individual Service Objects of Datadog - PagerDuty integrations. Note that the Datadog - PagerDuty integration must be activated (either manually in the Datadog UI or by using [datadog.pagerduty.Integration](https://www.terraform.io/docs/providers/datadog/r/integration_pagerduty.html)) in order for this resource to be usable.
Expand Down