omahaproxy

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 10 Imported by: 1

README

NOTE: the Omaha Proxy service has been permanently shut down, and the API is no longer available. If you need to still get the versions, please see this fork of the project.

omahaproxy

Package omahaproxy provides a simple client to retrieve data from Omaha Proxy.

Example

// _example/example.go
package main

import (
	"context"
	"flag"
	"fmt"
	"os"
	"runtime"

	"github.com/chromedp/omahaproxy"
)

func main() {
	platform := "linux"
	switch runtime.GOOS {
	case "windows":
		platform = "win"
		if runtime.GOARCH == "amd64" {
			platform += "64"
		}
	case "darwin":
		platform = "mac"
		if runtime.GOARCH == "aarch64" {
			platform += "_arm64"
		}
	}
	verbose := flag.Bool("v", false, "verbose")
	osstr := flag.String("os", platform, "os")
	channel := flag.String("channel", "stable", "channel")
	flag.Parse()
	if err := run(context.Background(), *verbose, *osstr, *channel); err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(1)
	}
}

func run(ctx context.Context, verbose bool, os, channel string) error {
	// enable verbose
	var opts []omahaproxy.Option
	if verbose {
		opts = append(opts, omahaproxy.WithLogf(fmt.Printf))
	}
	// create client
	cl := omahaproxy.New(opts...)
	// retrieve recent
	releases, err := cl.Recent(ctx)
	if err != nil {
		return err
	}
	for _, release := range releases {
		fmt.Printf("os: %s channel: %s version: %s\n", release.OS, release.Channel, release.Version)
	}
	// show latest
	ver, err := cl.Latest(ctx, os, channel)
	if err != nil {
		return err
	}
	fmt.Printf("latest: %s\n", ver)
	return nil
}

Documentation

Overview

Package omahaproxy provides a client and utilities for working with the Chrome Omaha Proxy.

See: https://omahaproxy.appspot.com

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = http.DefaultTransport

DefaultTransport is the default transport.

Functions

This section is empty.

Types

type Client

type Client struct {
	Transport http.RoundTripper
}

Client is a omaha proxy client.

func New

func New(opts ...Option) *Client

New creates a new omaha proxy client.

func (*Client) Entries

func (cl *Client) Entries(ctx context.Context) ([]VersionEntry, error)

Entries retrieves latest version entries from the omaha proxy.

func (*Client) Latest

func (cl *Client) Latest(ctx context.Context, os, channel string) (Version, error)

Latest returns the latest version for the provided os and channel from the omaha proxy.

func (*Client) Recent

func (cl *Client) Recent(ctx context.Context) ([]Release, error)

Recent retrieves the recent release history from the omaha proxy.

type Option

type Option func(*Client)

Option is a omaha proxy client option.

func WithLogf

func WithLogf(logf interface{}, opts ...httplog.Option) Option

WithLogf is a omaha proxy client option to set a log handler for HTTP requests and responses.

func WithTransport

func WithTransport(transport http.RoundTripper) Option

WithTransport is a omaha proxy client option to set the http transport.

type Release

type Release struct {
	OS        string
	Channel   string
	Version   string
	Timestamp time.Time
}

Release holds browser release information.

func Recent

func Recent(ctx context.Context, opts ...Option) ([]Release, error)

Recent returns the recent release information from the omaha proxy.

type Version

type Version struct {
	BranchCommit       string `json:"branch_commit"`
	BranchBasePosition string `json:"branch_base_position"`
	SkiaCommit         string `json:"skia_commit"`
	V8Version          string `json:"v8_version"`
	PreviousVersion    string `json:"previous_version"`
	V8Commit           string `json:"v8_commit"`
	TrueBranch         string `json:"true_branch"`
	PreviousReldate    string `json:"previous_reldate"`
	BranchBaseCommit   string `json:"branch_base_commit"`
	Version            string `json:"version"`
	CurrentReldate     string `json:"current_reldate"`
	CurrentVersion     string `json:"current_version"`
	OS                 string `json:"os"`
	Channel            string `json:"channel"`
	ChromiumCommit     string `json:"chromium_commit"`
}

Version wraps browser version information.

func Latest

func Latest(ctx context.Context, os, channel string, opts ...Option) (Version, error)

Latest retrieves the latest version for the specified os and channel from the omaha proxy.

func (Version) String

func (v Version) String() string

String satisfies the fmt.Stringer interface.

type VersionEntry

type VersionEntry struct {
	OS       string    `json:"os"`
	Versions []Version `json:"versions"`
}

VersionEntry is a OS version entry detailing the available browser version entries.

func Entries

func Entries(ctx context.Context, opts ...Option) ([]VersionEntry, error)

Entries returns the latest version entries from the omaha proxy.

Directories

Path Synopsis
_example/example.go
_example/example.go

Jump to

Keyboard shortcuts

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