Skip to content

Commit

Permalink
check project name before creating it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus-Osuna-M committed Jan 23, 2025
1 parent 310fe8a commit e7f55cf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rundeck/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ func CreateProject(d *schema.ResourceData, meta interface{}) error {
name := d.Get("name").(string)

ctx := context.Background()

project, _ := client.ProjectGet(ctx, name)

if project.StatusCode != 404 {
return fmt.Errorf("project with unique name (%s) already exist", name)
}

_, err := client.ProjectCreate(ctx, rundeck.ProjectCreateRequest{
Name: &name,
})
Expand Down

0 comments on commit e7f55cf

Please sign in to comment.