diff --git a/CHANGELOG.md b/CHANGELOG.md index eeeb1cf..77e843e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,4 +15,4 @@ FEATURES: - Fixed some bugs - Added the ability to register a deployment with a orchestrator - Added the ability to run prlctl commands -- Added the ability to run a script on destroy +- Added the ability to run a script on destroy it diff --git a/internal/clone_vm/resource.go b/internal/clone_vm/resource.go index c28db52..a93fcd3 100644 --- a/internal/clone_vm/resource.go +++ b/internal/clone_vm/resource.go @@ -340,6 +340,13 @@ func (r *CloneVmResource) Create(ctx context.Context, req resource.CreateRequest externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break @@ -687,6 +694,13 @@ func (r *CloneVmResource) Update(ctx context.Context, req resource.UpdateRequest externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break diff --git a/internal/remoteimage/resource.go b/internal/remoteimage/resource.go index 9b1e912..5629ab0 100644 --- a/internal/remoteimage/resource.go +++ b/internal/remoteimage/resource.go @@ -378,6 +378,13 @@ func (r *RemoteVmResource) Create(ctx context.Context, req resource.CreateReques externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break @@ -755,6 +762,13 @@ func (r *RemoteVmResource) Update(ctx context.Context, req resource.UpdateReques externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break diff --git a/internal/vagrantbox/resource.go b/internal/vagrantbox/resource.go index c3be0e5..135aa5b 100644 --- a/internal/vagrantbox/resource.go +++ b/internal/vagrantbox/resource.go @@ -322,6 +322,13 @@ func (r *VagrantBoxResource) Create(ctx context.Context, req resource.CreateRequ externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break @@ -667,6 +674,13 @@ func (r *VagrantBoxResource) Update(ctx context.Context, req resource.UpdateRequ externalIp = refreshVm.HostExternalIpAddress internalIp = refreshVm.InternalIpAddress } + + if refreshVm.State != "running" { + externalIp = refreshVm.HostExternalIpAddress + internalIp = "-" + break + } + if internalIp != "" { time.Sleep(5 * time.Second) break