Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added import funcionality to jira projects #58

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions jira/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jira
import (
"fmt"
"strconv"

"log"
jira "github.com/andygrunwald/go-jira"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/pkg/errors"
Expand Down Expand Up @@ -63,6 +63,9 @@ func resourceProject() *schema.Resource {
Read: resourceProjectRead,
Update: resourceProjectUpdate,
Delete: resourceProjectDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"project_id": &schema.Schema{
Expand Down Expand Up @@ -201,12 +204,11 @@ func resourceProjectCreate(d *schema.ResourceData, m interface{}) error {
// resourceProjectRead reads issue details using jira api
func resourceProjectRead(d *schema.ResourceData, m interface{}) error {
config := m.(*Config)

project, _, err := config.jiraClient.Project.Get(d.Id())
if err != nil {
return errors.Wrap(err, "getting jira project failed")
}

log.Printf("[INFO] Getting Project")
id, _ := strconv.Atoi(d.Id())
d.Set("project_id", id)
d.Set("key", project.Key)
Expand Down