utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeFieldsPlaceholder = "{{NODE_FIELDS}}"

	// Shared GraphQL node field fragments.
	FieldDownloadPath  = "downloadPath"
	FieldPredicateType = "predicateType"
	FieldPredicateSlug = "predicateSlug"
	FieldPredicate     = "predicate"
	FieldVerified      = "verified"
	FieldCreatedBy     = "createdBy"
	FieldCreatedAt     = "createdAt"
	FieldSubjectSha256 = "subject { sha256 }"
	// FieldSubjectWithPath includes Artifactory subject location fields used by entity cleanup
	// and callers that need the stored subject path in addition to the checksum.
	FieldSubjectWithPath         = "subject { sha256 fullPath repositoryKey path name }"
	FieldSigningKeyAlias         = "signingKey { alias }"
	FieldSigningKeyWithPublicKey = "signingKey {alias, publicKey}"

	// Optional GraphQL fragments.
	AttachmentsFragment = "attachments { name sha256 type downloadPath }"
)
View Source
const DefaultProject = "default"
View Source
const IsoDateTimeLayout = "2006-01-02T15:04:05.000-0700"
View Source
const SonarIntegration = "sonar"

Variables

This section is empty.

Functions

func BuildApplicationVersionRepoKey added in v0.8.1

func BuildApplicationVersionRepoKey(project string) string

func BuildBuildInfoRepoKey

func BuildBuildInfoRepoKey(project string) string

func BuildGraphQLEntityHasSubjectWith added in v0.10.0

func BuildGraphQLEntityHasSubjectWith(subject model.EntitySubject) string

BuildGraphQLEntityHasSubjectWith builds the GraphQL hasSubjectWith fields for an entity subject. Exactly one of EntityRepo, ProjectKey, and ApplicationKey may be set (or none).

func BuildQuery added in v0.9.0

func BuildQuery(template, nodeFields string) string

BuildQuery replaces every occurrence of NodeFieldsPlaceholder in template with the provided nodeFields string.

func BuildReleaseBundleRepoKey

func BuildReleaseBundleRepoKey(project string) string

func GetEnvVariable

func GetEnvVariable(envVarName string) (string, error)

func IsAttachmentsFieldNotFound added in v0.9.0

func IsAttachmentsFieldNotFound(err error) bool

func IsFeatureSupported added in v0.10.0

func IsFeatureSupported(feature EvidenceFeature, version string) bool

IsFeatureSupported reports whether the given Evidence service version supports feature. Non-release / development version strings are treated as supported so local and snapshot builds are not blocked. Unknown features are not supported.

func IsFlagPositiveNumber

func IsFlagPositiveNumber(flag string) bool

func IsHttpStatusSuccessful added in v0.9.0

func IsHttpStatusSuccessful(statusCode int) bool

func IsNonReleaseEvidenceVersion added in v0.10.0

func IsNonReleaseEvidenceVersion(version string) bool

IsNonReleaseEvidenceVersion reports whether version is anything other than a pure major.minor.patch release string (e.g. "7.1285.0"). Production Evidence returns that form only; every other string (dev, SNAPSHOT, empty, suffixes) is treated as development and should not fail feature checks.

func IsRunningUnderGitHubAction

func IsRunningUnderGitHubAction() bool

func IsSonarIntegration

func IsSonarIntegration(integration string) bool

func MinVersionForFeature added in v0.10.0

func MinVersionForFeature(feature EvidenceFeature) string

MinVersionForFeature returns the minimum Evidence release that supports feature, or an empty string when the feature is unknown.

func ParseIsoTimestamp

func ParseIsoTimestamp(isoTimestamp string) (time.Time, error)

func ResolveApplicationEntityProjectKey added in v0.10.0

func ResolveApplicationEntityProjectKey(serverDetails *config.ServerDetails, subject *model.EntitySubject) error

ResolveApplicationEntityProjectKey resolves project scope for bare application-entity subjects (entity-type=application with no --project/--entity-repo/--application-key scope already set). When resolution is not needed, subject is left unchanged.

func ResolveApplicationProjectKey added in v0.10.0

func ResolveApplicationProjectKey(serverDetails *config.ServerDetails, applicationKey string) (string, error)

ResolveApplicationProjectKey looks up an application in AppTrust and returns its project key.

func ValidateIntegration

func ValidateIntegration(integration string) error

Types

type AqlResult

type AqlResult struct {
	Results []*servicesUtils.ResultItem `json:"results,omitempty"`
}

func ExecuteAqlQuery

func ExecuteAqlQuery(query string, client *artifactory.ArtifactoryServicesManager) (*AqlResult, error)

ExecuteAqlQuery executes an AQL query and returns the result.

type EvidenceFeature added in v0.10.0

type EvidenceFeature string

EvidenceFeature identifies an Evidence service capability gated by a minimum version.

const (
	// FeatureEntityAPI is the Evidence /entity create, get, and verify APIs.
	FeatureEntityAPI EvidenceFeature = "entityAPI"
)

type NodeFieldsBuilder added in v0.9.0

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

NodeFieldsBuilder composes GraphQL node field lists dynamically, avoiding combinatorial explosion of query constants when optional fields (attachments, predicate, publicKey, etc.) are involved.

func NewNodeFieldsBuilder added in v0.9.0

func NewNodeFieldsBuilder(baseFields ...string) *NodeFieldsBuilder

NewNodeFieldsBuilder creates a builder pre-populated with the given base fields.

func (*NodeFieldsBuilder) Build added in v0.9.0

func (b *NodeFieldsBuilder) Build() string

Build returns the space-joined field list ready for insertion into a query template.

func (*NodeFieldsBuilder) WithIf added in v0.9.0

func (b *NodeFieldsBuilder) WithIf(condition bool, field string) *NodeFieldsBuilder

WithIf appends field to the list only when condition is true.

Jump to

Keyboard shortcuts

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