Skip to content

Commit

Permalink
Merge pull request #166 from rundeck/validate-proyect-name
Browse files Browse the repository at this point in the history
Check project name before creating it
  • Loading branch information
fdevans authored Jan 23, 2025
2 parents 310fe8a + e7f55cf commit e023d61
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 e023d61

Please sign in to comment.