Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalvivekm authored Nov 3, 2024
2 parents dd9cbda + 07cf259 commit 9ccf3be
Show file tree
Hide file tree
Showing 428 changed files with 1,469,190 additions and 88,567 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.3.7)
rexml (3.3.9)
rouge (4.4.0)
safe_yaml (1.0.5)
sass-embedded (1.79.3-arm64-darwin)
Expand Down
2 changes: 1 addition & 1 deletion _data/discuss/meshery.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion _includes/extensions/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
<div class="card-inner">
<div class="front">
<div class="chip {{extension.type | upcase }}">
<small class="pattern-type"> {{extension.type | upcase }}</small>
<small class="pattern-type">{{extension.type | upcase }}</small>
</div>
<h4 class="pattern-name">{{extension.name}}</h4>
<div class="pattern-image-container">
{% if extension.status == "coming-soon" %}
<img class="extensions-coming-soon" height="auto" width="auto" src="{{site.baseurl}}/assets/images/coming-soon.png" />
{% endif %}
<img class= "pattern-image"
data-snapshot-light="{{extension.image}}"
data-snapshot-dark="{{extension.image}}"
Expand Down
48 changes: 36 additions & 12 deletions _sass/catalog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ p {
cursor: default;
height: 1.5rem;
outline: none;
padding-left: 5px;
padding-left: 2px;
padding-right: 3px;
font-size: 14px;
font-family: "Open Sans", sans-serif;
white-space: nowrap;
Expand All @@ -245,25 +246,33 @@ p {
text-decoration: none;
justify-content: center;
}
.COLLABORATION {
background-color: var(--brand-color-primary);
color: var(--color-primary-dark);
box-shadow: 0px 1px 5px var(--brand-color-primary);
.chip.COLLABORATION {
background-color: var(--integrations-bg);
box-shadow: 0px 1px 2px var(--integrations-bg);
.pattern-type {
box-shadow: none;
background-color: none;
color: var(--color-secondary-medium);
}
}
.LIFECYCLE {
.chip.LIFECYCLE {
background-color: var(--brand-color-tertiary);
color: var(--color-secondary-dark);
box-shadow: 0px 1px 5px var(--brand-color-tertiary);
box-shadow: 0px 1px 2px var(--brand-color-tertiary);
.pattern-type {
box-shadow: none;
background-color: none;
color: var(--color-secondary-medium);
}
}
.GITOPS {
.chip.GITOPS {
background-color: var(--action-color-dark);
box-shadow: 0px 1px 2px var(--action-color-dark);
color: var(--color-primary-dark);
box-shadow: 0px 1px 5px var(--action-color-dark);
}
.CONFIGURATION {
.chip.CONFIGURATION {
background-color: var(--action-color-light);
box-shadow: 0px 1px 2px var(--action-color-light);
color: var(--color-primary-dark);
box-shadow: 0px 1px 5px var(--action-color-light);
}

.category-label {
Expand Down Expand Up @@ -334,6 +343,21 @@ p {
-ms-transform: translateY(0%) translateX(-0%) rotate(10deg);
-o-transform: translateY(0%) translateX(-0%) rotate(10deg);
}
.extensions-coming-soon {
width: 50%;
height: 50%;
position: relative;
float: right;
z-index: 2;
margin-top: -.5rem;
margin-right: -7rem;
transform: translateY(0%) translateX(0%) rotate(-10deg);
-webkit-transform: translateY(0%) translateX(-0%) rotate(-10deg);
-moz-transform: translateY(0%) translateX(-0%) rotate(-10deg);
-ms-transform: translateY(0%) translateX(-0%) rotate(-10deg);
-o-transform: translateY(0%) translateX(-0%) rotate(-10deg);

}

.hidden {
visibility: hidden;
Expand Down
76 changes: 58 additions & 18 deletions assets/artifact-hub-pkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,13 @@ func main() {
os.Exit(1)
}

catalogPatterns, err := fetchCatalogPatterns()
patterns, err := fetchCatalogPatterns()
if err != nil {
log.Error(err)
return
}

var patterns struct {
Patterns []CatalogPattern `json:"patterns"`
}
if err := json.Unmarshal(catalogPatterns, &patterns); err != nil {
log.Error(utils.ErrUnmarshal(err))
return
}

for _, pattern := range patterns.Patterns {
for _, pattern := range patterns {
if err := processPattern(pattern, token); err != nil {
log.Error(meshkitErrors.New(ErrProcessPatternCode, meshkitErrors.Alert,
[]string{"unable to process catalog pattern"},
Expand All @@ -107,18 +99,46 @@ func slugify(name string) string {

return s
}
func fetchCatalogPatterns() ([]byte, error) {
resp, err := http.Get(fmt.Sprintf("%s/api/catalog/content/pattern", mesheryCloudBaseURL))
func fetchCatalogPatterns() ([]CatalogPattern, error) {
// First request to get total count
resp, err := http.Get(fmt.Sprintf("%s/api/catalog/content/pattern?page=0&pagesize=10", mesheryCloudBaseURL))
if err != nil {
return nil, ErrHTTPGetRequest(err, fmt.Sprintf("%s/api/catalog/content/pattern", mesheryCloudBaseURL))
return nil, ErrHTTPGetRequest(err, fmt.Sprintf("%s/api/catalog/content/pattern?page=0&pagesize=10", mesheryCloudBaseURL))
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
var initialResponse struct {
TotalCount int `json:"total_count"`
Patterns []CatalogPattern `json:"patterns"`
}
if err := json.NewDecoder(resp.Body).Decode(&initialResponse); err != nil {
return nil, ErrReadRespBody(err)
}
return body, nil

totalPages := (initialResponse.TotalCount + 9) / 10 // Calculate number of pages (rounding up)

// Store all patterns from all pages
allPatterns := initialResponse.Patterns

// Fetch patterns from remaining pages
for page := 1; page <= totalPages; page++ {
resp, err := http.Get(fmt.Sprintf("%s/api/catalog/content/pattern?page=%d&pagesize=10", mesheryCloudBaseURL, page))
if err != nil {
return nil, ErrHTTPGetRequest(err, fmt.Sprintf("%s/api/catalog/content/pattern?page=%d&pagesize=10", mesheryCloudBaseURL, page))
}
defer resp.Body.Close()

var pageResponse struct {
Patterns []CatalogPattern `json:"patterns"`
}
if err := json.NewDecoder(resp.Body).Decode(&pageResponse); err != nil {
return nil, ErrReadRespBody(err)
}

allPatterns = append(allPatterns, pageResponse.Patterns...)
}

return allPatterns, nil
}

func processPattern(pattern CatalogPattern, token string) error {
Expand Down Expand Up @@ -209,10 +229,30 @@ func decodeURIComponent(encodedURI string) (string, error) {

func writePatternFile(pattern CatalogPattern, versionDir, patternType, patternInfo, patternCaveats, compatibility, patternImageURL string) error {
designFilePath := filepath.Join(versionDir, "design.yml")
if err := ioutil.WriteFile(designFilePath, []byte(pattern.PatternFile), 0644); err != nil {
return utils.ErrWriteFile(err, designFilePath)

var dataJson map[string]interface{}
if err := json.Unmarshal([]byte(pattern.PatternFile), &dataJson); err != nil {
// If JSON unmarshalling fails, try YAML unmarshalling
if yamlErr := yaml.Unmarshal([]byte(pattern.PatternFile), &dataJson); yamlErr != nil {
// Write faulty content to a file for debugging if both unmarshalling attempts fail
faultyFilePath := filepath.Join(versionDir, "faulty_pattern.yaml")
if writeErr := ioutil.WriteFile(faultyFilePath, []byte(pattern.PatternFile), 0644); writeErr != nil {
return fmt.Errorf("failed to write faulty data to file: %v", writeErr)
}
return fmt.Errorf("failed to unmarshal as JSON or YAML: %v; faulty data saved to %s", yamlErr, faultyFilePath)
}
}

// Step 2: Marshal the data into YAML format
yamlData, err := yaml.Marshal(dataJson)
if err != nil {
return fmt.Errorf("failed to marshal data to YAML: %v", err)
}

// Step 3: Write the YAML data to the file
if err := ioutil.WriteFile(designFilePath, yamlData, 0644); err != nil {
return utils.ErrWriteFile(err, designFilePath)
}
contenttemp, err := ioutil.ReadFile(designFilePath)
if err != nil {
return utils.ErrReadFile(err, designFilePath)
Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions assets/images/logos/meshsync-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/logos/meshsync.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9ccf3be

Please sign in to comment.