helm

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MEDIA_TYPE is the media type of the HELM Chart artifact as tgz.
	// It is the definitive format for JFrog Uploads
	MEDIA_TYPE = helm.ChartMediaType

	// NAME of the Uploader and the Configuration
	NAME = "JFrogHelm"

	// VERSION of the Uploader TODO Increment once stable
	VERSION = "v1alpha1"

	// VERSIONED_NAME is the name of the Uploader including the version
	VERSIONED_NAME = NAME + runtime.VersionSeparator + VERSION

	// ID_TYPE is the type of the JFrog Artifactory credentials
	ID_TYPE = cpi.ID_TYPE
	// ID_HOSTNAME is the hostname of the artifactory server to upload to
	ID_HOSTNAME = hostpath.ID_HOSTNAME
	// ID_PORT is the port of the artifactory server to upload to
	ID_PORT = hostpath.ID_PORT
	// ID_REPOSITORY is the repository name in JFrog Artifactory to upload to
	ID_REPOSITORY = "repository"

	// DEFAULT_TIMEOUT is the default timeout for http requests issued by the uploader.
	DEFAULT_TIMEOUT = time.Minute
)

Variables

This section is empty.

Functions

func ConvertArtifactSetWithOCIImageHelmChartToPlainTGZChart

func ConvertArtifactSetWithOCIImageHelmChartToPlainTGZChart(reader io.Reader) (_ io.ReadCloser, _ string, err error)

ConvertArtifactSetWithOCIImageHelmChartToPlainTGZChart converts an artifact set with a single layer helm OCI image to a plain tgz chart. Note that this transformation is not completely reversible because an OCI artifact contains provenance data, while a plain tgz chart does not. This means converting back from a signed tgz chart to an OCI image will lose the provenance data, and also change digests. The returned digest is the digest of the tgz chart.

func ConvertTargetSpecToHelmUploadURL

func ConvertTargetSpecToHelmUploadURL(spec *JFrogHelmUploaderSpec) (*url.URL, error)

ConvertTargetSpecToHelmUploadURL interprets the JFrogHelmUploaderSpec into a valid REST API Endpoint URL to upload to. It requires a valid ChartName and ChartVersion to determine the correct URL endpoint.

See https://jfrog.com/help/r/jfrog-rest-apis/deploy-artifact for the URL endpoint
See https://jfrog.com/help/r/jfrog-artifactory-documentation/deploying-artifacts for artifact deployment reference
See https://jfrog.com/help/r/jfrog-artifactory-documentation/use-the-jfrog-helm-client for the HELM Client reference.

Example:

JFrogHelmUploaderSpec.URL => demo.jfrog.ocm.software
JFrogHelmUploaderSpec.Repository => my-charts
JFrogHelmUploaderSpec.ChartName => podinfo
JFrogHelmUploaderSpec.ChartVersion => 0.0.1

will result in

url.URL => https://demo.jfrog.ocm.software/artifactory/my-charts/podinfo-0.0.1.tgz

func ConvertTargetSpecToInfo

func ConvertTargetSpecToInfo(spec *JFrogHelmUploaderSpec) (*ppi.UploadTargetSpecInfo, error)

ConvertTargetSpecToInfo converts the JFrogHelmUploaderSpec to a valid info block containing the consumer ID used in the library to identify the correct credentials that need to be passed to it.

func New

func New() ppi.Uploader

func ParseURLAllowNoScheme

func ParseURLAllowNoScheme(urlToParse string) (*url.URL, error)

ParseURLAllowNoScheme is an adaptation / hack on url.Parse because url.Parse does not support parsing a URL without a prefixed scheme. However, we would like to accept these kind of URLs because we default them to "https://" out of convenience.

func ReindexChart

func ReindexChart(ctx context.Context, client *http.Client, artifactoryURL string,
	repository string,
	creds credentials.Credentials) (err error)

func SetHeadersFromCredentials

func SetHeadersFromCredentials(req *http.Request, creds credentials.Credentials)

func Upload

