Documentation
¶
Index ¶
- Constants
- Variables
- func AssignDefaultsForCompDefs(componentDef *component.ComponentDefinition, modelDef *_model.ModelDefinition)
- func CloseLogger()
- func ConstructRelationshipPath(modelName, version, defVersion, outputLocation, filename string) (string, error)
- func CreateComponentsMetadataAndCreateSVGsForMDStyle(model ModelCSV, components []ComponentCSV, path, svgDir string) (string, error)
- func CreateComponentsMetadataAndCreateSVGsForMDXStyle(model ModelCSV, components []ComponentCSV, path, svgDir string) (string, error)
- func CreateRelationshipsMetadata(model ModelCSV, relationships []RelationshipCSV) (string, error)
- func DownloadCSVAndGetDownloadURL(sheetURL, csvPath string, spreadsheetID int64) (string, error)
- func ErrAppendToSheet(err error, id string) error
- func ErrCSVFileNotFound(path string) error
- func ErrGenerateComponent(err error, modelName, compName string) error
- func ErrGenerateModel(err error, modelName string) error
- func ErrModelSkipped(modelName, reason string) error
- func ErrModelTimeout(modelName string, timeout time.Duration) error
- func ErrUpdateComponent(err error, modelName, compName string) error
- func ErrUpdateRelationshipFile(err error) error
- func ErrUpdateToSheet(err error, id string) error
- func GenerateComponentsFromPkg(pkg models.Package, compDirPath string, defVersion string, ...) (int, int, error)
- func GenerateDefsForCoreRegistrant(model ModelCSV, ComponentCSVHelper *ComponentCSVHelper, path string, ...) error
- func GenerateModels(registrant string, sourceURl string, modelName string) (models.Package, string, error)
- func GetCsv(csvDirectory string) (string, string, string, error)
- func GetIndexForRegisterCol(cols []string, shouldRegister string) int
- func HandleRelationshipFile(filePath string, rel _rel.RelationshipDefinition) (bool, error)
- func InvokeGenerationFromSheet(wg *sync.WaitGroup, path string, modelsheetID, componentSheetID int64, ...) error
- func InvokeGenerationFromSheetWithOptions(wg *sync.WaitGroup, path string, modelsheetID, componentSheetID int64, ...) error
- func ProcessModelToComponentsMap(existingComponents map[string]map[string][]ComponentCSV)
- func ProcessRelationships(relationshipCSVHelper *RelationshipCSVHelper, ...)
- func RateLimitArtifactHub()
- func SetLogger(ismultiWriter bool) error
- func SetupLogger(name string, debugLevel bool, output io.Writer) logger.Handler
- func VerifyandUpdateSpreadsheet(cred string, wg *sync.WaitGroup, srv *sheets.Service, ...)
- type ComponentCSV
- type ComponentCSVHelper
- type GenerationOptions
- type ModelCSV
- func (m ModelCSV) CreateJSONItem(iconDir string) string
- func (m ModelCSV) CreateMarkDownForMDStyle(componentsMetadata, relationshipMetadata string, ...) string
- func (m ModelCSV) CreateMarkDownForMDXStyle(componentsMetadata string) string
- func (mcv *ModelCSV) CreateModelDefinition(version, defVersion string) _model.ModelDefinition
- func (m *ModelCSV) UpdateModelDefinition(modelDef *_model.ModelDefinition) error
- type ModelCSVHelper
- type ProgressTracker
- func (pt *ProgressTracker) FailureCount() int
- func (pt *ProgressTracker) IncrementFailure()
- func (pt *ProgressTracker) IncrementProcessed() int
- func (pt *ProgressTracker) IncrementSkipped()
- func (pt *ProgressTracker) IncrementSuccess()
- func (pt *ProgressTracker) Processed() int
- func (pt *ProgressTracker) Remaining() int
- func (pt *ProgressTracker) SkippedCount() int
- func (pt *ProgressTracker) SuccessCount() int
- func (pt *ProgressTracker) Total() int
- type RelationshipCSV
- type RelationshipCSVHelper
- type SpreadsheetData
Constants ¶
const ( SVG_WIDTH = 20 SVG_HEIGHT = 20 )
const ( // DefaultModelTimeout is the default timeout for generating a single model (5 minutes) DefaultModelTimeout = 5 * time.Minute )
Variables ¶
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" )
var ( // global logger variable Log logger.Handler //global logger error variable LogError logger.Handler )
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" )
var (
GoogleSpreadSheetURL = "https://docs.google.com/spreadsheets/d/"
)
var RegistrantToModelsMap = make(map[string]map[string]bool)
registrant:model:true/false Tracks if component sheet requires update
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 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 ¶
Downloads CSV file using spreadsheet URL
func ErrAppendToSheet ¶
func ErrCSVFileNotFound ¶
func ErrGenerateComponent ¶
func ErrGenerateModel ¶
func ErrModelSkipped ¶ added in v0.8.63
func ErrModelTimeout ¶ added in v0.8.63
func ErrUpdateComponent ¶
func ErrUpdateToSheet ¶
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 GetIndexForRegisterCol ¶
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
- Sheet Parsing: Parse the three sheets and prepare their respective csvHelper instances.
- 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/}.
- 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 SetupLogger ¶
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 ¶
Creates JSON formatted meshmodel attribute item for JSON Style docs
func (ModelCSV) CreateMarkDownForMDStyle ¶
func (ModelCSV) CreateMarkDownForMDXStyle ¶
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
}