From 9b62c342cf735775d1a2998857eabbe2a397f121 Mon Sep 17 00:00:00 2001 From: "Jose R. Gonzalez" Date: Thu, 18 Aug 2022 10:38:21 -0500 Subject: [PATCH] Remove the project type when submitting updates to pyxis Signed-off-by: Jose R. Gonzalez --- certification/pyxis/pyxis.go | 14 +++++++++++++- certification/pyxis/types.go | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/certification/pyxis/pyxis.go b/certification/pyxis/pyxis.go index 899ffdd8..675c31b3 100644 --- a/certification/pyxis/pyxis.go +++ b/certification/pyxis/pyxis.go @@ -299,7 +299,19 @@ func (p *pyxisClient) GetProject(ctx context.Context) (*CertProject, error) { } func (p *pyxisClient) updateProject(ctx context.Context, certProject *CertProject) (*CertProject, error) { - b, err := json.Marshal(certProject) + // We cannot send the project type to pyxis in a Patch. + // Copy the CertProject and strip the Type value to + // have omitempty skip the key in the JSON patch. + patchCertProject := &CertProject{ + ID: certProject.ID, + CertificationStatus: certProject.CertificationStatus, + Container: certProject.Container, + Name: certProject.Name, + ProjectStatus: certProject.ProjectStatus, + // Do not copy the Type. + } + + b, err := json.Marshal(patchCertProject) if err != nil { return nil, fmt.Errorf("could not marshal certProject: %w", err) } diff --git a/certification/pyxis/types.go b/certification/pyxis/types.go index 27fe87a5..469786ba 100644 --- a/certification/pyxis/types.go +++ b/certification/pyxis/types.go @@ -99,9 +99,9 @@ type CertProject struct { ID string `json:"_id,omitempty"` CertificationStatus string `json:"certification_status" default:"In Progress"` Container Container `json:"container"` - Name string `json:"name"` // required - ProjectStatus string `json:"project_status"` // required - Type string `json:"type" default:"Containers"` // required + Name string `json:"name"` // required + ProjectStatus string `json:"project_status"` // required + Type string `json:"type,omitempty"` // required } type Container struct {