generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into errorHandlingForRegistry
Signed-off-by: Shlok Mishra <99207534+Jougan-0@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
356 additions
and
40 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
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,5 +1,5 @@ | ||
{ | ||
"name": "meshkit", | ||
"type": "library", | ||
"next_error_code": 11243 | ||
"next_error_code": 11245 | ||
} |
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,102 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"database/sql/driver" | ||
"encoding/json" | ||
|
||
"github.com/layer5io/meshkit/utils" | ||
) | ||
|
||
// CatalogData defines model for catalog_data. | ||
type CatalogData struct { | ||
ContentClass ContentClass `json:"content_class,omitempty"` | ||
//Tracks the specific content version that has been made available in the Catalog | ||
PublishedVersion string `json:"published_version"` | ||
|
||
// Compatibility A list of technologies included in or implicated by this design; a list of relevant technology tags. | ||
Compatibility []CatalogDataCompatibility `json:"compatibility"` | ||
|
||
// PatternCaveats Specific stipulations to consider and known behaviors to be aware of when using this design. | ||
PatternCaveats string `json:"pattern_caveats"` | ||
|
||
// PatternInfo Purpose of the design along with its intended and unintended uses. | ||
PatternInfo string `json:"pattern_info"` | ||
|
||
// Contains reference to the dark and light mode snapshots of the catalog. | ||
SnapshotURL []string `json:"imageURL,omitempty"` // this will require updating exisitng catalog data as well. updated the json tag to match previous key name, so changes will not be required in exisitng catgalogs | ||
|
||
// Type Categorization of the type of design or operational flow depicted in this design. | ||
Type CatalogDataType `json:"type"` | ||
} | ||
|
||
func (cd *CatalogData) Scan(value interface{}) error { | ||
if value == nil { | ||
cd = &CatalogData{} | ||
return nil | ||
} | ||
data, err := utils.Cast[[]byte](value) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = json.Unmarshal([]byte(data), cd) | ||
if err != nil { | ||
return utils.ErrUnmarshal(err) | ||
} | ||
return nil | ||
} | ||
|
||
func (cd CatalogData) Value() (driver.Value, error) { | ||
marshaledValue, err := json.Marshal(cd) | ||
if err != nil { | ||
return nil, utils.ErrMarshal(err) | ||
} | ||
return marshaledValue, nil | ||
} | ||
|
||
// CatalogDataCompatibility defines model for CatalogData.Compatibility. | ||
type CatalogDataCompatibility string | ||
|
||
// CatalogDataType Categorization of the type of design or operational flow depicted in this design. | ||
type CatalogDataType string | ||
|
||
func (cd *CatalogData) IsNil() bool { | ||
return cd == nil || (len(cd.Compatibility) == 0 && | ||
cd.PatternCaveats == "" && | ||
cd.PatternInfo == "" && | ||
cd.Type == "" && | ||
cd.ContentClass.String() != "") | ||
} | ||
|
||
type ContentClass string | ||
|
||
const ( | ||
Official ContentClass = "official" | ||
Verified ContentClass = "verified" | ||
Project ContentClass = "project" | ||
Community ContentClass = "community" | ||
) | ||
|
||
func (c ContentClass) String() string { | ||
switch c { | ||
case Official: | ||
return "official" | ||
case Verified: | ||
return "verified" | ||
case Project: | ||
return "Project" | ||
case Community: | ||
fallthrough | ||
default: | ||
return "community" | ||
} | ||
} | ||
|
||
func GetCatalogClasses() []ContentClass { | ||
return []ContentClass{ | ||
Official, | ||
Verified, | ||
Project, | ||
Community, | ||
} | ||
} |
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,42 @@ | ||
package utils | ||
|
||
import ( | ||
"archive/tar" | ||
"bytes" | ||
) | ||
|
||
type TarWriter struct { | ||
Writer *tar.Writer | ||
Buffer *bytes.Buffer | ||
} | ||
|
||
func NewTarWriter() *TarWriter { | ||
buffer := bytes.Buffer{} | ||
return &TarWriter{ | ||
Writer: tar.NewWriter(&buffer), | ||
Buffer: &buffer, | ||
} | ||
} | ||
|
||
func (tw *TarWriter) Compress(name string, data []byte) error { | ||
header := tar.Header{ | ||
Name: name, | ||
Size: int64(len(data)), | ||
Mode: 777, | ||
} | ||
err := tw.Writer.WriteHeader(&header) | ||
if err != nil { | ||
return ErrCompressToTarGZ(err, "") | ||
} | ||
|
||
_, err = tw.Writer.Write(data) | ||
if err != nil { | ||
return ErrCompressToTarGZ(err, "") | ||
} | ||
return nil | ||
} | ||
|
||
func (tw *TarWriter) Close() { | ||
_ = tw.Writer.Flush() | ||
_ = tw.Writer.Close() | ||
} |
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,69 @@ | ||
package catalog | ||
|
||
type ContainersImage struct { | ||
Name string `yaml:"name,omitempty"` | ||
Image string `yaml:"image,omitempty"` | ||
Whitelisted string `yaml:"whitelisted,omitempty"` | ||
} | ||
|
||
type Link struct { | ||
Name string `yaml:"name,omitempty"` | ||
URL string `yaml:"url,omitempty"` | ||
} | ||
|
||
type Change struct { | ||
Kind string `yaml:"kind,omitempty"` | ||
Description string `yaml:"description,omitempty"` | ||
Links []Link `yaml:"links,omitempty"` | ||
} | ||
|
||
type Maintainer struct { | ||
Name string `yaml:"name,omitempty"` | ||
Email string `yaml:"email,omitempty"` | ||
} | ||
|
||
type Provider struct { | ||
Name string `yaml:"name,omitempty"` | ||
} | ||
|
||
type Recommendation struct { | ||
URL string `yaml:"url,omitempty"` | ||
} | ||
|
||
type Screenshot struct { | ||
Title string `yaml:"title,omitempty"` | ||
URL string `yaml:"url,omitempty"` | ||
} | ||
|
||
type ArtifactHubMetadata struct { | ||
Version string `yaml:"version,omitempty"` | ||
Name string `yaml:"name,omitempty"` | ||
DisplayName string `yaml:"displayName,omitempty"` | ||
CreatedAt string `yaml:"createdAt,omitempty"` | ||
Description string `yaml:"description,omitempty"` | ||
LogoPath string `yaml:"logoPath,omitempty"` | ||
LogoURL string `yaml:"logoURL,omitempty"` | ||
Digest string `yaml:"digest,omitempty"` | ||
License string `yaml:"license,omitempty"` | ||
HomeURL string `yaml:"homeURL,omitempty"` | ||
AppVersion string `yaml:"appVersion,omitempty"` | ||
ContainersImages []ContainersImage `yaml:"containersImages,omitempty"` | ||
ContainsSecurityUpdates string `yaml:"containsSecurityUpdates,omitempty"` | ||
Operator string `yaml:"operator,omitempty"` | ||
Deprecated string `yaml:"deprecated,omitempty"` | ||
Prerelease string `yaml:"prerelease,omitempty"` | ||
Keywords []string `yaml:"keywords,omitempty"` | ||
Links []Link `yaml:"links,omitempty"` | ||
Readme string `yaml:"readme,omitempty"` | ||
Install string `yaml:"install,omitempty"` | ||
Changes []Change `yaml:"changes,omitempty"` | ||
Maintainers []Maintainer `yaml:"maintainers,omitempty"` | ||
Provider Provider `yaml:"provider,omitempty"` | ||
Ignore []string `yaml:"ignore,omitempty"` | ||
Recommendations []Recommendation `yaml:"recommendations,omitempty"` | ||
Screenshots []Screenshot `yaml:"screenshots,omitempty"` | ||
Annotations struct { | ||
Key1 string `yaml:"key1,omitempty"` | ||
Key2 string `yaml:"key2,omitempty"` | ||
} `yaml:"annotations,omitempty"` | ||
} |
Oops, something went wrong.