Documentation
¶
Index ¶
- Constants
- func ConvertArtifactSetWithOCIImageHelmChartToPlainTGZChart(reader io.Reader) (_ io.ReadCloser, _ string, err error)
- func ConvertTargetSpecToHelmUploadURL(spec *JFrogHelmUploaderSpec) (*url.URL, error)
- func ConvertTargetSpecToInfo(spec *JFrogHelmUploaderSpec) (*ppi.UploadTargetSpecInfo, error)
- func New() ppi.Uploader
- func ParseURLAllowNoScheme(urlToParse string) (*url.URL, error)
- func ReindexChart(ctx context.Context, client *http.Client, artifactoryURL string, ...) (err error)
- func SetHeadersFromCredentials(req *http.Request, creds credentials.Credentials)
- func Upload(ctx context.Context, data io.Reader, client *http.Client, url *url.URL, ...) (_ ppi.AccessSpec, err error)
- type ArtifactoryUploadChecksums
- type ArtifactoryUploadResponse
- type JFrogHelmChart
- type JFrogHelmUploaderSpec
- type Uploader
- func (a *Uploader) Decoders() ppi.UploadFormats
- func (a *Uploader) Upload(ctx context.Context, p ppi.Plugin, arttype, mediaType, _, digest string, ...) (ppi.AccessSpecProvider, error)
- func (a *Uploader) ValidateSpecification(_ ppi.Plugin, spec ppi.UploadTargetSpec) (*ppi.UploadTargetSpecInfo, error)
Constants ¶
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 ParseURLAllowNoScheme ¶
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)
Types ¶
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 ¶
func (r *ArtifactoryUploadResponse) URL() string
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:
- 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`)
- building an Artifactory Style JFrog Upload URL out of it (see ConvertTargetSpecToHelmUploadURL),
- creating a request respecting the passed credentials based on SetHeadersFromCredentials
- uploading the passed blob as is (expected to be a tgz byte stream)
- 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)