From c87223566fab161a9b0c996612dbd7d381e3e697 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 9b23d793..57d92590 100644 --- a/mso/utils.go +++ b/mso/utils.go @@ -295,3 +295,31 @@ func createPortPath(path_type, static_port_pod, static_port_leaf, static_port_fe return fmt.Sprintf("topology/%s/paths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_path) } } + +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 +}