Skip to content

Commit

Permalink
Merge pull request #67 from robnester-rh/fix_uri_parsing_in_oci
Browse files Browse the repository at this point in the history
fix URI parsing in oci
  • Loading branch information
robnester-rh authored Jun 28, 2024
2 parents a8e9b34 + f178a36 commit 47ea24d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gather/oci/oci.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
// Copyright The Enterprise Contract Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

// Package oci provides functionality for gathering files or directories from OCI (Open Container Initiative) sources.
// It includes an implementation of the Gatherer interface, OCIGatherer, which allows copying files or directories from an OCI source to a destination path.
// The Gather method in OCIGatherer takes a source path and a destination path, and returns the metadata of the gathered file or directory and any error encountered.
// This package also includes a helper function, ociURLParse, for parsing the source URI.
package oci

import (
Expand Down Expand Up @@ -76,6 +96,10 @@ func (f *OCIGatherer) Gather(ctx context.Context, source, destination string) (m
}

func ociURLParse(source string) string {
if strings.Contains(source, "::") {
source = strings.Split(source, "::")[1]
}

scheme, src, found := strings.Cut(source, "://")
if !found {
src = scheme
Expand Down

0 comments on commit 47ea24d

Please sign in to comment.