models

package
v0.0.0-...-4d495be Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuperAdminRole        = "api-insights-admin"
	SuperAdminServiceRole = "api-insights-admin-service"

	// RoleTypeOrgAdmin role type represents roles that can manage other users and services of an org.
	RoleTypeOrgAdmin RoleType = "org-admin"
	// RoleTypeOrgDeveloper role type represents roles that can upload specs and view services of an org.
	RoleTypeOrgDeveloper RoleType = "org-developer"
)
View Source
const (
	ResourceActionCreate ResourceAction = "create"
	ResourceActionUpdate ResourceAction = "update"
	ResourceActionDelete ResourceAction = "delete"
	ResourceActionGet    ResourceAction = "get"
	ResourceActionList   ResourceAction = "list"

	ResourceKindOrganizations ResourceKind = "organizations"
	ResourceKindOrganization  ResourceKind = "organization"
	ResourceKindServices      ResourceKind = "services"
	ResourceKindService       ResourceKind = "service"
	ResourceKindSpecs         ResourceKind = "specs"
	ResourceKindSpec          ResourceKind = "spec"
)
View Source
const (
	ServiceTableName         = "services"
	ServiceVisibilityPublic  = "public"
	ServiceVisibilityPrivate = "private"
)
View Source
const (
	OrganizationTableName = "organizations"
)
View Source
const (
	SpecAnalysisTableName = "spec_analyses"
)
View Source
const (
	SpecDiffTableName = "spec_diffs"
)
View Source
const (
	SpecTableName = "specs"
)

Variables

View Source
var (
	MatchRoleTypeOrgAdmin            = func(s string) bool { return roleTypeOrgAdminRegexp.MatchString(s) }
	MatchRoleTypeOrgDeveloper        = func(s string) bool { return roleTypeOrgDeveloperRegexp.MatchString(s) }
	MatchRoleTypeOrgAdminService     = func(s string) bool { return roleTypeOrgAdminServiceRegexp.MatchString(s) }
	MatchRoleTypeOrgDeveloperService = func(s string) bool { return roleTypeOrgDeveloperServiceRegexp.MatchString(s) }
)
View Source
var (
	ErrResourceIDExpected = errors.New("access: resource ID expected")
)

Functions

func Flags

func Flags() []cli.Flag

Types

type AccessDataFilters

type AccessDataFilters []interface{}

type AnalyzerConfigMap

type AnalyzerConfigMap map[analyzer.SpecAnalyzer]analyzer.Config

func (*AnalyzerConfigMap) Merge

func (m *AnalyzerConfigMap) Merge(with AnalyzerConfigMap)

func (*AnalyzerConfigMap) Scan

func (m *AnalyzerConfigMap) Scan(value interface{}) error

Scan implements sql.Scanner interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

func (AnalyzerConfigMap) Value

func (m AnalyzerConfigMap) Value() (driver.Value, error)

Value implements driver.Valuer interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

type AuthInfo

type AuthInfo struct {
	Enabled bool `json:"enabled"`
}

type Contact

type Contact struct{ openapi3.Contact }

func (*Contact) Scan

func (m *Contact) Scan(value interface{}) error

Scan implements sql.Scanner interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

func (*Contact) Value

func (m *Contact) Value() (driver.Value, error)

Value implements driver.Valuer interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

type Info

type Info struct {
	Auth AuthInfo `json:"auth"`
}

Info contains various runtime server info

type ModelObject

type ModelObject interface {
	GetID() string
	String() string
	GetIndex(field string) string
	GetIndexes() map[string]string
	GetIndexValue(field string) string
	GetIndexValues() map[string]string

	Sortable(field string) bool
	SortableFields() map[string]struct{}
}

ModelObject defines the interface of a model

type OrgAccessFilter

type OrgAccessFilter struct {
	// AccessibleOrganizationIDs contains a list of OrganizationIDs that are authorized to the user for all operations.
	AccessibleOrganizationIDs []string
}

type OrgServiceAccessDataFilter

type OrgServiceAccessDataFilter struct {
	OrgAccessFilter     *OrgAccessFilter
	ServiceAccessFilter *ServiceAccessFilter
}

func NewOrgServiceAccessFilter

func NewOrgServiceAccessFilter() *OrgServiceAccessDataFilter

