Skip to content

Commit

Permalink
improvements...
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondshtogu committed Jul 28, 2023
1 parent d8877bd commit 2f31b8a
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 241 deletions.
3 changes: 1 addition & 2 deletions examples/.env-template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ ESXI_HOST=<esxi host>
ESXI_USERNAME=<esxi username>
ESXI_PASSWORD=<esxi password>
ESXI_SSH_PORT=22
ESXI_SSL_PORT=443
ESXI_METADATA_STORE=<data-store-name>
ESXI_SSL_PORT=443
2 changes: 0 additions & 2 deletions examples/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func getConfig(t *testing.T) map[string]string {
config["esxi-native:config:sshPort"] = value
case "ESXI_SSL_PORT":
config["esxi-native:config:sslPort"] = value
case "ESXI_OVFTOOL_LOCATION":
config["esxi-native:config:ovfToolLocation"] = value
}
}

Expand Down
21 changes: 3 additions & 18 deletions provider/cmd/pulumi-resource-esxi-native/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,18 @@
"password": {
"type": "string",
"description": "ESXi Password config"
},
"metadataStore": {
"type": "string",
"description": "ESXi Datastore Name where provider will store its additional configurations and tools (ex.: packer)"
}
},
"required": [
"host",
"password",
"metadataStore"
"password"
]
},
"provider": {
"description": "The provider type for the ESXi native package. By default, resources use package-wide configuration settings, however an explicit `Provider` instance may be created and passed during resource construction to achieve fine-grained programmatic control over provider settings. See the [documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.",
"required": [
"host",
"password",
"metadataStore"
"password"
],
"properties": {
"host": {
Expand All @@ -76,16 +70,11 @@
"password": {
"type": "string",
"description": "ESXi Password config"
},
"metadataStore": {
"type": "string",
"description": "ESXi Datastore Name where provider will store its additional configurations and tools (ex.: packer)"
}
},
"requiredInputs": [
"host",
"password",
"metadataStore"
"password"
],
"inputProperties": {
"host": {
Expand All @@ -110,10 +99,6 @@
"password": {
"type": "string",
"description": "ESXi Password config"
},
"metadataStore": {
"type": "string",
"description": "ESXi Datastore Name where provider will store its additional configurations and tools (ex.: packer)"
}
}
},
Expand Down
13 changes: 6 additions & 7 deletions provider/pkg/esxi/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ type Host struct {
Connection *ConnectionInfo
}

func NewHost(host, sshPort, sslPort, user, pass, ovfLoc string) (*Host, error) {
func NewHost(host, sshPort, sslPort, user, pass string) (*Host, error) {
connection := ConnectionInfo{
Host: host,
SshPort: sshPort,
SslPort: sslPort,
UserName: user,
Password: pass,
OvfLocation: ovfLoc,
Host: host,
SshPort: sshPort,
SslPort: sslPort,
UserName: user,
Password: pass,
}
clientConfig := &ssh.ClientConfig{
User: connection.UserName,
Expand Down
7 changes: 3 additions & 4 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,23 @@ func (p *esxiProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
pass, passErr := getConfig(vars, "password", "ESXI_PASSWORD")
sshPort, sshPortErr := getConfig(vars, "sshPort", "ESXI_SSH_PORT")
sslPort, sslPortErr := getConfig(vars, "sslPort", "ESXI_SSL_PORT")
ovfLoc, ovfLocErr := getConfig(vars, "metadataStore", "ESXI_METADATA_STORE")
if len(sshPort) > 0 {
sshPort = "22"
}
if len(sslPort) > 0 {
sslPort = "443"
}

if len(host) > 0 && len(user) > 0 && len(pass) > 0 && len(ovfLoc) > 0 {
if len(host) > 0 && len(user) > 0 && len(pass) > 0 {
// If all required values are not present/valid, the client will return an appropriate error.
esxiHost, err := esxi.NewHost(host, sshPort, sslPort, user, pass, ovfLoc)
esxiHost, err := esxi.NewHost(host, sshPort, sslPort, user, pass)
if err != nil {
return nil, err
}
p.esxi = esxiHost
} else {
errorMessage := "Invalid config."
for _, errMsg := range []string{hostErr, userErr, passErr, sshPortErr, sslPortErr, ovfLocErr} {
for _, errMsg := range []string{hostErr, userErr, passErr, sshPortErr, sslPortErr} {
if len(errMsg) > 0 {
errorMessage = fmt.Sprintf("%s\n%s", errorMessage, errMsg)
}
Expand Down
16 changes: 3 additions & 13 deletions sdk/dotnet/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ public static string? Host
set => _host.Set(value);
}

private static readonly __Value<string?> _ovfToolLocation = new __Value<string?>(() => __config.Get("ovfToolLocation"));
/// <summary>
/// ESXi Datastore Name config were ovftool will be configured
/// </summary>
public static string? OvfToolLocation
{
get => _ovfToolLocation.Get();
set => _ovfToolLocation.Set(value);
}

private static readonly __Value<string?> _password = new __Value<string?>(() => __config.Get("password"));
/// <summary>
/// ESXi Password config
Expand All @@ -62,7 +52,7 @@ public static string? Password
set => _password.Set(value);
}

private static readonly __Value<string?> _sshPort = new __Value<string?>(() => __config.Get("sshPort") ?? "22");
private static readonly __Value<string?> _sshPort = new __Value<string?>(() => __config.Get("sshPort"));
/// <summary>
/// ESXi Host SSH Port config
/// </summary>
Expand All @@ -72,7 +62,7 @@ public static string? SshPort
set => _sshPort.Set(value);
}

private static readonly __Value<string?> _sslPort = new __Value<string?>(() => __config.Get("sslPort") ?? "443");
private static readonly __Value<string?> _sslPort = new __Value<string?>(() => __config.Get("sslPort"));
/// <summary>
/// ESXi Host SSL Port config
/// </summary>
Expand All @@ -82,7 +72,7 @@ public static string? SslPort
set => _sslPort.Set(value);
}

private static readonly __Value<string?> _username = new __Value<string?>(() => __config.Get("username") ?? "root");
private static readonly __Value<string?> _username = new __Value<string?>(() => __config.Get("username"));
/// <summary>
/// ESXi Username config
/// </summary>
Expand Down
12 changes: 0 additions & 12 deletions sdk/dotnet/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public partial class Provider : global::Pulumi.ProviderResource
[Output("host")]
public Output<string> Host { get; private set; } = null!;

/// <summary>
/// ESXi Datastore Name config were ovftool will be configured
/// </summary>
[Output("ovfToolLocation")]
public Output<string> OvfToolLocation { get; private set; } = null!;

/// <summary>
/// ESXi Password config
/// </summary>
Expand Down Expand Up @@ -85,12 +79,6 @@ public sealed class ProviderArgs : global::Pulumi.ResourceArgs
[Input("host", required: true)]
public Input<string> Host { get; set; } = null!;

/// <summary>
/// ESXi Datastore Name config were ovftool will be configured
/// </summary>
[Input("ovfToolLocation", required: true)]
public Input<string> OvfToolLocation { get; set; } = null!;

/// <summary>
/// ESXi Password config
/// </summary>
Expand Down
8 changes: 1 addition & 7 deletions sdk/dotnet/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,6 @@ public InputList<Inputs.NetworkInterfaceArgs> NetworkInterfaces
[Input("os")]
public Input<string>? Os { get; set; }

/// <summary>
/// Local path to source ovf files.
/// </summary>
[Input("ovfLocalSource")]
public Input<string>? OvfLocalSource { get; set; }

[Input("ovfProperties")]
private InputList<Inputs.KeyValuePairArgs>? _ovfProperties;

Expand All @@ -274,7 +268,7 @@ public InputList<Inputs.KeyValuePairArgs> OvfProperties
public Input<int>? OvfPropertiesTimer { get; set; }

/// <summary>
/// Path or URL on esxi host of ovf files.
/// Path or URL of ovf file source.
/// </summary>
[Input("ovfSource")]
public Input<string>? OvfSource { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2-alpha.1689157800+de9282c6
0.0.2-alpha.1690489921+d8877bdc.dirty
23 changes: 3 additions & 20 deletions sdk/go/esxi/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/go/esxi/portGroup.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions sdk/go/esxi/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/go/esxi/pulumiEnums.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f31b8a

Please sign in to comment.