This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move code for (de)serialization from/to JSON to model struc…
…ts (#376) * refactor: Move code for (de)serialization from/to JSON to model structs Signed-off-by: odubajDT <[email protected]> * added comments to the exported methods Signed-off-by: odubajDT <[email protected]> * remove unnecessary check Signed-off-by: odubajDT <[email protected]>
- Loading branch information
Showing
40 changed files
with
600 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package models | ||
|
||
import "encoding/json" | ||
|
||
// CreateService create service | ||
type CreateService struct { | ||
|
||
// service name | ||
// Required: true | ||
ServiceName *string `json:"serviceName"` | ||
} | ||
|
||
// ToJSON converts object to JSON string | ||
func (c *CreateService) ToJSON() ([]byte, error) { | ||
return json.Marshal(c) | ||
} | ||
|
||
// FromJSON converts JSON string to object | ||
func (c *CreateService) FromJSON(b []byte) error { | ||
var res CreateService | ||
if err := json.Unmarshal(b, &res); err != nil { | ||
return err | ||
} | ||
*c = res | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package models | ||
|
||
import "encoding/json" | ||
|
||
// DeleteProjectResponse delete project response | ||
type DeleteProjectResponse struct { | ||
|
||
// message | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
// ToJSON converts object to JSON string | ||
func (d *DeleteProjectResponse) ToJSON() ([]byte, error) { | ||
return json.Marshal(d) | ||
} | ||
|
||
// FromJSON converts JSON string to object | ||
func (d *DeleteProjectResponse) FromJSON(b []byte) error { | ||
var res DeleteProjectResponse | ||
if err := json.Unmarshal(b, &res); err != nil { | ||
return err | ||
} | ||
*d = res | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package models | ||
|
||
import "encoding/json" | ||
|
||
// DeleteServiceResponse delete service response | ||
type DeleteServiceResponse struct { | ||
|
||
// message | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
// ToJSON converts object to JSON string | ||
func (d *DeleteServiceResponse) ToJSON() ([]byte, error) { | ||
return json.Marshal(d) | ||
} | ||
|
||
// FromJSON converts JSON string to object | ||
func (d *DeleteServiceResponse) FromJSON(b []byte) error { | ||
var res DeleteServiceResponse | ||
if err := json.Unmarshal(b, &res); err != nil { | ||
return err | ||
} | ||
*d = res | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package models | ||
|
||
import "encoding/json" | ||
|
||
// EventContext event context | ||
type EventContext struct { | ||
|
||
// keptn context | ||
// Required: true | ||
KeptnContext *string `json:"keptnContext"` | ||
} | ||
|
||
// ToJSON converts object to JSON string | ||
func (ec *EventContext) ToJSON() ([]byte, error) { | ||
return json.Marshal(ec) | ||
} | ||
|
||
// FromJSON converts JSON string to object | ||
func (ec *EventContext) FromJSON(b []byte) error { | ||
var res EventContext | ||
if err := json.Unmarshal(b, &res); err != nil { | ||
return err | ||
} | ||
*ec = res | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.