From 5c12ec5b937f0ca7ee01ce9c5f1d382aef1b5242 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Wed, 18 Jan 2023 12:16:51 +0100 Subject: [PATCH] Fix return value; Remove short flags to avoid collisions; Update documentation --- .drone.yml | 2 +- README.md | 11 +++++++---- cmd/npp-prepper/main.go | 6 +++--- pkg/hypervisor/client.go | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index f63e7a2..c643d15 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ type: kubernetes name: 'Golang Build' environment: - BINARY_VERSION: v0.4.5 + BINARY_VERSION: v0.5.0 clone: disable: true diff --git a/README.md b/README.md index 9e85020..69eab53 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ -# NPP-Prepper +# NPP-Prepper [![Build Status](https://ci.spamasaurus.com/api/badges/djpbessems/Go.NPP-Prepper/status.svg)](https://ci.spamasaurus.com/djpbessems/Go.NPP-Prepper) A simple static binary that allows the creation of vCenter's Network Protocol Profiles (within vCenter's API referred to as IpPools). Existing tooling like `govc` or `PowerCLI` can either not be used to configure IpPools, or adds unreasonably large overhead (container image `vmware/powerclicore` is nearly 1GB large). In fact, VMware's documentation *only* mentions how to use this feature through the use of vCenter's webinterface, which is entirely pointless in nowadays' world of automation. `npp-prepper` was born out of necessity; one of my projects involves bootstrapping OVA's in greenfield environments, with the explicit design choice to not rely on external processes, like DHCP. +### Download +Latest release can be downloaded [here](https://code.spamasaurus.com/djpbessems/-/packages/generic/npp-prepper) + ### Usage ```bash Usage: @@ -42,7 +45,7 @@ Help Options: [dc command options] -n, --name= Name of datacenter - -p, --portgroup= Name of network portgroup + --portgroup= Name of network portgroup --startaddress= --endaddress= --netmask= @@ -69,9 +72,9 @@ Help Options: -h, --help Show this help message [vm command options] - -d, --datacenter= Name of datacenter -n, --name= Name of virtual machine - -p, --portgroup= Name of network portgroup + --datacenter= Name of datacenter + --portgroup= Name of network portgroup ``` ### Future plans diff --git a/cmd/npp-prepper/main.go b/cmd/npp-prepper/main.go index eebb9c4..cf3ba5c 100644 --- a/cmd/npp-prepper/main.go +++ b/cmd/npp-prepper/main.go @@ -18,7 +18,7 @@ var Global struct { var Commands struct { Datacenter struct { Name string `short:"n" long:"name" description:"Name of datacenter" required:"true"` - Network string `short:"p" long:"portgroup" description:"Name of network portgroup" required:"true"` + Network string `long:"portgroup" description:"Name of network portgroup" required:"true"` StartAddress string `long:"startaddress" required:"true"` EndAddress string `long:"endaddress" required:"true"` Netmask string `long:"netmask" required:"true"` @@ -28,9 +28,9 @@ var Commands struct { Force bool `short:"f" long:"force"` } // `command:"datacenter" alias:"dc" description:"Define a Network Protocol Profile within a datacenter"` VirtualMachine struct { - Datacenter string `short:"d" long:"datacenter" description:"Name of datacenter" required:"true"` Name string `short:"n" long:"name" description:"Name of virtual machine" required:"true"` - Network string `short:"p" long:"portgroup" description:"Name of network portgroup" required:"true"` + Datacenter string `long:"datacenter" description:"Name of datacenter" required:"true"` + Network string `long:"portgroup" description:"Name of network portgroup" required:"true"` } // `command:"virtualmachine" alias:"vm" description:"Configure a virtual machine for usage of Network Protocol Profiles"` GuestOS struct { } // `command:"guestos" alias:"os" description:"Configure guest OS network with allocated IP address"` diff --git a/pkg/hypervisor/client.go b/pkg/hypervisor/client.go index e7400ba..09c1709 100644 --- a/pkg/hypervisor/client.go +++ b/pkg/hypervisor/client.go @@ -29,7 +29,7 @@ func NewClient(ctx context.Context, host, username, password string, insecure bo return nil, err } - return clt, err + return clt, nil } func DatacenterFinder(ctx context.Context, clt *vim25.Client, datacenter string) (*find.Finder, error) {