-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
68 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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2020 Clivern. All rights reserved. | ||
// Use of this source code is governed by the MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package model | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// Container struct | ||
type Container struct { | ||
Name string `json:"name"` | ||
Image string `json:"image"` | ||
Version string `json:"version"` | ||
Deployment Deployment `json:"deployment"` | ||
} | ||
|
||
// Application struct | ||
type Application struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Format string `json:"format"` | ||
Containers []Container `json:"containers"` | ||
} | ||
|
||
// Deployment struct | ||
type Deployment struct { | ||
Name string `json:"name"` | ||
UID string `json:"uid"` | ||
} | ||
|
||
// LoadFromJSON update object from json | ||
func (c *Application) LoadFromJSON(data []byte) (bool, error) { | ||
err := json.Unmarshal(data, &c) | ||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
} | ||
|
||
// ConvertToJSON convert object to json | ||
func (c *Application) ConvertToJSON() (string, error) { | ||
data, err := json.Marshal(&c) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(data), nil | ||
} | ||
|
||
// LoadFromJSON update object from json | ||
func (d *Deployment) LoadFromJSON(data []byte) (bool, error) { | ||
err := json.Unmarshal(data, &d) | ||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
} | ||
|
||
// ConvertToJSON convert object to json | ||
func (d *Deployment) ConvertToJSON() (string, error) { | ||
data, err := json.Marshal(&d) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(data), 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 was deleted.
Oops, something went wrong.