generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from MUzairS15/MUzairS15/artifacthub-pkg
Add support for generating pkg file.
- Loading branch information
Showing
7 changed files
with
180 additions
and
8 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
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
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"` | ||
} |
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,55 @@ | ||
package catalog | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/layer5io/meshkit/models/catalog/v1beta1" | ||
) | ||
|
||
func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, catalogData *v1beta1.CatalogData) *ArtifactHubMetadata { | ||
artifacthubPkg := &ArtifactHubMetadata{ | ||
Name: name, | ||
Description: catalogData.PatternInfo, | ||
Provider: Provider{ | ||
Name: user, | ||
}, | ||
Links: []Link{ | ||
{ | ||
Name: "download", | ||
URL: downloadURL, // this depends on where the design is stored by the user, we can give remote provider URL otherwise | ||
}, | ||
{ | ||
Name: "Meshery Catalog", | ||
URL: "https://meshery.io/catalog", | ||
}, | ||
}, | ||
HomeURL: "https://docs.meshery.io/concepts/logical/designs", | ||
Version: version, | ||
CreatedAt: createdAt, | ||
License: "Apache-2.0", | ||
LogoURL: "https://raw.githubusercontent.com/meshery/meshery.io/0b8585231c6e2b3251d38f749259360491c9ee6b/assets/images/brand/meshery-logo.svg", | ||
Install: "mesheryctl design import -f", | ||
Readme: fmt.Sprintf("%s \n ##h4 Caveats and Consideration \n", catalogData.PatternCaveats), | ||
} | ||
|
||
if len(catalogData.SnapshotURL) > 0 { | ||
artifacthubPkg.Screenshots = append(artifacthubPkg.Screenshots, Screenshot{ | ||
Title: "MeshMap Snapshot", | ||
URL: catalogData.SnapshotURL[0], | ||
}) | ||
|
||
if len(catalogData.SnapshotURL) > 1 { | ||
artifacthubPkg.Screenshots = append(artifacthubPkg.Screenshots, Screenshot{ | ||
Title: "MeshMap Snapshot", | ||
URL: catalogData.SnapshotURL[1], | ||
}) | ||
} | ||
} | ||
|
||
artifacthubPkg.Screenshots = append(artifacthubPkg.Screenshots, Screenshot{ | ||
Title: "Meshery Project", | ||
URL: "https://raw.githubusercontent.com/meshery/meshery.io/master/assets/images/logos/meshery-gradient.png", | ||
}) | ||
|
||
return artifacthubPkg | ||
} |
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