Skip to content

Commit

Permalink
Fix project mapping functions
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Apr 29, 2024
1 parent 491e909 commit 01d0d21
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/provider/project_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,10 @@ func (r *ProjectResource) ImportState(ctx context.Context, req resource.ImportSt
func DTProjectToTFProject(ctx context.Context, dtProject dtrack.Project) (ProjectResourceModel, diag.Diagnostics) {
var diags diag.Diagnostics
project := ProjectResourceModel{
ID: types.StringValue(dtProject.UUID.String()),
Name: types.StringValue(dtProject.Name),
Classifier: types.StringValue(dtProject.Classifier),
Active: types.BoolValue(dtProject.Active),
Description: types.StringValue(dtProject.Description),
ID: types.StringValue(dtProject.UUID.String()),
Name: types.StringValue(dtProject.Name),
Classifier: types.StringValue(dtProject.Classifier),
Active: types.BoolValue(dtProject.Active),
}

if dtProject.ParentRef != nil {
Expand All @@ -245,13 +244,16 @@ func DTProjectToTFProject(ctx context.Context, dtProject dtrack.Project) (Projec
func TFProjectToDTProject(ctx context.Context, tfProject ProjectResourceModel) (dtrack.Project, diag.Diagnostics) {
var diags diag.Diagnostics
project := dtrack.Project{
UUID: uuid.MustParse(tfProject.ID.ValueString()),
Name: tfProject.Name.ValueString(),
Classifier: tfProject.Classifier.ValueString(),
Active: tfProject.Active.ValueBool(),
Description: tfProject.Description.ValueString(),
}

if tfProject.ID.ValueString() != "" {
project.UUID = uuid.MustParse(tfProject.ID.ValueString())
}

if !tfProject.ParentID.IsNull() {
project.ParentRef = &dtrack.ParentRef{UUID: uuid.MustParse(tfProject.ParentID.ValueString())}
}
Expand Down

0 comments on commit 01d0d21

Please sign in to comment.