From 2bf62f0122f3f5ae4d6632ade3402b5dadfcba7a Mon Sep 17 00:00:00 2001 From: Olivier Cloirec <5033885+clook@users.noreply.github.com> Date: Thu, 16 Jul 2020 13:24:35 +0200 Subject: [PATCH] Fix project resource import where autoscan is unknown / unset. --- harbor/resource_project.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/harbor/resource_project.go b/harbor/resource_project.go index 3a04fd5..a3eb4f8 100644 --- a/harbor/resource_project.go +++ b/harbor/resource_project.go @@ -156,13 +156,16 @@ func setProjectSchema(data *schema.ResourceData, project *models.Project) error return err } - autoScan, err := strconv.ParseBool(project.Metadata.AutoScan) - if err != nil { - return err - } + // prevent errors where auto_scan is unset + if project.Metadata.AutoScan != "" { + autoScan, err := strconv.ParseBool(project.Metadata.AutoScan) + if err != nil { + return err + } - if err := data.Set("vulnerability_scanning", autoScan); err != nil { - return err + if err := data.Set("vulnerability_scanning", autoScan); err != nil { + return err + } } public, err := strconv.ParseBool(project.Metadata.Public)