destinations

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

README

Destinations Package

This package provides implementations of the core.Destination interface for different artifact destinations.

Components

JFrog Destination

The JFrogDestination implements the core.Destination interface for uploading artifacts to JFrog Artifactory.

Features
  • Uploads artifacts to JFrog Artifactory
  • Supports basic authentication
  • Validates destination configuration
  • Handles matrix parameters for artifact properties
  • Checks for existing artifacts
Usage
config := destinations.JFrogConfig{
    URL:      "https://jfrog.example.com",
    User:     "username",
    Password: "password",
}
dest := destinations.NewJFrogDestination(config, logger)

artifact := &core.Artifact{
    Name:     "example",
    Version:  "1.0.0",
    Location: "test-repo/example",
    Metadata: map[string]string{
        "prop1": "value1",
        "prop2": "value2",
    },
}
err := dest.Put(ctx, artifact, content)
Configuration

The JFrog destination requires:

  • Artifactory URL
  • Username
  • Password
  • Valid URL scheme (http/https)

Adding New Destinations

To add a new destination implementation:

  1. Create a new type that implements the core.Destination interface
  2. Implement the required methods:
    • Put(ctx context.Context, artifact *core.Artifact, content io.Reader) error
    • Exists(ctx context.Context, artifact *core.Artifact) (bool, error)
    • Validate() error
  3. Add appropriate tests in the corresponding test file
  4. Update this README with documentation for the new destination

Documentation

Overview

Package destinations provides implementations for various registry destinations.

Package destinations provides implementations of the core.Destination interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCloudsmithDestination added in v0.5.6

func NewCloudsmithDestination(config CloudsmithConfig, logger *logrus.Logger) core.Destination

NewCloudsmithDestination creates a new Cloudsmith destination.

Types

type CloudsmithConfig added in v0.5.6

type CloudsmithConfig struct {
	// URL is the base URL of the Cloudsmith repository (e.g., https://api.cloudsmith.io)
	URL string

	// User is the username or API key for authentication
	User string

	// Password is the password or API secret for authentication
	Password string

	// DestPath is the destination path in the repository (format: owner/repo)
	DestPath string

	// SourcePathStrip is the path prefix to strip from source URLs
	SourcePathStrip string
}

CloudsmithConfig holds the configuration for Cloudsmith destinations.

type CloudsmithDestination added in v0.5.6

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

CloudsmithDestination implements the core.Destination interface for Cloudsmith repositories.

func (*CloudsmithDestination) BuildDestinationPath added in v0.5.6

func (d *CloudsmithDestination) BuildDestinationPath(artifact *core.Artifact, _ bool) (string, error)

BuildDestinationPath constructs the destination path for an artifact.

func (*CloudsmithDestination) Exists added in v0.5.6

func (d *CloudsmithDestination) Exists(ctx context.Context, artifact *core.Artifact, raw bool) (bool, error)

Exists checks if an artifact already exists in the Cloudsmith repository.

func (*CloudsmithDestination) Put added in v0.5.6

func (d *CloudsmithDestination) Put(ctx context.Context, artifact *core.Artifact, content io.Reader, raw bool) (string, error)

Put stores an artifact in the Cloudsmith repository.

func (*CloudsmithDestination) String added in v0.5.6

func (d *CloudsmithDestination) String() string

String returns a string representation of the CloudsmithDestination.

func (*CloudsmithDestination) Validate added in v0.5.6

func (d *CloudsmithDestination) Validate() error

Validate checks if the CloudsmithDestination configuration is valid.

type JFrogConfig

type JFrogConfig struct {
	URL      string // Base URL of the Artifactory instance (e.g., https://artifactory.example.com)
	User     string // Username for authentication
	Password string // Password for authentication
	DestPath string // Path within Artifactory where artifacts will be stored

	// SourcePathStrip is an optional prefix to strip from source URLs before processing.
	// This is useful for JFrog-to-JFrog mirroring where you want to remove the source
	// repository path. For example, setting this to "artifactory.corp.net/staging/"
	// will strip that prefix from source URLs before generating the destination path.
	SourcePathStrip string
}

JFrogConfig contains the configuration for connecting to JFrog Artifactory.

type JFrogDestination

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

JFrogDestination implements the core.Destination interface for JFrog Artifactory.

func NewJFrogDestination

func NewJFrogDestination(config JFrogConfig, logger *logrus.Logger) *JFrogDestination

NewJFrogDestination creates a new JFrogDestination with the provided configuration.

func (*JFrogDestination) BuildDestinationPath added in v0.5.3

func (d *JFrogDestination) BuildDestinationPath(artifact *core.Artifact, raw bool) (string, error)

BuildDestinationPath calculates the destination path for an artifact without performing an upload. This is used for dry-run scenarios to predict the final location. The returned path is the path component of the full target URL.

func (*JFrogDestination) BuildTargetURL

func (d *JFrogDestination) BuildTargetURL(artifact *core.Artifact, raw bool) (*url.URL, error)

BuildTargetURL constructs the full URL for an artifact in JFrog Artifactory. It includes the base URL, destination path, and matrix parameters for metadata.

func (*JFrogDestination) Exists

func (d *JFrogDestination) Exists(ctx context.Context, artifact *core.Artifact, raw bool) (bool, error)

Exists checks if an artifact already exists in JFrog Artifactory.

func (*JFrogDestination) GetConfig

func (d *JFrogDestination) GetConfig() JFrogConfig

GetConfig returns the JFrog configuration (used for testing).

func (*JFrogDestination) Put

func (d *JFrogDestination) Put(ctx context.Context, artifact *core.Artifact, content io.Reader, raw bool) (string, error)

Put uploads an artifact to JFrog Artifactory.

func (*JFrogDestination) Validate

func (d *JFrogDestination) Validate() error

Validate checks if the JFrog configuration is valid.

Jump to

Keyboard shortcuts

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