Skip to content

Commit

Permalink
chore: keep up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobmoellerdev committed Nov 28, 2024
1 parent 067d397 commit 99e94bd
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 5 deletions.
6 changes: 3 additions & 3 deletions api/ocm/extensions/accessmethods/git/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
)

const (
Type = "git"
TypeV1 = Type + runtime.VersionSeparator + "v1"
Type = "git"
TypeV1Alpha1 = Type + runtime.VersionSeparator + "v1alpha1"
)

func init() {
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](Type, accspeccpi.WithDescription(usage)))
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](TypeV1, accspeccpi.WithFormatSpec(formatV1), accspeccpi.WithConfigHandler(ConfigHandler())))
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](TypeV1Alpha1, accspeccpi.WithFormatSpec(formatV1), accspeccpi.WithConfigHandler(ConfigHandler())))
}

// AccessSpec describes the access for a GitHub registry.
Expand Down
19 changes: 19 additions & 0 deletions api/tech/git/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net/http"
"os"
"sync"

Expand All @@ -12,12 +13,30 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/transport"
gitclient "github.com/go-git/go-git/v5/plumbing/transport/client"
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/storage"
"github.com/go-git/go-git/v5/storage/filesystem"
mlog "github.com/mandelsoft/logging"
"github.com/mandelsoft/vfs/pkg/memoryfs"
"github.com/mandelsoft/vfs/pkg/vfs"

"ocm.software/ocm/api/utils/logging"
)

const LogAttrProtocol = "protocol"

func init() {
// override the logging realm for http based git clients
gitclient.InstallProtocol("http", githttp.NewClient(&http.Client{
Transport: logging.NewRoundTripper(http.DefaultTransport, logging.DynamicLogger(REALM, mlog.NewAttribute(LogAttrProtocol, "http"))),
}))
gitclient.InstallProtocol("https", githttp.NewClient(&http.Client{
Transport: logging.NewRoundTripper(http.DefaultTransport, logging.DynamicLogger(REALM, mlog.NewAttribute(LogAttrProtocol, "https"))),
}))
//TODO Determine how we ideally log for ssh+git protocol

Check failure on line 37 in api/tech/git/resolver.go

View workflow job for this annotation

GitHub Actions / Lint Golang

commentFormatting: put a space between `//` and comment text (gocritic)
}

var DefaultWorktreeBranch = plumbing.NewBranchReferenceName("ocm")

type client struct {
Expand Down
2 changes: 2 additions & 0 deletions api/utils/blobaccess/git/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"ocm.software/ocm/api/utils/tarutils"
)

