registry

package
v0.8.65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SVG_WIDTH  = 20
	SVG_HEIGHT = 20
)
View Source
const (

	// DefaultModelTimeout is the default timeout for generating a single model (5 minutes)
	DefaultModelTimeout = 5 * time.Minute
)

Variables

View Source
var (
	ErrAppendToSheetCode          = "meshkit-11302"
	ErrUpdateToSheetCode          = "meshkit-11303"
	ErrGeneratesModelCode         = "meshkit-11305"
	ErrCSVFileNotFoundCode        = "meshkit-11307"
	ErrUpdateComponentsCode       = "meshkit-11308"
	ErrGeneratesComponentCode     = "meshkit-11309"
	ErrUpdateRelationshipFileCode = "meshkit-11310"
	ErrModelTimeoutCode           = "meshkit-11311"
	ErrModelSkippedCode           = "meshkit-11312"
)
View Source
var (
	// global logger variable
	Log logger.Handler
	//global logger error variable
	LogError logger.Handler
)
View Source
var (

	// refers to all cells in the fourth row (explain how is table clulte in ghsset and henc this rang is valid and will not reuire udpate or when it hould require update)
	ComponentsSheetAppendRange = "Components!A4"
	ModelsSheetAppendRange     = "Models!A4"
)
View Source
var (
	GoogleSpreadSheetURL = "https://docs.google.com/spreadsheets/d/"
)
View Source
var RegistrantToModelsMap = make(map[string]map[string]bool)

registrant:model:true/false Tracks if component sheet requires update

View Source
var RegistrantToModelsToComponentsMap = make(map[string]map[string]map[string]bool)

registrant:model:component:true/false Tracks if component sheet requires update

Functions

func AssignDefaultsForCompDefs

func AssignDefaultsForCompDefs(componentDef *component.ComponentDefinition, modelDef *_model.ModelDefinition)

func CloseLogger added in v0.8.64

func CloseLogger()

CloseLogger closes the log file handles opened by SetLogger. This should be called when logging is no longer needed to prevent file handle leaks.

func ConstructRelationshipPath

func ConstructRelationshipPath(modelName, version, defVersion, outputLocation, filename string) (string, error)

func CreateComponentsMetadataAndCreateSVGsForMDStyle

func CreateComponentsMetadataAndCreateSVGsForMDStyle(model ModelCSV, components []ComponentCSV, path, svgDir string) (string, error)

func CreateComponentsMetadataAndCreateSVGsForMDXStyle

func CreateComponentsMetadataAndCreateSVGsForMDXStyle(model ModelCSV, components []ComponentCSV, path, svgDir string) (string, error)

func CreateRelationshipsMetadata

func CreateRelationshipsMetadata(model ModelCSV, relationships []RelationshipCSV) (string, error)

func DownloadCSVAndGetDownloadURL

func DownloadCSVAndGetDownloadURL(sheetURL, csvPath string, spreadsheetID int64) (string, error)

Downloads CSV file using spreadsheet URL

func ErrAppendToSheet

func ErrAppendToSheet(err error, id string) error

func ErrCSVFileNotFound

func ErrCSVFileNotFound(path string) error

func ErrGenerateComponent

func ErrGenerateComponent(err error, modelName, compName string) error

func ErrGenerateModel

func ErrGenerateModel(err error, modelName string) error

func ErrModelSkipped added in v0.8.63

func ErrModelSkipped(modelName, reason string) error

func ErrModelTimeout added in v0.8.63

func ErrModelTimeout(modelName string, timeout time.Duration) error

func ErrUpdateComponent

func ErrUpdateComponent(err error, modelName, compName string) error

func ErrUpdateRelationshipFile

func ErrUpdateRelationshipFile(err error) error

func ErrUpdateToSheet

func ErrUpdateToSheet(err error, id string) error

func GenerateComponentsFromPkg

func GenerateComponentsFromPkg(pkg models.Package, compDirPath string, defVersion string, modelDef _model.ModelDefinition, groupFilter string) (int, int, error)

func GenerateDefsForCoreRegistrant

