Skip to content

Commit

Permalink
[ignore] Change function SetToSchema to SetSchemaResourceData to bett…
Browse files Browse the repository at this point in the history
…er describe the functionality and adjust error messages
  • Loading branch information
akinross committed Dec 2, 2024
1 parent c872235 commit 43cb14d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mso/datasource_mso_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func datasourceMSOTemplateRead(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
ndoTemplate.SetToSchema(d)
ndoTemplate.SetSchemaResourceData(d)
d.Set("template_id", d.Id())
log.Println("[DEBUG] MSO Template Datasource: Read Completed", d.Id())
return nil
Expand Down
14 changes: 7 additions & 7 deletions mso/resource_mso_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type ndoTemplate struct {
msoClient *client.Client
}

func (ndoTemplate *ndoTemplate) SetToSchema(d *schema.ResourceData) {
func (ndoTemplate *ndoTemplate) SetSchemaResourceData(d *schema.ResourceData) {
d.SetId(ndoTemplate.id)
d.Set("template_name", ndoTemplate.templateName)
d.Set("template_type", ndoTemplate.templateType)
Expand All @@ -167,16 +167,16 @@ func (ndoTemplate *ndoTemplate) validateConfig() []error {
errors := []error{}

if ndoTemplate.tenantId != "" && !ndoTemplateTypes[ndoTemplate.templateType].tenant {
errors = append(errors, fmt.Errorf(fmt.Sprintf("Tenant cannot be attached to template of type %s.", ndoTemplate.templateType)))
errors = append(errors, fmt.Errorf(fmt.Sprintf("A Tenant cannot be attached to a template of type %s.", ndoTemplate.templateType)))
}
if ndoTemplate.tenantId == "" && ndoTemplateTypes[ndoTemplate.templateType].tenant {
errors = append(errors, fmt.Errorf(fmt.Sprintf("Tenant is required for template of type %s.", ndoTemplate.templateType)))
errors = append(errors, fmt.Errorf(fmt.Sprintf("A Tenant is required for a template of type %s. Use the `tenant_id` attribute to specify the Tenant to associate with this template.", ndoTemplate.templateType)))
}
if len(ndoTemplate.sites) == 0 && ndoTemplateTypes[ndoTemplate.templateType].siteAmount == 1 {
errors = append(errors, fmt.Errorf(fmt.Sprintf("Site is required for template of type %s.", ndoTemplate.templateType)))
errors = append(errors, fmt.Errorf(fmt.Sprintf("At least one site is required for a template of type %s.", ndoTemplate.templateType)))
}
if len(ndoTemplate.sites) > 1 && ndoTemplateTypes[ndoTemplate.templateType].siteAmount == 1 {
errors = append(errors, fmt.Errorf(fmt.Sprintf("Only one site is allowed for template of type %s.", ndoTemplate.templateType)))
errors = append(errors, fmt.Errorf(fmt.Sprintf("Only one site is allowed for a template of type %s.", ndoTemplate.templateType)))
}
duplicates := duplicatesInList(ndoTemplate.sites)
if len(duplicates) > 0 {
Expand Down Expand Up @@ -359,7 +359,7 @@ func resourceMSOTemplateRead(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
ndoTemplate.SetToSchema(d)
ndoTemplate.SetSchemaResourceData(d)
log.Println("[DEBUG] MSO Template Resource: Read Completed", d.Id())
return nil
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func resourceMSOTemplateImport(d *schema.ResourceData, m interface{}) ([]*schema
if err != nil {
return nil, err
}
ndoTemplate.SetToSchema(d)
ndoTemplate.SetSchemaResourceData(d)
log.Println("[DEBUG] MSO Template Resource: Import Completed", d.Id())
return []*schema.ResourceData{d}, nil
}

0 comments on commit 43cb14d

Please sign in to comment.