// BlobAccess clones the repository into a temporary filesystem, packs it into a tar.gz file,
// and returns a BlobAccess object for the tar.gz file.
func BlobAccess(opt ...Option) (_ bpi.BlobAccess, rerr error) {
var finalize finalizer.Finalizer
defer finalize.FinalizeWithErrorPropagation(&rerr)
Expand Down
47 changes: 47 additions & 0 deletions docs/reference/ocm_add_resource-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,29 @@ with the field <code>type</code> in the <code>input</code> field:

Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>

- Input type <code>git</code>

The repository type allows accessing an arbitrary git repository
using the manifest annotation <code>software.ocm/component-version</code>.
The ref can be used to further specify the branch or tag to checkout, otherwise the remote HEAD is used.

This blob type specification supports the following fields:
- **<code>repository</code>** *string*

This REQUIRED property describes the URL of the git repository to access. All git URL formats are supported.

- **<code>ref</code>** *string*

This OPTIONAL property can be used to specify the remote branch or tag to checkout (commonly called ref).
If not set, the default HEAD (remotes/origin/HEAD) of the remote is used.

- **<code>commit</code>** *string*

This OPTIONAL property can be used to specify the commit hash to checkout.
If not set, the default HEAD of the ref is used.

Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>

- Input type <code>helm</code>

The path must denote an helm chart archive or directory
Expand Down Expand Up @@ -607,6 +630,30 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>git</code>

This method implements the access of the content of a git commit stored in a
Git repository.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>repoUrl</code>** *string*

Repository URL with or without scheme.

- **<code>ref</code>** (optional) *string*

Original ref used to get the commit from

- **<code>commit</code>** *string*

The sha/id of the git commit

Options used to configure fields: <code>--accessRepository</code>, <code>--commit</code>, <code>--reference</code>

- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
47 changes: 47 additions & 0 deletions docs/reference/ocm_add_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,29 @@ with the field <code>type</code> in the <code>input</code> field:

Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>

- Input type <code>git</code>

The repository type allows accessing an arbitrary git repository
using the manifest annotation <code>software.ocm/component-version</code>.
The ref can be used to further specify the branch or tag to checkout, otherwise the remote HEAD is used.

This blob type specification supports the following fields:
- **<code>repository</code>** *string*

This REQUIRED property describes the URL of the git repository to access. All git URL formats are supported.

- **<code>ref</code>** *string*

This OPTIONAL property can be used to specify the remote branch or tag to checkout (commonly called ref).
If not set, the default HEAD (remotes/origin/HEAD) of the remote is used.

- **<code>commit</code>** *string*

This OPTIONAL property can be used to specify the commit hash to checkout.
If not set, the default HEAD of the ref is used.

Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>

- Input type <code>helm</code>

The path must denote an helm chart archive or directory
Expand Down Expand Up @@ -619,6 +642,30 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>git</code>

This method implements the access of the content of a git commit stored in a
Git repository.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>repoUrl</code>** *string*

Repository URL with or without scheme.

- **<code>ref</code>** (optional) *string*

Original ref used to get the commit from

- **<code>commit</code>** *string*

The sha/id of the git commit

Options used to configure fields: <code>--accessRepository</code>, <code>--commit</code>, <code>--reference</code>

- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
47 changes: 47 additions & 0 deletions docs/reference/ocm_add_source-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,29 @@ with the field <code>type</code> in the <code>input</code> field:

Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>

- Input type <code>git</code>

The repository type allows accessing an arbitrary git repository
using the manifest annotation <code>software.ocm/component-version</code>.
The ref can be used to further specify the branch or tag to checkout, otherwise the remote HEAD is used.

This blob type specification supports the following fields:
- **<code>repository</code>** *string*

This REQUIRED property describes the URL of the git repository to access. All git URL formats are supported.

- **<code>ref</code>** *string*

This OPTIONAL property can be used to specify the remote branch or tag to checkout (commonly called ref).
If not set, the default HEAD (remotes/origin/HEAD) of the remote is used.

- **<code>commit</code>** *string*

This OPTIONAL property can be used to specify the commit hash to checkout.
If not set, the default HEAD of the ref is used.

Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>

- Input type <code>helm</code>

The path must denote an helm chart archive or directory
Expand Down Expand Up @@ -607,6 +630,30 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>git</code>

This method implements the access of the content of a git commit stored in a
Git repository.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>repoUrl</code>** *string*

Repository URL with or without scheme.

- **<code>ref</code>** (optional) *string*

Original ref used to get the commit from

- **<code>commit</code>** *string*

The sha/id of the git commit

Options used to configure fields: <code>--accessRepository</code>, <code>--commit</code>, <code>--reference</code>

- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
47 changes: 47 additions & 0 deletions docs/reference/ocm_add_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,29 @@ with the field <code>type</code> in the <code>input</code> field:

Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>

- Input type <code>git</code>

The repository type allows accessing an arbitrary git repository
using the manifest annotation <code>software.ocm/component-version</code>.
The ref can be used to further specify the branch or tag to checkout, otherwise the remote HEAD is used.

This blob type specification supports the following fields:
- **<code>repository</code>** *string*

This REQUIRED property describes the URL of the git repository to access. All git URL formats are supported.

- **<code>ref</code>** *string*

This OPTIONAL property can be used to specify the remote branch or tag to checkout (commonly called ref).
If not set, the default HEAD (remotes/origin/HEAD) of the remote is used.

- **<code>commit</code>** *string*

This OPTIONAL property can be used to specify the commit hash to checkout.
If not set, the default HEAD of the ref is used.

Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>

- Input type <code>helm</code>

The path must denote an helm chart archive or directory
Expand Down Expand Up @@ -617,6 +640,30 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>git</code>

This method implements the access of the content of a git commit stored in a
Git repository.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>repoUrl</code>** *string*

Repository URL with or without scheme.

- **<code>ref</code>** (optional) *string*

Original ref used to get the commit from

- **<code>commit</code>** *string*

The sha/id of the git commit

Options used to configure fields: <code>--accessRepository</code>, <code>--commit</code>, <code>--reference</code>

- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
24 changes: 24 additions & 0 deletions docs/reference/ocm_ocm-accessmethods.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>git</code>

This method implements the access of the content of a git commit stored in a
Git repository.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>repoUrl</code>** *string*

Repository URL with or without scheme.

- **<code>ref</code>** (optional) *string*

Original ref used to get the commit from

- **<code>commit</code>** *string*

The sha/id of the git commit

Options used to configure fields: <code>--accessRepository</code>, <code>--commit</code>, <code>--reference</code>

- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
Loading

0 comments on commit 99e94bd

Please sign in to comment.