-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a24aba2
commit 427571c
Showing
13 changed files
with
173 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,46 @@ | ||
using static Ubiquitous.AutoDevOps.Stack.AutoDevOpsSettings; | ||
using System; | ||
using JetBrains.Annotations; | ||
using Pulumi; | ||
|
||
namespace Ubiquitous.AutoDevOps.Stack.Factories { | ||
public static class Names { | ||
public static string PulumiName(this DeploySettings settings, string? resource = null) => | ||
resource.IsEmpty() ? settings.ResourceName : $"{settings.ResourceName}-{resource}"; | ||
[PublicAPI] | ||
public record ResourceName { | ||
public string Value { get; } | ||
|
||
public ResourceName(string value) { | ||
if (string.IsNullOrEmpty(value)) | ||
throw new ArgumentNullException(nameof(value), "Resource name cannot be empty"); | ||
Value = value; | ||
} | ||
|
||
public static implicit operator string(ResourceName resourceName) => resourceName.GetName(); | ||
|
||
public static implicit operator Input<string>(ResourceName resourceName) => resourceName.GetName(); | ||
|
||
public static implicit operator ResourceName(string value) => new(value); | ||
|
||
static string _baseName = ""; | ||
public static void SetBaseName(string baseName) => _baseName = baseName; | ||
|
||
public PulumiName AsPulumiName() => new(Value); | ||
|
||
string GetName() => _baseName.IsEmpty() ? Value : $"{_baseName}-{Value}"; | ||
} | ||
|
||
[PublicAPI] | ||
public record PulumiName { | ||
public string Value { get; } | ||
|
||
public PulumiName(string value) { | ||
if (string.IsNullOrEmpty(value)) | ||
throw new ArgumentNullException(nameof(value), "Pulumi resource name cannot be empty"); | ||
Value = value; | ||
} | ||
|
||
public static implicit operator string(PulumiName resourceName) | ||
=> _baseName.IsEmpty() ? resourceName.Value : $"{_baseName}-{resourceName.Value}"; | ||
|
||
static string _baseName = ""; | ||
public static void SetBaseName(string baseName) => _baseName = baseName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.