func GenerateDefsForCoreRegistrant(model ModelCSV, ComponentCSVHelper *ComponentCSVHelper, path string, modelName string) error

For registrants eg: meshery, whose components needs to be directly created by referencing meshery/schemas repo. the sourceURL contains the path of models component definitions

func GenerateModels

func GenerateModels(registrant string, sourceURl string, modelName string) (models.Package, string, error)

func GetCsv

func GetCsv(csvDirectory string) (string, string, string, error)

func GetIndexForRegisterCol

func GetIndexForRegisterCol(cols []string, shouldRegister string) int

func HandleRelationshipFile

func HandleRelationshipFile(filePath string, rel _rel.RelationshipDefinition) (bool, error)

HandleRelationshipFile checks if the file exists and compares its content. It writes the new data only if the file doesn't exist or the contents differ. Returns true if the file was written or updated, false if no changes were made.

func InvokeGenerationFromSheet

func InvokeGenerationFromSheet(wg *sync.WaitGroup, path string, modelsheetID, componentSheetID int64, spreadsheeetID string, modelName string, modelCSVFilePath, componentCSVFilePath, spreadsheeetCred, relationshipCSVFilePath string, relationshipSheetID int64, srv *sheets.Service) error
  1. Sheet Parsing: Parse the three sheets and prepare their respective csvHelper instances.
  2. Registrant-Based Processing: 2.1 Meshery: Use the Meshery components sheet as the source. 2.2 GitHub/ArtifactHub: Perform additional steps, such as determining the registrant type via the URL and generating a package. This package serves as the basis for component generation (refer to the MeshKit function for details). 2.3 File Writing: Write the generated components to their respective paths in the format {model-name/{release-version-in-repo}/defversion/}.
  3. Handling Relationships: Relationships marked with * as the version are written to all versions, with the filenames updated in the sheet.

If their is ever an error with the writing of file back to spreadsheet of column mismatch just update utils.ComponentCSV struct.

func InvokeGenerationFromSheetWithOptions added in v0.8.63

func InvokeGenerationFromSheetWithOptions(wg *sync.WaitGroup, path string, modelsheetID, componentSheetID int64, spreadsheeetID string, modelName string, modelCSVFilePath, componentCSVFilePath, spreadsheeetCred, relationshipCSVFilePath string, relationshipSheetID int64, srv *sheets.Service, opts GenerationOptions) error

InvokeGenerationFromSheetWithOptions generates models from a spreadsheet with configurable options. This is the primary function for model generation with support for: - Per-model timeout (configurable, default 5 minutes) - Progress tracking and callbacks - Latest version only filtering

func ProcessModelToComponentsMap

func ProcessModelToComponentsMap(existingComponents map[string]map[string][]ComponentCSV)

func ProcessRelationships

func ProcessRelationships(relationshipCSVHelper *RelationshipCSVHelper, spreadsheetUpdateChan chan RelationshipCSV, path string)

func RateLimitArtifactHub

func RateLimitArtifactHub()

func SetLogger

func SetLogger(ismultiWriter bool) error

func SetupLogger

func SetupLogger(name string, debugLevel bool, output io.Writer) logger.Handler

Initialize Meshkit Logger instance

func VerifyandUpdateSpreadsheet

func VerifyandUpdateSpreadsheet(cred string, wg *sync.WaitGroup, srv *sheets.Service, spreadsheetUpdateChan chan SpreadsheetData, sheetId, modelCSVFilePath, componentCSVFilePath string)

Verifies if the component entry already exist in the spreadsheet, otherwise updates the spreadshhet to include new component entry.

Types

type ComponentCSV

