git

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Access Method git - Git Commit Access

Synopsis

type: git/v1

Provided blobs use the following media type for: application/x-tgz

The artifact content is provided as gnu-zipped tar archive

Description

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

Supported specification version is v1alpha1

Specification Versions
Version v1alpha1

The type specific specification fields are:

  • repository string

    Repository URL with or without scheme.

  • ref (optional) string

    Original ref used to get the commit from

  • commit string

    The sha/id of the git commit

Go Bindings

The go binding can be found here

Example
package main

import (
  "archive/tar"
  "bytes"
  "compress/gzip"
  "fmt"
  "io"

  "ocm.software/ocm/api/ocm"
  "ocm.software/ocm/api/ocm/cpi"
  me "ocm.software/ocm/api/ocm/extensions/accessmethods/git"
)

func main() {
  ctx := ocm.New()
  accessSpec := me.New(
    "https://github.com/octocat/Hello-World.git",
    me.WithRef("refs/heads/master"),
  )
  method, err := accessSpec.AccessMethod(&cpi.DummyComponentVersionAccess{Context: ctx})
  if err != nil {
    panic(err)
  }
  content, err := method.GetContent()
  if err != nil {
    panic(err)
  }
  unzippedContent, err := gzip.NewReader(bytes.NewReader(content))

  r := tar.NewReader(unzippedContent)

  file, err := r.Next()
  if err != nil {
    panic(err)
  }
  
  if file.Name != "README.md" {
    panic("Expected README.md")
  }

  data, err := io.ReadAll(r)
  if err != nil {
    panic(err)
  }
  fmt.Println(string(data))
}

Documentation

Index

Constants

View Source
const (
	Type         = "git"
	TypeV1Alpha1 = Type + runtime.VersionSeparator + "v1alpha1"

	UpperType         = "Git"
	UpperTypeV1Alpha1 = UpperType + runtime.VersionSeparator + "v1alpha1"
)

Variables

This section is empty.

Functions

func AddConfig

func AddConfig(opts flagsets.ConfigOptions, config flagsets.Config) error

Types

type AccessSpec

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

	// Repository is the repository URL
	Repository string `json:"repository"`

	// Ref defines the hash of the commit
	Ref string `json:"ref,omitempty"`

	// Commit defines the hash of the commit in string format to checkout from the Ref
	Commit string `json:"commit,omitempty"`
}

AccessSpec describes the access for a GitHub registry.

func New

func New(url string, opts ...AccessSpecOptions) *AccessSpec

New creates a new git registry access spec version v1.

func (*AccessSpec) AccessMethod

func (*AccessSpec) Describe

func (a *AccessSpec) Describe(internal.Context) string

func (*AccessSpec) GetType

func (*AccessSpec) GetType() string

func (*AccessSpec) GlobalAccessSpec

func (a *AccessSpec) GlobalAccessSpec(accspeccpi.Context) accspeccpi.AccessSpec

func (*AccessSpec) IsLocal

func (*AccessSpec) IsLocal(internal.Context) bool

type AccessSpecOptions

type AccessSpecOptions func(s *AccessSpec)

AccessSpecOptions defines a set of options which can be applied to the access spec.

func WithCommit

func WithCommit(commit string) AccessSpecOptions

func WithRef

func WithRef(ref string) AccessSpecOptions

Jump to

Keyboard shortcuts

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