// resourceIssueRead reads issue details using jira api
resourceIssueRead reads issue details using jira api
// resourceIssueRead reads issue details using jira api
func resourceIssueRead(d *schema.ResourceData, m interface{}) error {
	config := m.(*Config)
	issue, res, err := config.jiraClient.Issue.Get(d.Id(), nil)
	if err != nil {
		body, _ := ioutil.ReadAll(res.Body)
		return errors.Wrapf(err, "getting jira issue failed: %s", body)
	}
	if issue.Fields.Assignee != nil {
		d.Set("assignee", issue.Fields.Assignee.Name)
	}
	if issue.Fields.Reporter != nil {
		d.Set("reporter", issue.Fields.Reporter.Name)
	}
	var resourceFieldsRaw, resourceHasFields = d.GetOk("fields")
	if resourceHasFields {
		incomingFields := make(map[string]string)
		resourceFields := resourceFieldsRaw.(map[string]string)
		for field := range issue.Fields.Unknowns {
			if _, existingField := resourceFields[field]; existingField {
				if value, valueExists := issue.Fields.Unknowns.Value(field); valueExists {
					switch value.(type) {
					case bool:
						incomingFields[field] = fmt.Sprintf("%t", value.(bool))
					case int:
						incomingFields[field] = fmt.Sprintf("%d", value.(int))
					case float32:
						incomingFields[field] = fmt.Sprintf("%f", value.(float32))
					case float64:
						incomingFields[field] = fmt.Sprintf("%f", value.(float64))
					case uint:
						incomingFields[field] = fmt.Sprintf("%d", value.(uint))
					}
				}
			}
		}
		d.Set("fields", incomingFields)
	}
	d.Set("labels", nil)
	if issue.Fields.Labels != nil && len(issue.Fields.Labels) > 0 {
		d.Set("labels", issue.Fields.Labels)
	}
	d.Set("issue_type", issue.Fields.Type.Name)
	if issue.Fields.Description != "" {
		d.Set("description", issue.Fields.Description)
	}
	d.Set("summary", issue.Fields.Summary)
	d.Set("project_key", issue.Fields.Project.Key)
	d.Set("issue_key", issue.Key)
	d.Set("state", issue.Fields.Status.ID)
	return nil
}
func resourceIssueRead ( d * schema . ResourceData , m interface { } ) error { config := m . ( * Config ) issue , res , err := config . jiraClient . Issue . Get ( d . Id ( ) , nil ) if err != nil { body , _ := ioutil . ReadAll ( res . Body ) return errors . Wrapf ( err , " " , body ) } if issue . Fields . Assignee != nil { d . Set ( " " , issue . Fields . Assignee . Name ) } if issue . Fields . Reporter != nil { d . Set ( " " , issue . Fields . Reporter . Name ) } var resourceFieldsRaw , resourceHasFields = d . GetOk ( " " ) if resourceHasFields { incomingFields := make ( map [ string ] string ) resourceFields := resourceFieldsRaw . ( map [ string ] string ) for field := range issue . Fields . Unknowns { if _ , existingField := resourceFields [ field ] ; existingField { if value , valueExists := issue . Fields . Unknowns . Value ( field ) ; valueExists { switch value . ( type ) { case bool : incomingFields [ field ] = fmt . Sprintf ( " " , value . ( bool ) ) case int : incomingFields [ field ] = fmt . Sprintf ( " " , value . ( int ) ) case float32 : incomingFields [ field ] = fmt . Sprintf ( " " , value . ( float32 ) ) case float64 : incomingFields [ field ] = fmt . Sprintf ( " " , value . ( float64 ) ) case uint : incomingFields [ field ] = fmt . Sprintf ( " " , value . ( uint ) ) } } } } d . Set ( " " , incomingFields ) } d . Set ( " " , nil ) if issue . Fields . Labels != nil && len ( issue . Fields . Labels ) > 0 { d . Set ( " " , issue . Fields . Labels ) } d . Set ( " " , issue . Fields . Type . Name ) if issue . Fields . Description != " " { d . Set ( " " , issue . Fields . Description ) } d . Set ( " " , issue . Fields . Summary ) d . Set ( " " , issue . Fields . Project . Key ) d . Set ( " " , issue . Key ) d . Set ( " " , issue . Fields . Status . ID ) return nil }
resourceIssueRead reads issue details using jira api
resourceIssueRead reads issue details using jira api
// Custom or non-standard fields // Only scalar types supported for now