From e267739c387f651d0d423b113249f4e722eb5c26 Mon Sep 17 00:00:00 2001 From: akinross Date: Mon, 11 Nov 2024 14:46:31 +0100 Subject: [PATCH] [ignore] Move generic util functions to utils.go --- mso/resource_mso_template.go | 28 ---------------------------- mso/utils.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/mso/resource_mso_template.go b/mso/resource_mso_template.go index 17063fd5..8bbc7668 100644 --- a/mso/resource_mso_template.go +++ b/mso/resource_mso_template.go @@ -461,31 +461,3 @@ func resourceMSOTemplateImport(d *schema.ResourceData, m interface{}) ([]*schema log.Println("[DEBUG] MSO Template Resource: Import Completed", d.Id()) return []*schema.ResourceData{d}, nil } - -func getListOfStringsFromSchemaList(d *schema.ResourceData, key string) []string { - if values, ok := d.GetOk(key); ok { - return convertToListOfStrings(values.([]interface{})) - } - return nil -} - -func convertToListOfStrings(values []interface{}) []string { - result := []string{} - for _, item := range values { - result = append(result, item.(string)) - } - return result -} - -func duplicatesInList(list []string) []string { - duplicates := []string{} - set := make(map[string]int) - for index, item := range list { - if _, ok := set[item]; ok { - duplicates = append(duplicates, item) - } else { - set[item] = index - } - } - return duplicates -} diff --git a/mso/utils.go b/mso/utils.go index 03df6217..87e39c68 100644 --- a/mso/utils.go +++ b/mso/utils.go @@ -240,3 +240,31 @@ func getSchemaIdFromName(msoClient *client.Client, name string) (string, error) return "", fmt.Errorf("Schema of specified name not found") } + +func getListOfStringsFromSchemaList(d *schema.ResourceData, key string) []string { + if values, ok := d.GetOk(key); ok { + return convertToListOfStrings(values.([]interface{})) + } + return nil +} + +func convertToListOfStrings(values []interface{}) []string { + result := []string{} + for _, item := range values { + result = append(result, item.(string)) + } + return result +} + +func duplicatesInList(list []string) []string { + duplicates := []string{} + set := make(map[string]int) + for index, item := range list { + if _, ok := set[item]; ok { + duplicates = append(duplicates, item) + } else { + set[item] = index + } + } + return duplicates +}