type ComponentCSV struct {
	Registrant string `json:"registrant" csv:"registrant"`
	Model      string `json:"model" csv:"model"`
	Component  string `json:"component" csv:"component"`
	// Category           category.CategoryDefinitionName   `json:"category" csv:"category"`
	// SubCategory        subcategory.SubCategoryDefinition `json:"subCategory" csv:"subCategory"`
	Description        string `json:"description" csv:"description"`
	Shape              string `json:"shape" csv:"shape"`
	PrimaryColor       string `json:"primaryColor" csv:"primaryColor"`
	SecondaryColor     string `json:"secondaryColor" csv:"secondaryColor"`
	SVGColor           string `json:"svgColor" csv:"svgColor"`
	SVGWhite           string `json:"svgWhite" csv:"svgWhite"`
	SVGComplete        string `json:"svgComplete" csv:"svgComplete"`
	Schema             string `json:"schema" csv:"schema"`
	Docs               string `json:"docs" csv:"docs"`
	StyleOverrides     string `json:"styleOverrides" csv:"styleOverrides"`
	Styles             string `json:"styles" csv:"styles"`
	ShapePolygonPoints string `json:"shapePolygonPoints" csv:"shapePolygonPoints"`
	DefaultData        string `json:"defaultData" csv:"defaultData"`
	Capabilities       string `json:"capabilities" csv:"capabilities"`
	LogoURL            string `json:"logoURL" csv:"logoURL"`
	Genealogy          string `json:"genealogy" csv:"genealogy"`
	IsAnnotation       string `json:"isAnnotation" csv:"isAnnotation"`
	Version            string `json:"version" csv:"version"`

	ModelDisplayName string `json:"modelDisplayName" csv:"-"`

	Status string `json:"status" csv:"status"`
}

func ConvertCompDefToCompCSV

func ConvertCompDefToCompCSV(modelcsv *ModelCSV, compDef component.ComponentDefinition) *ComponentCSV

func (*ComponentCSV) CreateComponentDefinition

func (c *ComponentCSV) CreateComponentDefinition(isModelPublished bool, defVersion string) (component.ComponentDefinition, error)

The Component Definition generated assumes or is only for components which have registrant as "meshery"

func (*ComponentCSV) UpdateCompDefinition

func (c *ComponentCSV) UpdateCompDefinition(compDef *component.ComponentDefinition) error

type ComponentCSVHelper

type ComponentCSVHelper struct {
	SpreadsheetID  int64
	SpreadsheetURL string
	Title          string
	CSVPath        string
	Components     map[string]map[string][]ComponentCSV
}

func NewComponentCSVHelper

func NewComponentCSVHelper(sheetURL, spreadsheetName string, spreadsheetID int64, localCsvPath string) (*ComponentCSVHelper, error)

func (ComponentCSVHelper) Cleanup

func (m ComponentCSVHelper) Cleanup() error

func (*ComponentCSVHelper) GetColumns

func (mch *ComponentCSVHelper) GetColumns() ([]string, error)

func (*ComponentCSVHelper) ParseComponentsSheet

func (mch *ComponentCSVHelper) ParseComponentsSheet(modelName string) error

type GenerationOptions added in v0.8.63

type GenerationOptions struct {
	// ModelTimeout is the timeout duration for generating a single model
	// Default is 5 minutes if not specified
	ModelTimeout time.Duration
	// LatestVersionOnly when true, generates only the latest version of each model
	LatestVersionOnly bool
	// ProgressCallback is called to report generation progress
	// Parameters: currentModel (name), currentIndex (1-based), totalModels
	ProgressCallback func(modelName string, currentIndex, totalModels int)
}

GenerationOptions contains configuration options for model generation

func DefaultGenerationOptions added in v0.8.63

func DefaultGenerationOptions() GenerationOptions

DefaultGenerationOptions returns GenerationOptions with default values

type ModelCSV

