Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
/ omahaproxy Public archive

Package omahaproxy is a simple client for the Omaha Proxy

License

Notifications You must be signed in to change notification settings

chromedp/omahaproxy

Repository files navigation

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
}

About

Package omahaproxy is a simple client for the Omaha Proxy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages