Skip to content

Commit

Permalink
fix template creation model to omit empty github installation id
Browse files Browse the repository at this point in the history
  • Loading branch information
avnerenv0 committed May 31, 2021
1 parent b06e0f2 commit 16698cf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
6 changes: 3 additions & 3 deletions client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type Project struct {
}

type UpdateProjectPayload struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
}

type ConfigurationVariableSchema struct {
Expand Down Expand Up @@ -107,7 +107,7 @@ type TemplateCreatePayload struct {
IsGitLab bool `json:"isGitLab"`
TokenName string `json:"tokenName"`
TokenId string `json:"tokenId"`
GithubInstallationId int `json:"githubInstallationId"`
GithubInstallationId int `json:"githubInstallationId,omitempty"`
Revision string `json:"revision"`
ProjectIds []string `json:"projectIds,omitempty"`
OrganizationId string `json:"organizationId"`
Expand Down
21 changes: 21 additions & 0 deletions client/model_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package client_test

import (
"encoding/json"

. "github.com/env0/terraform-provider-env0/client"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("Models", func() {
Describe("TemplateCreatePayload", func() {
It("Should omit Github Installation Id when it's not there", func() {
payload := TemplateCreatePayload{}
jsonPayload, _ := json.Marshal(payload)
var parsedPayload map[string]interface{}
json.Unmarshal(jsonPayload, &parsedPayload)
Expect(parsedPayload["githubInstallationId"]).To(BeNil())
})
})
})
10 changes: 5 additions & 5 deletions tests/integration/005_ssh_key/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ output "name" {
}

resource "env0_template" "usage" {
name = "use a ssh key"
description = "use a ssh key"
type = "terraform"
repository = "https://github.com/shlomimatichin/env0-template-jupyter-gpu"
ssh_keys = [env0_ssh_key.tested]
name = "use a ssh key"
description = "use a ssh key"
type = "terraform"
repository = "https://github.com/shlomimatichin/env0-template-jupyter-gpu"
ssh_keys = [env0_ssh_key.tested]
}

0 comments on commit 16698cf

Please sign in to comment.