diff --git a/internal/deploy/devops_service.go b/internal/deploy/devops_service.go index fa46e35..e4d4113 100644 --- a/internal/deploy/devops_service.go +++ b/internal/deploy/devops_service.go @@ -90,14 +90,22 @@ func (c *DevOpsServiceClient) InstallDependencies(listToInstall []string) ([]str if !ok { for _, dep := range listToInstall { - switch dep { + switch strings.ToLower(dep) { case "brew": brewPresent := c.findPath("brew") if brewPresent == "" { if err := c.InstallBrew(); err != nil { return installed_dependencies, err } - installed_dependencies = append(installed_dependencies, "brew") + isAlreadyInInstalledDependencies := false + for _, installedDep := range installed_dependencies { + if installedDep == "brew" { + isAlreadyInInstalledDependencies = true + } + } + if !isAlreadyInInstalledDependencies { + installed_dependencies = append(installed_dependencies, "brew") + } } case "git": gitPresent := c.findPath("git") @@ -127,7 +135,7 @@ func (c *DevOpsServiceClient) InstallDependencies(listToInstall []string) ([]str installed_dependencies = append(installed_dependencies, "vagrant") } default: - return installed_dependencies, errors.New("Unsupported dependency") + return installed_dependencies, errors.New("Unsupported dependency " + dep + " to install") } } } else { diff --git a/internal/deploy/models/resource_models_v2.go b/internal/deploy/models/resource_models_v2.go index 57ba9ce..eeabf50 100644 --- a/internal/deploy/models/resource_models_v2.go +++ b/internal/deploy/models/resource_models_v2.go @@ -2,6 +2,7 @@ package models import ( "strings" + "terraform-provider-parallels-desktop/internal/apiclient" "terraform-provider-parallels-desktop/internal/models" "terraform-provider-parallels-desktop/internal/schemas/authenticator" @@ -115,6 +116,10 @@ func (p *ParallelsDesktopDevopsConfigV2) MapObject() basetypes.ObjectValue { } func (o *DeployResourceModelV2) GenerateApiHostConfig(provider *models.ParallelsProviderModel) apiclient.HostConfig { + if o.Api.IsNull() || o.Api.IsUnknown() { + return apiclient.HostConfig{} + } + hostConfig := apiclient.HostConfig{ IsOrchestrator: false, Host: strings.ReplaceAll(o.SshConnection.Host.String(), "\"", ""), diff --git a/internal/schemas/reverseproxy/operations.go b/internal/schemas/reverseproxy/operations.go index 5f4936b..6b6d538 100644 --- a/internal/schemas/reverseproxy/operations.go +++ b/internal/schemas/reverseproxy/operations.go @@ -22,11 +22,11 @@ func Read() diag.Diagnostics { func Create(ctx context.Context, config apiclient.HostConfig, request []ReverseProxyHost) ([]ReverseProxyHost, diag.Diagnostics) { diagnostic := diag.Diagnostics{} - for _, host := range request { + for i, host := range request { if h, diag := createHost(ctx, config, host); diag.HasError() { diagnostic = append(diagnostic, diag...) } else { - host.ID = h.ID + request[i].ID = h.ID } }