Skip to content

Commit

Permalink
fix(Project): Omit empty git configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunEgan committed Jul 29, 2021
1 parent 194f6ac commit 7d82834
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion models.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type RepositoryLink struct {
type CreateProjectRequest struct {
Name string `json:"name"`
Framework string `json:"framework"`
GitRepository *GitRepositoryRequest `json:"gitRepository"`
GitRepository *GitRepositoryRequest `json:"gitRepository,omitempty"`
}

type GitRepositoryRequest struct {
Expand Down
22 changes: 8 additions & 14 deletions projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@ func (p *ProjectApi) CreateProject(ctx context.Context, name string, framework s
rel := &url.URL{Path: "/v6/projects"}
u := p.baseUrl.ResolveReference(rel)

var body *CreateProjectRequest
body := &CreateProjectRequest{
Name: name,
Framework: framework,
}

if repositoryType != "" && repositoryName != "" {
body = &CreateProjectRequest{
Name: name,
Framework: framework,
GitRepository: &GitRepositoryRequest{
Type: repositoryType,
Repo: repositoryName,
},
}
} else {
body = &CreateProjectRequest{
Name: name,
Framework: framework,
body.GitRepository = &GitRepositoryRequest{
Type: repositoryType,
Repo: repositoryName,
}
}


payload, err := json.Marshal(body)
if err != nil {
return nil, err
Expand Down

0 comments on commit 7d82834

Please sign in to comment.