func Upload(
	ctx context.Context,
	data io.Reader,
	client *http.Client,
	url *url.URL,
	creds credentials.Credentials,
	digest string,
) (_ ppi.AccessSpec, err error)

Types

type ArtifactoryUploadChecksums

type ArtifactoryUploadChecksums struct {
	Sha1   string `json:"sha1,omitempty"`
	Sha256 string `json:"sha256,omitempty"`
	Md5    string `json:"md5,omitempty"`
}

type ArtifactoryUploadResponse

type ArtifactoryUploadResponse struct {
	Repo        string                     `json:"repo,omitempty"`
	Path        string                     `json:"path,omitempty"`
	Created     string                     `json:"created,omitempty"`
	CreatedBy   string                     `json:"createdBy,omitempty"`
	DownloadUri string                     `json:"downloadUri,omitempty"`
	MimeType    string                     `json:"mimeType,omitempty"`
	Size        string                     `json:"size,omitempty"`
	Checksums   ArtifactoryUploadChecksums `json:"checksums,omitempty"`
	Uri         string                     `json:"uri"`
}

func (*ArtifactoryUploadResponse) ToHelmAccessSpec

func (r *ArtifactoryUploadResponse) ToHelmAccessSpec() (ppi.AccessSpec, error)

func (*ArtifactoryUploadResponse) URL

type JFrogHelmChart

type JFrogHelmChart struct {
	// ChartName is the desired name of the chart in the repository.
	// OPTIONAL: If not set, defaulted from the passed Hint.
	Name string `json:"name,omitempty"`
	// Version is the desired version of the chart
	// OPTIONAL: If not set, defaulted from the passed Hint.
	Version string `json:"version,omitempty"`
}

type JFrogHelmUploaderSpec

type JFrogHelmUploaderSpec struct {
	runtime.ObjectVersionedType `json:",inline"`

	// URL is the hostname of the JFrog instance.
	// Required for correct reference to Artifactory.
	URL string `json:"url"`

	// Repository is the repository to upload to.
	// Required for correct reference to Artifactory.
	Repository string `json:"repository"`

	JFrogHelmChart `json:",inline"`

	// Timeout is the maximum duration the upload of the chart can take
	// before aborting and failing.
	// OPTIONAL: If not set, set to the internal DEFAULT_TIMEOUT.
	Timeout *time.Duration `json:"timeout,omitempty"`

	// ReIndexAfterUpload is a flag to indicate if the chart should be reindexed after upload or not.
	// OPTIONAL: If not set, defaulted to false.
	ReIndexAfterUpload bool `json:"reindexAfterUpload,omitempty"`
}

func (*JFrogHelmUploaderSpec) GetTimeout

func (s *JFrogHelmUploaderSpec) GetTimeout() time.Duration

type Uploader

type Uploader struct {
	ppi.UploaderBase
	*http.Client
}

func (*Uploader) Decoders

func (a *Uploader) Decoders() ppi.UploadFormats

func (*Uploader) Upload

func (a *Uploader) Upload(
	ctx context.Context,
	p ppi.Plugin,
	arttype, mediaType, _, digest string,
	targetSpec ppi.UploadTargetSpec,
	creds credentials.Credentials,
	reader io.Reader,
) (ppi.AccessSpecProvider, error)

Upload uploads any artifact that is of type artifacttypes.HELM_CHART. Process:

  1. introspect the JFrogHelmUploaderSpec (cast from ppi.UploadTargetSpec) and hint parameter (the hint is expected to be an OCI style reference, such as `repo/comp:version`)
  2. building an Artifactory Style JFrog Upload URL out of it (see ConvertTargetSpecToHelmUploadURL),
  3. creating a request respecting the passed credentials based on SetHeadersFromCredentials
  4. uploading the passed blob as is (expected to be a tgz byte stream)
  5. interpreting the JFrog API response, and converting it from ArtifactoryUploadResponse to ppi.AccessSpec

func (*Uploader) ValidateSpecification

func (a *Uploader) ValidateSpecification(_ ppi.Plugin, spec ppi.UploadTargetSpec) (*ppi.UploadTargetSpecInfo, error)

Jump to

Keyboard shortcuts

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