add profiles to response

This commit is contained in:
Victor Vrantchan
2016-05-04 17:59:18 -04:00
parent 02965de47f
commit 257e6120ea
2 changed files with 8 additions and 2 deletions

View File

@@ -9,9 +9,9 @@ import (
// Profile is a configuration profile
type Profile struct {
UUID string `plist:"-" json:"profile_uuid" db:"profile_uuid"`
UUID string `plist:"-" json:"profile_uuid,omitempty" db:"profile_uuid"`
PayloadIdentifier string `json:"payload_identifier" db:"identifier"`
Data string `json:"data" db:"data"`
Data string `json:"data,omitempty" db:"data"`
}
// Logger adds a logger to the database config

View File

@@ -36,10 +36,16 @@ func (svc workflowService) CreateWorkflow(wfRequest *Workflow) (*Workflow, error
}
// if this loop fails the workflow already exists
// need to delete the workflow? ugh
// also, the PayloadIdentifier is not validated
// it should be
for _, pf := range wfRequest.Profiles {
if err := svc.db.AddProfile(wf.UUID, pf.UUID); err != nil {
return nil, errors.Wrap(err, "createworkflow failed to add profile")
}
wf.Profiles = append(wf.Profiles, configProfile{
UUID: pf.UUID,
PayloadIdentifier: pf.PayloadIdentifier,
})
}
return wf, nil
}