organization

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

README

go-whosonfirst-iterate-organization

Go package to implement the whosonfirst/go-whosonfirst-iterate/v2/emitter.Emitter interface for iterating multiple repositories in a GitHub organization.

Motivation

This package is designed for situations where you need to iterate over multiple Who's On First -style repositories in a GitHub organization.

Under the hood it is thin wrapper around the whosonfirst/go-whosonfirst-github package, used to fetch a list of repositories for an organization, and the whosonfirst/go-whosonfirst-iterate-git to fetch each repository and iterate over its files.

It implements the whosonfirst/go-whosonfirst-iterate/v2/emitter.Emitter interface so it will work with any existing code and callback functions designed for use with the go-whosonfirst-iterate package.

Documentation

Go Reference

Example

Iterate over all the sfomuseum-data/sfomuseum-data-flights-* repositories, excluding sfomuseum-data-flights-YYYY-MM, cloning each repository to /tmp before processing. (Each repository will be deleted after processing).

package main

import (
	_ "github.com/whosonfirst/go-whosonfirst-iterate-organization/v2"
)

import (
	"context"
	"io"
	"fmt"
	"testing"
	
	"github.com/whosonfirst/go-whosonfirst-iterate/v2/iterator"
)

func main()

	ctx := context.Background()

	iter_uri := "org:///tmp"
	
	iter_cb := func(ctx context.Context, path string, r io.ReadSeeker, args ...interface{}) error {
		fmt.Println(path)
		return nil
	}

	iter, _ := iterator.NewIterator(ctx, iter_uri, iter_cb)

	iter.IterateURIs(ctx, "sfomuseum-data://?prefix=sfomuseum-data-flights-&exclude=sfomuseum-data-flights-YYYY-MM")
}

Error handling omitted for the sake of brevity.

See also

Documentation

Overview

package organization implements the `whosonfirst/go-whosonfirst-iterate/v2/emitter.Emitter` interface for iterating multiple repositories in a GitHub organization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOrganizationEmitter

func NewOrganizationEmitter(ctx context.Context, uri string) (emitter.Emitter, error)

NewOrganizationEmitter returns a new `OrganizationEmitter` configured by 'uri' which takes the form of:

org://{PATH}?{PARAMETERS}

Where {PATH} is an optional path where individual Git repositories should be downloaded for processing; {PARAMETERS} is optional and may be any of the valid parameters used in URIs to create a new `whosonfirst/go-whosonfirst-iterate-git.GitEmitter`. If {PATH} is not defined then Git repositories are download in to, and processed from, memory. If {PATH} is defined any Git repositories downloaded will be remove after processing (unless the `?preserve=1` query parameter is present).

Types

type OrganizationEmitter

type OrganizationEmitter struct {
	emitter.Emitter
	// contains filtered or unexported fields
}

type OrganizationEmitter implements the `emitter.Emitter` interface for iterating multiple repositories in a GitHub organization.

func (*OrganizationEmitter) WalkURI

WalkURI fetchesone or more respositories belonging to a GitHub orgnization invoking 'cb' for each file in those respositores. The list of files to process is determined by 'uri' which takes the form of:

{GITHUB_ORGANIZATION}://?prefix={STRING}&exclude={STRING}&access_token={STRING}

Where {PREFIX} is zero or more "prefix" parameters to filter the list of repositories by for inclusion; {EXCLUDE} is zero or more "exclude" query parameters to filter the list of repositories by for exclusion; {ACCESS_TOKEN} is an optional GitHub API access token to include with the underlying calls to the GitHub API.

Jump to

Keyboard shortcuts

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