type ModelCSV struct {
	Registrant         string                            `json:"registrant" csv:"registrant"`
	ModelDisplayName   string                            `json:"modelDisplayName" csv:"modelDisplayName"`
	Model              string                            `json:"model" csv:"model"`
	Category           category.CategoryDefinitionName   `json:"category" csv:"category"`
	SubCategory        subcategory.SubCategoryDefinition `json:"subCategory" csv:"subCategory"`
	Description        string                            `json:"description" csv:"description"`
	SourceURL          string                            `json:"sourceURL" csv:"sourceURL"`
	Website            string                            `json:"website" csv:"website"`
	Docs               string                            `json:"docs" csv:"docs"`
	Shape              string                            `json:"shape" csv:"shape"`
	PrimaryColor       string                            `json:"primaryColor" csv:"primaryColor"`
	SecondaryColor     string                            `json:"secondaryColor" csv:"secondaryColor"`
	StyleOverrides     string                            `json:"styleOverrides" csv:"styleOverrides"`
	Styles             string                            `json:"styles" csv:"styles"`
	ShapePolygonPoints string                            `json:"shapePolygonPoints" csv:"shapePolygonPoints"`
	DefaultData        string                            `json:"defaultData" csv:"defaultData"`
	Capabilities       string                            `json:"capabilities" csv:"capabilities"`
	LogoURL            string                            `json:"logoURL" csv:"logoURL"`
	SVGColor           string                            `json:"svgColor" csv:"svgColor"`
	SVGWhite           string                            `json:"svgWhite" csv:"svgWhite"`
	SVGComplete        string                            `json:"svgComplete" csv:"svgComplete"`
	IsAnnotation       string                            `json:"isAnnotation" csv:"isAnnotation"`
	PublishToRegistry  string                            `json:"publishToRegistry" csv:"publishToRegistry"`
	Group              string                            `json:"group" csv:"group"`
	AboutProject       string                            `json:"aboutProject" csv:"-"`
	PageSubtTitle      string                            `json:"pageSubtitle" csv:"-"`
	DocsURL            string                            `json:"docsURL" csv:"-"`
	StandardBlurb      string                            `json:"standardBlurb" csv:"-"`
	Feature1           string                            `json:"feature1" csv:"-"`
	Feature2           string                            `json:"feature2" csv:"-"`
	Feature3           string                            `json:"feature3" csv:"-"`
	HowItWorks         string                            `json:"howItWorks" csv:"-"`
	HowItWorksDetails  string                            `json:"howItWorksDetails" csv:"-"`
	Screenshots        string                            `json:"screenshots" csv:"-"`
	FullPage           string                            `json:"fullPage" csv:"-"`
	PublishToSites     string                            `json:"publishToSites" csv:"-"`
}

keep

func (ModelCSV) CreateJSONItem

func (m ModelCSV) CreateJSONItem(iconDir string) string

Creates JSON formatted meshmodel attribute item for JSON Style docs

func (ModelCSV) CreateMarkDownForMDStyle

func (m ModelCSV) CreateMarkDownForMDStyle(componentsMetadata, relationshipMetadata string, componentsCount, relationshipsCount int, outputFor string) string

func (ModelCSV) CreateMarkDownForMDXStyle

func (m ModelCSV) CreateMarkDownForMDXStyle(componentsMetadata string) string

template := `--- title: <model-display-name> subtitle: <Page Subtitle> integrationIcon: ../../../assets/images/service-mesh-icons/aws-app-mesh.svg darkModeIntegrationIcon: ../../../assets/images/service-mesh-icons/aws-app-mesh_white.svg docURL: <Docs URL> category: <Category> subcategory: <Sub-Category> featureList: [<Feature 1>,<Feature 2>,<Feature 3>] workingSlides: [

../_images/meshmap-visualizer.png,
../_images/meshmap-designer.png]

howItWorks: <howItWorks> howItWorksDetails: howItWorksDetails published: <Publish> --- <p>

<About Project>

</p> <p>

<Standard Blurb>

</p>`

func (*ModelCSV) CreateModelDefinition

func (mcv *ModelCSV) CreateModelDefinition(version, defVersion string) _model.ModelDefinition

func (*ModelCSV) UpdateModelDefinition

func (m *ModelCSV) UpdateModelDefinition(modelDef *_model.ModelDefinition) error

keep

type ModelCSVHelper

type ModelCSVHelper struct {
	SpreadsheetID  int64
	SpreadsheetURL string
	Title          string
	CSVPath        string
	Models         []ModelCSV
}

func NewModelCSVHelper

func NewModelCSVHelper(sheetURL, spreadsheetName string, spreadsheetID int64, localCsvPath string) (*ModelCSVHelper, error)

func (ModelCSVHelper) Cleanup