func (OrgServiceAccessDataFilter) CanCreateOrg

func (f OrgServiceAccessDataFilter) CanCreateOrg(orgID string) (bool, error)

func (OrgServiceAccessDataFilter) CanCreateService

func (f OrgServiceAccessDataFilter) CanCreateService(orgID string) (bool, error)

func (OrgServiceAccessDataFilter) CanListOrgs

func (f OrgServiceAccessDataFilter) CanListOrgs() (authorized bool, orgIDs []string, err error)

func (OrgServiceAccessDataFilter) CanListServices

func (f OrgServiceAccessDataFilter) CanListServices() (authorized bool, orgIDs []string, err error)

type Organization

type Organization struct {
	ID          string            `json:"id,omitempty" gorm:"column:id;primaryKey"`
	NameID      string            `json:"name_id" gorm:"column:name_id;unique;index"`
	Title       string            `json:"title" gorm:"column:title"`
	Description string            `json:"description" gorm:"column:description"`
	Meta        datatypes.JSONMap `json:"meta" gorm:"column:meta"`
	Contact     *Contact          `json:"contact" gorm:"column:contact"`
	CreatedAt   time.Time         `json:"created_at" gorm:"column:created_at"`
	UpdatedAt   time.Time         `json:"updated_at" gorm:"column:updated_at"`

	Roles
}

Organization represents an organization

func (*Organization) BeforeCreate

func (m *Organization) BeforeCreate(tx *gorm.DB) (err error)

func (*Organization) BeforeSave

func (m *Organization) BeforeSave(tx *gorm.DB) (err error)

func (*Organization) GetID

func (m *Organization) GetID() string

GetID returns the ID of analyzer object

func (*Organization) GetIndex

func (m *Organization) GetIndex(field string) string

GetIndex returns an index for specific field

func (*Organization) GetIndexValue

func (m *Organization) GetIndexValue(field string) string

GetIndexValue return index value for specified field

func (*Organization) GetIndexValues

func (m *Organization) GetIndexValues() map[string]string

GetIndexValues return all field index values

func (*Organization) GetIndexes

func (m *Organization) GetIndexes() map[string]string

GetIndexes returns all the field indexes

func (*Organization) GetTags

func (m *Organization) GetTags() []string

GetTags returns all the tags

func (*Organization) Sortable

func (m *Organization) Sortable(field string) bool

Sortable checks if field is sortable.

func (*Organization) SortableFields

func (m *Organization) SortableFields() map[string]struct{}

SortableFields returns all sortable fields

func (*Organization) String

func (m *Organization) String() string

String returns the text representation of analyzer object

func (*Organization) TableName

func (m *Organization) TableName() string

TableName implements gorm Tabler interface

type OrganizationPatch

type OrganizationPatch struct {
	NameID      *string            `json:"name_id"`
	Title       *string            `json:"title"`
	Description *string            `json:"description"`
	Meta        *datatypes.JSONMap `json:"meta"`
	Contact     *Contact           `json:"contact"`
	*Roles
}

OrganizationPatch represents a service with patchable fields.

type Pagination

type Pagination struct {
	Total      int `json:"total"`
	TotalPages int `json:"total_pages"`
	PageSize   int `json:"page_size"`
	PageNum    int `json:"current_page"`
}

Pagination represents pagination arguments

type Resource

type Resource struct {
	Kind           ResourceKind
	Action         ResourceAction
	ID             *string
	Subresource    *Resource
	IsRootResource bool
	IsSubresource  bool
}

func NewResourceFromReq

func NewResourceFromReq(req *restful.Request) *Resource

func (Resource) IsCreateOrganization

func (r Resource) IsCreateOrganization() bool

func (Resource) IsCreateService

func (r Resource) IsCreateService() bool

func (Resource) IsDeleteOrganization

func (r Resource) IsDeleteOrganization() bool

func (Resource) IsDeleteService

func (r Resource) IsDeleteService() bool

func (Resource) IsGetOrganization

func (r Resource) IsGetOrganization() bool

func (Resource) IsGetService

func (r Resource) IsGetService() bool

func (Resource) IsListOrganizations

func (r Resource) IsListOrganizations() bool

func (Resource) IsListServices

func (r Resource) IsListServices() bool

