coverage

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIndex

func GetIndex(indexFilePath string) (*azidx.Index, error)

func GetIndexFromLocalDir

func GetIndexFromLocalDir(swaggerRepo, indexFilePath string) (*azidx.Index, error)

func IsPathKeyMatchWithResourceId added in v0.15.0

func IsPathKeyMatchWithResourceId(pathKey, resourceId string) bool

func MockResourceIDFromType

func MockResourceIDFromType(azapiResourceType string) (string, string)

func SchemaNamePathFromRef

func SchemaNamePathFromRef(swaggerPath string, ref openapiSpec.Ref) (schemaName string, schemaPath string)

Types

type CoverageItem added in v0.15.0

type CoverageItem struct {
	ApiPath     string
	DisplayName string
	Model       *Model
}

type CoverageReport

type CoverageReport struct {
	Coverages map[string]*CoverageItem
}

func NewOperationPropertiesCoverageReport added in v0.15.0

func NewOperationPropertiesCoverageReport(traceDir string, swaggerPath string) (*CoverageReport, error)

func (*CoverageReport) AddCoverageFromState

func (c *CoverageReport) AddCoverageFromState(resourceId, resourceType string, jsonBody map[string]interface{}, swaggerPath string) error

func (*CoverageReport) MarkdownContent added in v0.15.0

func (c *CoverageReport) MarkdownContent() string

func (*CoverageReport) MarkdownContentCompact added in v0.15.0

func (c *CoverageReport) MarkdownContentCompact() string

type Model

type Model struct {
	Bool                    *map[string]bool   `json:"Bool,omitempty"` // key is the Enum value, value is coverage status
	BoolCoveredCount        int                `json:"BoolCoveredCount,omitempty"`
	CoveredCount            int                `json:"CoveredCount,omitempty"`
	Discriminator           *string            `json:"Discriminator,omitempty"`
	Enum                    *map[string]bool   `json:"Enum,omitempty"` // key is the Enum value, value is coverage status
	EnumCoveredCount        int                `json:"EnumCoveredCount,omitempty"`
	EnumTotalCount          int                `json:"EnumTotalCount,omitempty"`
	Format                  *string            `json:"Format,omitempty"`
	HasAdditionalProperties bool               `json:"HasAdditionalProperties,omitempty"`
	Identifier              string             `json:"Identifier,omitempty"` // e.g., #.properties.accessPolicies[].permissions.certificates
	IsAnyCovered            bool               `json:"IsAnyCovered"`
	IsFullyCovered          bool               `json:"IsFullyCovered,omitempty"`
	IsReadOnly              bool               `json:"IsReadOnly,omitempty"`
	IsRequired              bool               `json:"IsRequired,omitempty"`
	IsRoot                  bool               `json:"IsRoot,omitempty"`
	IsSecret                bool               `json:"IsSecret,omitempty"` // related to x-ms-secret
	Item                    *Model             `json:"Item,omitempty"`
	ModelName               string             `json:"ModelName,omitempty"`
	Properties              *map[string]*Model `json:"Properties,omitempty"`
	RootCoveredCount        int                `json:"RootCoveredCount,omitempty"` // only for root model, covered count plus all variant count if any
	RootTotalCount          int                `json:"RootTotalCount,omitempty"`   // only for root model, total count plus all variant count if any
	SourceFile              string             `json:"SourceFile,omitempty"`
	TotalCount              int                `json:"TotalCount,omitempty"`
	Type                    *string            `json:"Type,omitempty"`
	Variants                *map[string]*Model `json:"Variants,omitempty"`    // variant model name is used as key, in case x-ms-discriminator-value is not available
	VariantType             *string            `json:"VariantType,omitempty"` // the x-ms-discriminator-value of the variant model if exists, otherwise model name
}

func Expand

func Expand(modelName, swaggerPath string) (*Model, error)

func (*Model) CountCoverage

func (m *Model) CountCoverage() (int, int)

func (*Model) CredScan

func (m *Model) CredScan(root interface{}, secrets map[string]string)

CredScan scans the input payload (root) and extract the secret field and value in the secrets map.

func (*Model) MarkCovered

func (m *Model) MarkCovered(root interface{})

func (*Model) SplitCovered

func (m *Model) SplitCovered(covered, uncovered *[]string)

type SwaggerModel

type SwaggerModel struct {
	ApiPath     string
	ModelName   string
	SwaggerPath string
	OperationID string
}

func GetModelInfoFromIndex

func GetModelInfoFromIndex(resourceId, apiVersion, method, indexFilePath string) (*SwaggerModel, error)

GetModelInfoFromIndex will try to download online index from https://github.com/teowa/azure-rest-api-index-file, and get model info from it if the index is already downloaded as in {indexFilePath}, it will use the cached index

func GetModelInfoFromIndexRef

func GetModelInfoFromIndexRef(ref openapispec.Ref, swaggerRepo string) (*SwaggerModel, error)

func GetModelInfoFromIndexWithType

func GetModelInfoFromIndexWithType(azapiResourceType, method, indexCacheFile string) (*SwaggerModel, error)

func GetModelInfoFromLocalDir

func GetModelInfoFromLocalDir(resourceId, swaggerPath string, method string) (*SwaggerModel, error)

func GetModelInfoFromLocalIndex

func GetModelInfoFromLocalIndex(resourceId, apiVersion, method, swaggerRepo, indexCacheFile string) (*SwaggerModel, error)

GetModelInfoFromLocalIndex tries to build index from local swagger repo and get model info from it

func GetModelInfoFromLocalSpecFile

func GetModelInfoFromLocalSpecFile(resourceId, swaggerPath string, method string) (*SwaggerModel, error)

Jump to

Keyboard shortcuts

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