Skip to content

Commit

Permalink
Merge pull request #17 from tuckner/update-fix
Browse files Browse the repository at this point in the history
fix action update bug
  • Loading branch information
tuckner authored Jun 9, 2021
2 parents 28101c3 + bb80ea0 commit 33d1f6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=github.com
NAMESPACE=tuckner
NAME=tines
BINARY=terraform-provider-${NAME}
VERSION=0.0.16
VERSION=0.0.17
OS_ARCH=darwin_amd64

default: install
Expand Down
12 changes: 7 additions & 5 deletions tines/resource_tines_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tines

import (
"encoding/json"
"log"
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -114,7 +113,7 @@ func resourceTinesAgentCreate(d *schema.ResourceData, meta interface{}) error {

custom := tcontainer.NewMarshalMap()
custom["options"] = optionContainer
log.Printf("[DEBUG] Options block: %v", custom)
// log.Printf("[DEBUG] Options block: %v", custom)

a := tines.Agent{
Name: name,
Expand Down Expand Up @@ -158,7 +157,7 @@ func resourceTinesAgentRead(d *schema.ResourceData, meta interface{}) error {
d.Set("story_id", agent.StoryID)
d.Set("user_id", agent.UserID)
d.Set("position", agent.Position)
d.Set("agent_type", d.Get("agent_type").(string))
d.Set("agent_type", agent.Type)

return nil
}
Expand All @@ -185,10 +184,10 @@ func resourceTinesAgentUpdate(d *schema.ResourceData, meta interface{}) error {
agentType := d.Get("agent_type").(string)
storyID := d.Get("story_id").(int)
keepEventsFor := d.Get("keep_events_for").(int)
position := d.Get("position").(map[string]interface{})
sourceRaw := d.Get("source_ids").([]interface{})
receiveRaw := d.Get("receiver_ids").([]interface{})
options := d.Get("agent_options").(string)
position := d.Get("position").(map[string]interface{})

receiveID := make([]int, len(receiveRaw))
for i, v := range receiveRaw {
Expand All @@ -200,8 +199,11 @@ func resourceTinesAgentUpdate(d *schema.ResourceData, meta interface{}) error {
sourceID[i] = v.(int)
}

var optionContainer map[string]interface{}
json.Unmarshal([]byte(options), &optionContainer)

custom := tcontainer.NewMarshalMap()
custom["options"] = options
custom["options"] = optionContainer
// log.Printf("[DEBUG] Options block: %v", custom)

a := tines.Agent{
Expand Down

0 comments on commit 33d1f6d

Please sign in to comment.