util

package
v0.0.0-...-0bc0c14 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// Filters out entries with empty field
	ArrayFilterIfEmpty = iota
	// Omits entries from filtering with empty field (leaves entries in result)
	ArraySkipIfEmpty = iota

	// Parameter 'name'
	ParamName = "name"
	// Parameter 'displayName'
	ParamDisplayName = "displayName"
	// Parameter 'description'
	ParamDescription = "description"
	// Parameter 'icon'
	ParamIcon = "iconUri"
	// Parameter 'projectType'
	ParamProjectType = "projectType"
	// Parameter 'language'
	ParamLanguage = "language"
	// Parameter 'version'
	ParamVersion = "version"
	// Parameter 'schemaVersion'
	ParamSchemaVersion = "schemaVersion"
	// Parameter 'default'
	ParamDefault = "default"
	// Parameter 'git.url'
	ParamGitUrl = "gitUrl"
	// Parameter 'git.remoteName'
	ParamGitRemoteName = "gitRemoteName"
	// Parameter 'git.subDir'
	ParamGitSubDir = "gitSubDir"
	// Parameter 'git.revision'
	ParamGitRevision = "gitRevision"
	// Parameter 'provider'
	ParamProvider = "provider"
	// Parameter 'supportUrl'
	ParamSupportUrl = "supportUrl"
	// Parameter 'lastModified'
	ParamLastModified = "lastModified"

	// Parameter 'attributeNames'
	ArrayParamAttributeNames = "attributeNames"
	// Parameter 'tags'
	ArrayParamTags = "tags"
	// Parameter 'architectures'
	ArrayParamArchitectures = "arch"
	// Parameter 'resources'
	ArrayParamResources = "resources"
	// Parameter 'starterProjects'
	ArrayParamStarterProjects = "starterProjects"
	// Parameter 'links'
	ArrayParamLinks = "links"
	// Parameter 'commandGroups'
	ArrayParamCommandGroups = "commandGroups"
	// Parameter 'deploymentScopes'
	ArrayParamDeploymentScopes = "deploymentScopes"
	// Parameter 'gitRemoteNames'
	ArrayParamGitRemoteNames = "gitRemoteNames"
	// Parameter 'gitRemotes'
	ArrayParamGitRemotes = "gitRemotes"
)

Variables

This section is empty.

Functions

func ConvertNonRFC3339Date

func ConvertNonRFC3339Date(dt string) (time.Time, error)

func ConvertRFC3339Date

func ConvertRFC3339Date(dt *string) (time.Time, error)

func ConvertToOldIndexFormat

func ConvertToOldIndexFormat(schemaList []indexSchema.Schema) []indexSchema.Schema

func EncodeIndexIconToBase64

func EncodeIndexIconToBase64(indexPath string, base64IndexPath string) ([]byte, error)

EncodeIndexIconToBase64 encodes all index icons to base64 format given the index file path

func FilterDevfileDeprecated

func FilterDevfileDeprecated(index *[]indexSchema.Schema, deprecated, v1Index bool)

FilterDevfileDeprecated inplace filters devfiles based on stack deprecation

func FilterDevfileSchemaVersion

func FilterDevfileSchemaVersion(index []indexSchema.Schema, minSchemaVersion, maxSchemaVersion *string) ([]indexSchema.Schema, error)

FilterDevfileSchemaVersion filters devfiles based on schema version

func FilterDevfileVersion

func FilterDevfileVersion(index []indexSchema.Schema, minVersion, maxVersion *string) ([]indexSchema.Schema, error)

FilterDevfileVersion filters devfiles based on stack version

func FilterLastModifiedDate

func FilterLastModifiedDate(index []indexSchema.Schema, minLastModified *string, maxLastModified *string) ([]indexSchema.Schema, error)

FilterLastModifiedDate filters based on the last modified date of a stack or sample

func GetClient

func GetClient(c *gin.Context) string

func GetOptionalEnv

func GetOptionalEnv(key string, defaultValue interface{}) interface{}

GetOptionalEnv gets the optional environment variable

func GetUser

func GetUser(c *gin.Context) string

GetUser gets the user

func IsArrayParameter

func IsArrayParameter(name string) bool

func IsDateGreaterOrEqual

func IsDateGreaterOrEqual(bound time.Time, current time.Time) bool

func IsDateLowerOrEqual

func IsDateLowerOrEqual(bound time.Time, current time.Time) bool

func IsEnabled

func IsEnabled(key string, defaultValue bool) bool

IsEnabled return value of a boolean environment variable, if environment variable has non-boolean typed value returns default value

func IsFieldParameter

func IsFieldParameter(name string) bool

func IsHtmlRequested

func IsHtmlRequested(acceptHeader []string) bool

IsHtmlRequested checks the accept header if html has been requested

func IsIndirectCall

func IsIndirectCall(c *gin.Context) bool

IsIndirectCall determines if a request is made from an internal client

func IsInvalidLastModifiedDate

func IsInvalidLastModifiedDate(lastModifiedDate *string) bool

func IsTelemetryEnabled

func IsTelemetryEnabled() bool

func IsWebClient

func IsWebClient(c *gin.Context) bool

IsWebClient determines if the event is coming from the registry viewer or DevConsole client.

func MakeVersionMap

func MakeVersionMap(devfileIndex indexSchema.Schema) (map[string]indexSchema.Version, error)

MakeVersionMap creates a map of versions for a given devfile index schema.

func ReadIndexPath

func ReadIndexPath(indexPath string) ([]indexSchema.Schema, error)

ReadIndexPath reads the index from the path and unmarshalls it into the index

func SetContext

func SetContext(c *gin.Context) *analytics.Context

SetContext suppresses the collection of IP addresses in Segment but infers the country code from the HTTP `Accept-Language` header

func StrPtrIsSet

func StrPtrIsSet(ptr *string) bool

StrPtrIsSet checks if string pointer is set to a value

func StructToMap

func StructToMap[T any](s T) map[string]any

StructToMap converts any struct into a map

func TrackEvent

func TrackEvent(event analytics.Message) error

TrackEvent tracks event for telemetry

Types

type FilterOptions

type FilterOptions[T any] struct {
	GetFromIndexField   func(*indexSchema.Schema) T
	GetFromVersionField func(*indexSchema.Version) T
	FilterOutEmpty      bool
	V1Index             bool
}

FilterOptions provides filtering options to filters operations

type FilterResult

type FilterResult struct {
	// Name of filter
	Name string
	// Index schema result
	Index []indexSchema.Schema
	// First error returned in result
	Error error
}

FilterResult result entity of filtering the index schema

func AndFilter

func AndFilter(results ...*FilterResult) FilterResult

AndFilter filters results of given filters to only overlapping results

func FilterDevfileStrArrayField

func FilterDevfileStrArrayField(index []indexSchema.Schema, paramName string, requestedValues []string, v1Index bool) FilterResult

FilterDevfileStrArrayField filters devfiles based on an array field

func FilterDevfileStrField

func FilterDevfileStrField(index []indexSchema.Schema, paramName, requestedValue string, v1Index bool) FilterResult

FilterDevfileStrField filters by given string field, returns unchanged index if given parameter name is unrecognized

Jump to

Keyboard shortcuts

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