func (Resource) IsReadOnlyAction

func (r Resource) IsReadOnlyAction() bool

func (Resource) IsSpec

func (r Resource) IsSpec() bool

func (Resource) IsSpecs

func (r Resource) IsSpecs() bool

func (Resource) IsUpdateOrganization

func (r Resource) IsUpdateOrganization() bool

func (Resource) IsUpdateService

func (r Resource) IsUpdateService() bool

type ResourceAction

type ResourceAction string

ResourceAction specifies a performable action on a ResourceKind, e.g. create, update, delete, get, list.

type ResourceKind

type ResourceKind string

ResourceKind specifies a resource object, e.g. organization, service.

type RoleType

type RoleType string

RoleType represents an organization role type

type Roles

type Roles struct {
	Roles datatypes.JSONMap `json:"roles" gorm:"column:roles"`
	// contains filtered or unexported fields
}

Roles represents organization roles

func NewOrganizationRoles

func NewOrganizationRoles() Roles

func (*Roles) AddOrgAdminRole

func (r *Roles) AddOrgAdminRole(role string)

func (*Roles) AddOrgDeveloperRole

func (r *Roles) AddOrgDeveloperRole(role string)

func (*Roles) OrgAdminRoleSet

func (r *Roles) OrgAdminRoleSet() map[string]struct{}

func (*Roles) OrgDeveloperRoleSet

func (r *Roles) OrgDeveloperRoleSet() map[string]struct{}

func (*Roles) RoleTypeSetMap

func (r *Roles) RoleTypeSetMap() map[RoleType]map[string]struct{}

type Service

type Service struct {
	ID             string            `json:"id,omitempty" gorm:"column:id;primaryKey"`
	AdditionalInfo datatypes.JSONMap `json:"additional_info" gorm:"column:additional_info"`
	Contact        *Contact          `json:"contact" gorm:"column:contact"`
	Description    string            `json:"description" gorm:"column:description"`
	NameID         string            `json:"name_id" gorm:"column:name_id;unique;index"`
	OrganizationID string            `json:"organization_id" gorm:"column:organization_id;index"`
	ProductTag     string            `json:"product_tag" gorm:"column:product_tag;index"`
	Title          string            `json:"title" gorm:"column:title"`
	Visibility     string            `json:"visibility" gorm:"column:visibility;index"`
	CreatedAt      time.Time         `json:"created_at" gorm:"column:created_at"`
	UpdatedAt      time.Time         `json:"updated_at" gorm:"column:updated_at"`

	AnalyzersConfigs AnalyzerConfigMap `json:"analyzers_configs,omitempty" gorm:"column:analyzers_configs"`

	Summary *ServiceSummary `json:"summary" gorm:"column:summary"`
}

Service represents a service

func (*Service) BeforeCreate

func (m *Service) BeforeCreate(tx *gorm.DB) (err error)

func (*Service) BeforeSave

func (m *Service) BeforeSave(tx *gorm.DB) (err error)

func (*Service) GetID

func (m *Service) GetID() string

GetID returns the ID of service object

func (*Service) GetIndex

func (m *Service) GetIndex(field string) string

GetIndex returns an index for specific field

func (*Service) GetIndexValue

func (m *Service) GetIndexValue(field string) string

GetIndexValue return index value for specified field

func (*Service) GetIndexValues

func (m *Service) GetIndexValues() map[string]string

GetIndexValues return all field index values

func (*Service) GetIndexes

func (m *Service) GetIndexes() map[string]string

GetIndexes returns all the field indexes

func (*Service) GetNameID

func (m *Service) GetNameID(name analyzer.SpecAnalyzer, analyzerCfg analyzer.Config) string

GetNameID retrieves the service name ID, using the following precedence, from:

func (*Service) GetTags

func (m *Service) GetTags() []string

GetTags returns all the tags

func (*Service) SetSummary

func (m *Service) SetSummary(score int, version string, revision string, updatedAt time.Time)

func (*Service) Sortable

func (m *Service) Sortable(field string) bool

Sortable checks if field is sortable.

func (*Service) SortableFields

func (m *Service) SortableFields() map[string]struct{}

SortableFields returns all sortable fields

func (*Service) String

func (m *Service) String() string

String returns the text representation of service object

func (*Service) TableName

func (m *Service) TableName() string

TableName implements gorm Tabler interface

type ServiceAccessFilter

type ServiceAccessFilter struct {
	// AccessibleOrganizationIDs contains a list of OrganizationIDs that are authorized to the user for creating & listing.
	AccessibleOrganizationIDs []string
}

type ServicePatch

type ServicePatch struct {
	AdditionalInfo   *datatypes.JSONMap `json:"additional_info"`
	Contact          *Contact           `json:"contact"`
	Description      *string            `json:"description"`
	NameID           *string            `json:"name_id"`
	OrganizationID   *string            `json:"organization_id"`
	ProductTag       *string            `json:"product_tag"`
	Title            *string            `json:"title"`
	AnalyzersConfigs *AnalyzerConfigMap `json:"analyzers_configs"`
	Visibility       *string            `json:"visibility"`
}

ServicePatch represents a service with patchable fields.

type ServiceResponse

type ServiceResponse struct {
	Pagination
	Data []Service `json:"data"`
}

ServiceResponse wrappers service response

type ServiceSummary

type ServiceSummary struct {
	Score     *int      `json:"score" gorm:"column:score"`
	Version   string    `json:"version" gorm:"column:version"`
	Revision  string    `json:"revision" gorm:"column:revision"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
}

func (*ServiceSummary) Scan

func (m *ServiceSummary) Scan(value interface{}) error

Scan implements sql.Scanner interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

func (ServiceSummary) Value

func (m ServiceSummary) Value() (driver.Value, error)

Value implements driver.Valuer interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.

type Spec

type Spec struct {
	ID            string    `json:"id,omitempty" gorm:"primaryKey"`
	Doc           SpecDoc   `json:"doc" gorm:"column:doc"`
	DocCompressed []byte    `json:"-" gorm:"column:doc_compressed"`
	DocType       string    `json:"doc_type" gorm:"column:doc_type"`
	Revision      string    `json:"revision" gorm:"column:revision;index"`
	Score         *int      `json:"score" gorm:"column:score"`
	ServiceID     string    `json:"service_id" gorm:"column:service_id;index"`
	State         string    `json:"state" gorm:"column:state;index"` // Archive, Release, Development, Latest
	Valid         string    `json:"valid" gorm:"column:valid"`
	Version       string    `json:"version" gorm:"column:version;index"`
	CreatedAt     time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt     time.Time `json:"updated_at" gorm:"column:updated_at"`

	DocOAS *openapi3.T `json:"-" gorm:"-"`
	// contains filtered or unexported fields
}

Spec represents a spec

func (*Spec) AfterFind

func (m *Spec) AfterFind(tx *gorm.DB) (err error)

AfterFind is a hook called after querying by GORM (https://gorm.io/docs/hooks.html). For handling large Spec.Doc(s), if Spec.DocCompressed contains the compression, decompresses it back into Spec.Doc.

func (*Spec) AfterSave

func (m *Spec) AfterSave(tx *gorm.DB) (err error)

AfterSave is a hook called after creation by GORM (https://gorm.io/docs/hooks.html). For handling large Spec.Doc(s), resets the temporary staging of Spec.Doc.

func (*Spec) BeforeCreate

func (m *Spec) BeforeCreate(tx *gorm.DB) (err error)

func (*Spec) BeforeSave

func (m *Spec) BeforeSave(tx *gorm.DB) (err error)

BeforeSave is a hook called before creation by GORM (https://gorm.io/docs/hooks.html). For handling large Spec.Doc(s), compressData conditionally compresses Spec.Doc into Spec.DocCompressed.

func (*Spec) GetDocAsMap

func (m *Spec) GetDocAsMap() (docMap map[string]interface{}, isJSON bool, err error)

GetDocAsMap unmarshals Spec.Doc into a map by first parsing as a JSON & if that fails, as a YAML.

func (*Spec) GetID

func (m *Spec) GetID() string

GetID returns the ID of spec object

func (*Spec) GetIndex

func (m *Spec) GetIndex(field string) string

GetIndex returns an index for specific field

func (*Spec) GetIndexValue

func (m *Spec) GetIndexValue(field string) string

GetIndexValue return index value for specified field

func (*Spec) GetIndexValues

func (m *Spec) GetIndexValues() map[string]string

GetIndexValues return all field index values

func (*Spec) GetIndexes

func (m *Spec) GetIndexes() map[string]string

GetIndexes returns all the field indexes

func (*Spec) GetTags

func (m *Spec) GetTags() []string

GetTags returns all the tags

func (*Spec) LoadDocAsOAS

func (m *Spec) LoadDocAsOAS(ctx context.Context, validate, setDocType, setVersion bool) (*openapi3.T, error)

LoadDocAsOAS loads Spec.Doc as an OpenAPI spec & stores it as Spec.DocOAS. Set validate to validate Spec.DocOAS. Set setDocType to derive Spec.DocType from Spec.DocOAS.Version. Set setVersion to derive Spec.Version from Spec.DocOAS.Info.Version.

func (*Spec) Sortable

func (m *Spec) Sortable(field string) bool

Sortable checks if field is sortable.

func (*Spec) SortableFields

func (m *Spec) SortableFields() map[string]struct{}

SortableFields returns all sortable fields

func (*Spec) String

func (m *Spec) String() string

String returns the text representation of spec object

func (*Spec) TableName

func (m *Spec) TableName() string

TableName implements gorm Tabler interface

type SpecAnalysis

type SpecAnalysis struct {
	ID       string                `json:"id,omitempty" gorm:"column:id;primaryKey"`
	Analyzer analyzer.SpecAnalyzer `json:"analyzer" gorm:"column:analyzer;index"`

	SpecAnalysisConfig
	SpecAnalysisResult

	Score     *int      `json:"score" gorm:"column:score"`
	ServiceID string    `json:"service_id" gorm:"column:service_id;index:svc_spec_created_idx;index:svc_created_idx"`
	SpecID    string    `json:"spec_id" gorm:"column:spec_id;index;index:svc_spec_created_idx"`
	Status    string    `json:"status" gorm:"column:status;index"` // Submitted, Invalid, Analyzed
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at;index:svc_spec_created_idx;index:svc_created_idx"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
}

SpecAnalysis represents a specAnalysis

func DistinctSpecAnalyses

func DistinctSpecAnalyses(from []*SpecAnalysis) (to []*SpecAnalysis)

DistinctSpecAnalyses filters out duplicate (uniqueness based on SpecAnalysis.SpecID & SpecAnalysis.Analyzer) spec analyses.

func (*SpecAnalysis) AfterFind

func (m *SpecAnalysis) AfterFind(tx *gorm.DB) (err error)

AfterFind is a hook called after querying by GORM (https://gorm.io/docs/hooks.html). For handling large SpecAnalysis.SpecAnalysisResult(s), if SpecAnalysisResult.RawResultCompressed contains the compression, decompresses it back into SpecAnalysisResult.RawResult.

func (*SpecAnalysis) AfterSave

func (m *SpecAnalysis) AfterSave(tx *gorm.DB) (err error)

AfterSave is a hook called after creation by GORM (https://gorm.io/docs/hooks.html). For handling large SpecAnalysis.SpecAnalysisResult(s), resets the temporary staging of SpecAnalysis.SpecAnalysisResult.

func (*SpecAnalysis) BeforeCreate

func (m *SpecAnalysis) BeforeCreate(tx *gorm.DB) (err error)

func (*SpecAnalysis) BeforeSave

func (m *SpecAnalysis) BeforeSave(tx *gorm.DB) (err error)

BeforeSave is a hook called before creation by GORM (https://gorm.io/docs/hooks.html). For handling large SpecAnalysisResult.RawResult(s), compressData conditionally compresses SpecAnalysisResult.RawResult into SpecAnalysisResult.RawResultCompressed.

func (*SpecAnalysis) GetID

func (m *SpecAnalysis) GetID() string

GetID returns the ID of specAnalysis object

func (*SpecAnalysis) GetIndex

func (m *SpecAnalysis) GetIndex(field string) string

GetIndex returns an index for specific field

func (*SpecAnalysis) GetIndexValue

func (m *SpecAnalysis) GetIndexValue(field string) string

GetIndexValue return index value for specified field

func (*SpecAnalysis) GetIndexValues

func (m *SpecAnalysis) GetIndexValues() map[string]string

GetIndexValues return all field index values

func (*SpecAnalysis) GetIndexes

func (m *SpecAnalysis) GetIndexes() map[string]string

GetIndexes returns all the field indexes

func (*SpecAnalysis) GetTags

func (m *SpecAnalysis) GetTags() []string

GetTags returns all the tags

func (*SpecAnalysis) OmitResultFindings

func (m *SpecAnalysis) OmitResultFindings()

func (*SpecAnalysis) SetResult

func (m *SpecAnalysis) SetResult(result *analyzer.Result, status string) error

func (*SpecAnalysis) SetScore

func (m *SpecAnalysis) SetScore(score int) error

func (*SpecAnalysis) Sortable

func (m *SpecAnalysis) Sortable(field string) bool

Sortable checks if field is sortable.

func (*SpecAnalysis) SortableFields

func (m *SpecAnalysis) SortableFields() map[string]struct{}

SortableFields returns all sortable fields

func (*SpecAnalysis) String

func (m *SpecAnalysis) String() string

String returns the text representation of specAnalysis object

func (*SpecAnalysis) TableName

func (m *SpecAnalysis) TableName() string

TableName implements gorm Tabler interface

type SpecAnalysisConfig

type SpecAnalysisConfig struct {
	Config    analyzer.Config `json:"config,omitempty" gorm:"-"`
	RawConfig datatypes.JSON  `json:"-" gorm:"column:config"`
}

type SpecAnalysisRequest

type SpecAnalysisRequest struct {
	Analyzers        []analyzer.SpecAnalyzer `json:"analyzers"`
	AnalyzersConfigs AnalyzerConfigMap       `json:"analyzers_configs,omitempty"`

	Spec    *Spec    `json:"spec,omitempty"`
	Service *Service `json:"service,omitempty"`

	ActiveAnalyzers map[analyzer.SpecAnalyzer]*analyzer.Analyzer `json:"-"`
}

SpecAnalysisRequest represents a request for a SpecAnalysis

func (*SpecAnalysisRequest) HasSpec

func (m *SpecAnalysisRequest) HasSpec() bool

type SpecAnalysisResponse

type SpecAnalysisResponse struct {
	Results map[analyzer.SpecAnalyzer]*SpecAnalysis `json:"results,omitempty"`

	SpecScore int `json:"spec_score"`
}

type SpecAnalysisResponseWrapper

type SpecAnalysisResponseWrapper struct {
	Pagination
	Data []SpecAnalysis `json:"data"`
}

SpecAnalysisResponseWrapper wrappers specAnalysis response

type SpecAnalysisResult

type SpecAnalysisResult struct {
	Result              *analyzer.Result `json:"result" gorm:"-"`
	RawResult           datatypes.JSON   `json:"-" gorm:"column:result"`
	RawResultCompressed []byte           `json:"-" gorm:"column:result_compressed"`
	// contains filtered or unexported fields
}

type SpecDiff

type SpecDiff struct {
	ID string `json:"id,omitempty" gorm:"column:id;primaryKey"`
	*SpecDiffRequest

	SpecDiffResult

	ServiceID string    `json:"service_id,omitempty" gorm:"column:service_id;index"`
	Status    string    `json:"status,omitempty" gorm:"column:status;index"` // Submitted, Invalid, Diffed
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
}

SpecDiff represents a specDiff

func (*SpecDiff) AfterFind

func (m *SpecDiff) AfterFind(tx *gorm.DB) (err error)

AfterFind is a hook called after querying by GORM (https://gorm.io/docs/hooks.html). For handling large SpecDiff.SpecDiffResult(s), if SpecDiffResult.RawResultCompressed contains the compression, decompresses it back into SpecDiffResult.RawResult.

func (*SpecDiff) AfterSave

func (m *SpecDiff) AfterSave(tx *gorm.DB) (err error)

AfterSave is a hook called after creation by GORM (https://gorm.io/docs/hooks.html). For handling large SpecDiff.SpecDiffResult(s), resets the temporary staging of SpecDiff.SpecDiffResult.

func (*SpecDiff) BeforeCreate

func (m *SpecDiff) BeforeCreate(tx *gorm.DB) (err error)

func (*SpecDiff) BeforeSave

func (m *SpecDiff) BeforeSave(tx *gorm.DB) (err error)

BeforeSave is a hook called before creation by GORM (https://gorm.io/docs/hooks.html). For handling large SpecDiffResult.RawResult(s), compressData conditionally compresses SpecDiffResult.RawResult into SpecDiffResult.RawResultCompressed.

func (*SpecDiff) GetID

func (m *SpecDiff) GetID() string

GetID returns the ID of specDiff object

func (*SpecDiff) GetIndex

func (m *SpecDiff) GetIndex(field string) string

GetIndex returns an index for specific field

func (*SpecDiff) GetIndexValue

func (m *SpecDiff) GetIndexValue(field string) string

GetIndexValue return index value for specified field

func (*SpecDiff) GetIndexValues

func (m *SpecDiff) GetIndexValues() map[string]string

GetIndexValues return all field index values

func (*SpecDiff) GetIndexes

func (m *SpecDiff) GetIndexes() map[string]string

GetIndexes returns all the field indexes

func (*SpecDiff) GetTags

func (m *SpecDiff) GetTags() []string

GetTags returns all the tags

func (*SpecDiff) SetResult

func (m *SpecDiff) SetResult(result *diff.Result, status string) error

func (*SpecDiff) Sortable

func (m *SpecDiff) Sortable(field string) bool

Sortable checks if field is sortable.

func (*SpecDiff) SortableFields

func (m *SpecDiff) SortableFields() map[string]struct{}

SortableFields returns all sortable fields

func (*SpecDiff) String

func (m *SpecDiff) String() string

String returns the text representation of specDiff object

func (*SpecDiff) TableName

func (m *SpecDiff) TableName() string

TableName implements gorm Tabler interface

type SpecDiffConfig

type SpecDiffConfig struct {
	Config    *diff.Config   `json:"config,omitempty" gorm:"-"`
	RawConfig datatypes.JSON `json:"-" gorm:"column:config"`
}

type SpecDiffRequest

type SpecDiffRequest struct {
	NewSpecID string `json:"new_spec_id,omitempty" gorm:"column:new_spec_id;index"`
	OldSpecID string `json:"old_spec_id,omitempty" gorm:"column:old_spec_id;index"`

	OldSpecDoc SpecDoc `json:"old_spec_doc,omitempty" gorm:"-"`
	NewSpecDoc SpecDoc `json:"new_spec_doc,omitempty" gorm:"-"`

	SpecDiffConfig
}

func (*SpecDiffRequest) Compare

func (r *SpecDiffRequest) Compare(with *SpecDiffRequest) bool

func (*SpecDiffRequest) From

func (r *SpecDiffRequest) From(req *restful.Request, specsGetter func(oldSpecID, newSpecID string) (oldSpec *Spec, newSpec *Spec, err error)) error

func (*SpecDiffRequest) HasSpecDocs

func (r *SpecDiffRequest) HasSpecDocs() (hasOldSpecDoc, hasNewSpecDoc bool)

type SpecDiffResponse

type SpecDiffResponse struct {
	Pagination
	Data []SpecDiff `json:"data"`
}

SpecDiffResponse wrappers specDiff response

type SpecDiffResult

type SpecDiffResult struct {
	Result              *diff.Result   `json:"result" gorm:"-"`
	RawResult           datatypes.JSON `json:"-" gorm:"column:result"`
	RawResultCompressed []byte         `json:"-" gorm:"column:result_compressed"`
	// contains filtered or unexported fields
}

type SpecDoc

type SpecDoc *string

func NewSpecDocFromBytes

func NewSpecDocFromBytes(data []byte) SpecDoc

type SpecDocAnalyzer

type SpecDocAnalyzer interface {
	Analyze(doc SpecDoc, cfgMap analyzer.Config, serviceNameID *string) (*analyzer.Result, error)
}

SpecDocAnalyzer represents the interface for analyzing a SpecDoc using (optional) analyzer.Config.

type SpecResponse

type SpecResponse struct {
	Pagination
	Data []Spec `json:"data"`
}

SpecResponse wrappers spec response

type UnauthorizedResourceAccessError

type UnauthorizedResourceAccessError struct {
	ResourceKind        ResourceKind   // organization, service
	ResourceAction      ResourceAction // create, list, get, update, delete
	ResourceID          string         // organization/service/spec ID
	UnauthorizedMessage string
}

func (UnauthorizedResourceAccessError) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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