func (m ModelCSVHelper) Cleanup() error

func (*ModelCSVHelper) ParseModelsSheet

func (mch *ModelCSVHelper) ParseModelsSheet(parseForDocs bool, modelName string) error

type ProgressTracker added in v0.8.63

type ProgressTracker struct {
	// contains filtered or unexported fields
}

ProgressTracker tracks model generation progress in a thread-safe manner

func NewProgressTracker added in v0.8.63

func NewProgressTracker(total int) *ProgressTracker

NewProgressTracker creates a new progress tracker with the given total

func (*ProgressTracker) FailureCount added in v0.8.63

func (pt *ProgressTracker) FailureCount() int

FailureCount returns the number of failed model generations

func (*ProgressTracker) IncrementFailure added in v0.8.63

func (pt *ProgressTracker) IncrementFailure()

IncrementFailure increments the failure count

func (*ProgressTracker) IncrementProcessed added in v0.8.63

func (pt *ProgressTracker) IncrementProcessed() int

IncrementProcessed increments the processed count and returns the new value

func (*ProgressTracker) IncrementSkipped added in v0.8.63

func (pt *ProgressTracker) IncrementSkipped()

IncrementSkipped increments the skipped count

func (*ProgressTracker) IncrementSuccess added in v0.8.63

func (pt *ProgressTracker) IncrementSuccess()

IncrementSuccess increments the success count

func (*ProgressTracker) Processed added in v0.8.63

func (pt *ProgressTracker) Processed() int

Processed returns the number of processed models

func (*ProgressTracker) Remaining added in v0.8.63

func (pt *ProgressTracker) Remaining() int

Remaining returns the number of remaining models to process

func (*ProgressTracker) SkippedCount added in v0.8.63

func (pt *ProgressTracker) SkippedCount() int

SkippedCount returns the number of skipped models

func (*ProgressTracker) SuccessCount added in v0.8.63

func (pt *ProgressTracker) SuccessCount() int

SuccessCount returns the number of successfully generated models

func (*ProgressTracker) Total added in v0.8.63

func (pt *ProgressTracker) Total() int

Total returns the total number of models to process

type RelationshipCSV

type RelationshipCSV struct {
	RowIndex          int    `json:"-" csv:"-"`
	Model             string `json:"Model" csv:"Model"`
	Version           string `json:"Version" csv:"Version"`
	KIND              string `json:"kind" csv:"kind"`
	Type              string `json:"type" csv:"type"`
	Status            string `json:"status" csv:"status"`
	SubType           string `json:"subType" csv:"subType"`
	PublishToRegistry string `json:"PublishToRegistry" csv:"PublishToRegistry"`
	Description       string `json:"metadata.description" csv:"metadata.description"`
	IsAnnotation      string `json:"metadata.isAnnotation" csv:"metadata.isAnnotation"`
	Styles            string `json:"metadata.styles" csv:"metadata.styles"`
	EvalPolicy        string `json:"evalPolicy" csv:"evalPolicy"`
	Selector          string `json:"selector" csv:"selector"`
	Filename          string `json:"filename" csv:"filename"`
}

type RelationshipCSVHelper

type RelationshipCSVHelper struct {
	SpreadsheetID        int64
	SpreadsheetURL       string
	Title                string
	CSVPath              string
	Relationships        []RelationshipCSV
	UpdatedRelationships []RelationshipCSV
}

func NewRelationshipCSVHelper

func NewRelationshipCSVHelper(sheetURL, spreadsheetName string, spreadsheetID int64, localCsvPath string) (*RelationshipCSVHelper, error)

func (*RelationshipCSVHelper) ParseRelationshipsSheet

func (mrh *RelationshipCSVHelper) ParseRelationshipsSheet(modelName string) error

func (*RelationshipCSVHelper) UpdateRelationshipSheet

func (mrh *RelationshipCSVHelper) UpdateRelationshipSheet(srv *sheets.Service, cred, sheetId, csvPath string) error

type SpreadsheetData

type SpreadsheetData struct {
	Model      *ModelCSV
	Components []component.ComponentDefinition
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL