Skip to content

Commit

Permalink
Update to go 1.20.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed May 21, 2023
1 parent dfa9a32 commit 66bdcf1
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install:
- go get github.com/udhos/lockfile
- go get github.com/udhos/equalfile
- go get github.com/udhos/difflib
- go get gopkg.in/yaml.v2
- go get gopkg.in/yaml.v3
- go get golang.org/x/crypto/ssh
- go get github.com/aws/aws-sdk-go/aws

Expand Down
49 changes: 11 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,13 @@ Quick Start - Short version

This is how to boot up Jazigo very quickly:

## With Go Modules (starting from Go 1.11)

git clone https://github.com/udhos/jazigo ;# clone outside of GOPATH
cd jazigo
go install ./jazigo
mkdir etc repo log
JAZIGO_HOME=$PWD ~/go/bin/jazigo

## Without Go Modules (before Go 1.11)

go get github.com/udhos/jazigo
cd ~/go/src/github.com/udhos/jazigo
./build.sh
mkdir etc repo log
JAZIGO_HOME=$PWD ~/go/bin/jazigo
Open jazigo interface - http://localhost:8080/jazigo/

Quick Start - Detailed version
==============================
Expand All @@ -92,34 +84,15 @@ Installation and usage are supposed to be dead simple. If you hit any surprising

If you want to build from source code, start from step 1.

If you downloaded the executable binary file, start from step 5.

1\. Setup GOPATH as usual

Example:
If you downloaded the executable binary file, start from step 2.

#export GOPATH=~/go ;# starting from Go 1.8, GOPATH is no longer required
mkdir ~/go
1\. Build from source

2\. Get dependencies

go get github.com/icza/gowut/gwu
go get github.com/udhos/lockfile
go get github.com/udhos/equalfile
go get github.com/udhos/difflib
go get gopkg.in/yaml.v2
go get golang.org/x/crypto/ssh
go get github.com/aws/aws-sdk-go

3\. Get source code

go get github.com/udhos/jazigo

4\. Compile and install

go install github.com/udhos/jazigo/jazigo
git clone https://github.com/udhos/jazigo
cd jazigo
go install ./...

5\. Decide where to store config, backup, log and static www files
2\. Decide where to store config, backup, log and static www files

Example:

Expand All @@ -133,7 +106,7 @@ By default, Jazigo looks for directories 'etc', 'repo', 'log', and 'www' under $
If left undefined, JAZIGO_HOME defaults to /var/jazigo.
See command line options to fine tune filesystem locations.

6\. Copy static files (CSS and images) to $JAZIGO_HOME/www
3\. Copy static files (CSS and images) to $JAZIGO_HOME/www

Example:

Expand All @@ -147,19 +120,19 @@ Example:
wget https://raw.githubusercontent.com/udhos/jazigo/master/www/jazigo.css
wget https://raw.githubusercontent.com/udhos/jazigo/master/www/GitHub-Mark-32px.png

7\. Run jazigo once (see -runOnce option)
4\. Run jazigo once (see -runOnce option)

`$GOPATH/bin/jazigo -runOnce`

Watch messages logged to standard output for errors.

Hint: Since root privileges are usually not needed, run Jazigo as a regular user.

8\. Run jazigo forever
5\. Run jazigo forever

`$GOPATH/bin/jazigo -disableStdoutLog`

9\. Open the web interface
6\. Open the web interface

Point web browser at: [http://localhost:8080/jazigo](http://localhost:8080/jazigo)

Expand Down
93 changes: 12 additions & 81 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,92 +1,23 @@
#!/bin/sh
#!/bin/bash

step=0
go install golang.org/x/vuln/cmd/govulncheck@latest

msg() {
step=$((step+1))
echo >&2 $step. $*
}
gofmt -s -w .

get() {
i=$1
msg fetching $i
go get $i
msg fetching $i - done
}
revive ./...

get github.com/icza/gowut/gwu
get github.com/udhos/difflib
get github.com/udhos/lockfile
get github.com/udhos/equalfile
get gopkg.in/yaml.v2
get golang.org/x/crypto/ssh
get github.com/aws/aws-sdk-go
#get honnef.co/go/simple/cmd/gosimple
#get honnef.co/go/tools/cmd/staticcheck
#gocyclo -over 15 .

src=`find . -type f | egrep '\.go$'`
go mod tidy

msg fmt
gofmt -s -w $src
msg fix
go tool fix $src
msg vet
go tool vet .
govulncheck ./...

msg install
pkg=github.com/udhos/jazigo
go install $pkg/jazigo
go env -w CGO_ENABLED=1

# go get honnef.co/go/simple/cmd/gosimple
s=$GOPATH/bin/gosimple
simple() {
msg simple - this is slow, please standby
# gosimple cant handle source files from multiple packages
$s jazigo/*.go
$s conf/*.go
$s dev/*.go
$s store/*.go
$s temp/*.go
}
[ -x "$s" ] && simple
go test -race ./...

# go get github.com/golang/lint/golint
l=$GOPATH/bin/golint
lint() {
msg lint
# golint cant handle source files from multiple packages
$l jazigo/*.go
$l conf/*.go
$l dev/*.go
$l store/*.go
$l temp/*.go
}
[ -x "$l" ] && lint
go env -w CGO_ENABLED=0

# go get honnef.co/go/tools/cmd/staticcheck
sc=$GOPATH/bin/staticcheck
static() {
msg staticcheck - this is slow, please standby
# staticcheck cant handle source files from multiple packages
$sc jazigo/*.go
$sc conf/*.go
$sc dev/*.go
$sc store/*.go
$sc temp/*.go
}
[ -x "$sc" ] && static
go install ./...

msg test dev - this may take a while, please stand by
go test github.com/udhos/jazigo/dev

msg test store
if [ -z "$JAZIGO_S3_REGION" ]; then
echo >&2 JAZIGO_S3_REGION undefined -- for S3 testing, set JAZIGO_S3_REGION=region
fi
if [ -z "$JAZIGO_S3_FOLDER" ]; then
echo >&2 JAZIGO_S3_FOLDER undefined -- for S3 testing, set JAZIGO_S3_FOLDER=bucket/folder
fi
go test github.com/udhos/jazigo/store

msg test jazigo
go test github.com/udhos/jazigo/jazigo
go env -u CGO_ENABLED
3 changes: 2 additions & 1 deletion conf/conf.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Package conf handles configuration.
package conf

import (
"time"

"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"

"github.com/udhos/jazigo/store"
)
Expand Down
1 change: 1 addition & 0 deletions dev/control.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package dev provides access to multiple devices.
package dev

import (
Expand Down
6 changes: 3 additions & 3 deletions dev/model_fortios.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func registerModelFortiOS(logger hasPrintf, t *DeviceTable) {
"config system global", // enter config: valid only for vdom
"config system console", // enter config: valid only for non-vdom
"set output standard", // disable paging
"end", // exit config
"get system status", // system information
"show", // get configuration
"end", // exit config
"get system status", // system information
"show", // get configuration
}

promptPattern := `\S+\s#\s$` // "hostname # "
Expand Down
23 changes: 13 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ module github.com/udhos/jazigo

require (
github.com/aws/aws-sdk-go v1.15.16
github.com/icza/gowut v1.3.0
github.com/udhos/difflib v0.0.0-20170223180222-9237ff6aafff
github.com/udhos/equalfile v0.0.0-20180725151512-a22d6261a8df
github.com/udhos/lockfile v0.0.0-20160928001432-1d49c987357a
golang.org/x/crypto v0.9.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ini/ini v1.25.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20180820052304-89baedc74dd7 // indirect
github.com/icza/gowut v1.3.0
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 // indirect
github.com/jtolds/gls v4.2.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf // indirect
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect
github.com/stretchr/testify v1.2.2 // indirect
github.com/udhos/difflib v0.0.0-20170223180222-9237ff6aafff
github.com/udhos/equalfile v0.0.0-20180725151512-a22d6261a8df
github.com/udhos/lockfile v0.0.0-20160928001432-1d49c987357a
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac
golang.org/x/net v0.0.0-20180821023952-922f4815f713 // indirect
golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v2 v2.2.1
golang.org/x/sys v0.8.0 // indirect
)

go 1.13
go 1.20
19 changes: 9 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ github.com/udhos/equalfile v0.0.0-20180725151512-a22d6261a8df h1:SDnf0lMzWQcbGOL
github.com/udhos/equalfile v0.0.0-20180725151512-a22d6261a8df/go.mod h1:1LOX9HjdFMke7ryP3IPby09FkswyY5KzhhsT37wLz/Y=
github.com/udhos/lockfile v0.0.0-20160928001432-1d49c987357a h1:286YGPLaLItW0JKx1IePghZEhuNLHNEGPOIsD+25Yx4=
github.com/udhos/lockfile v0.0.0-20160928001432-1d49c987357a/go.mod h1:w5A2nWhTT88JgIVjPxgCNvD8yrXpXSckwYh924u8a0I=
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg=
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180821023952-922f4815f713 h1:rMJUcaDGbG+X967I4zGKCq5laYqcGKJmpB+3jhpOhPw=
golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 h1:0w2EXzxbB03VAzqwe3csbadu4CPhMRtxCz/rjw9gkic=
golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
74 changes: 38 additions & 36 deletions jazigo/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,51 @@ Jazigo is a tool written in Go for retrieving configuration for multiple network
See also: https://github.com/udhos/jazigo
Usage:
jazigo [flag]
jazigo [flag]
Flags are:
-configPathPrefix string
configuration path prefix
-deviceDelete
delete devices specified in stdin
-deviceImport
import devices from stdin
-deviceList
list devices to stdout
-devicePurge
purge devices specified in stdin
-disableStdoutLog
disable logging to stdout
-logCheckInterval duration
interval for checking log file size
-logMaxFiles int
number of log files to keep
-logMaxSize int
size limit for log file
-logPathPrefix string
log path prefix
-repositoryPath string
repository path
-runOnce
exit after scanning all devices once
-s3region string
AWS S3 region
-webListen string
address:port for web UI
-wwwStaticPath string
directory for static www content
-configPathPrefix string
configuration path prefix
-deviceDelete
delete devices specified in stdin
-deviceImport
import devices from stdin
-deviceList
list devices to stdout
-devicePurge
purge devices specified in stdin
-disableStdoutLog
disable logging to stdout
-logCheckInterval duration
interval for checking log file size
-logMaxFiles int
number of log files to keep
-logMaxSize int
size limit for log file
-logPathPrefix string
log path prefix
-repositoryPath string
repository path
-runOnce
exit after scanning all devices once
-s3region string
AWS S3 region
-webListen string
address:port for web UI
-wwwStaticPath string
directory for static www content
By default, jazigo looks for these path prefixes under $JAZIGO_HOME:
etc/jazigo.conf. (can be overridden with -configPathPrefix)
log/jazigo.log. (can be overridden with -logPathPrefix)
repo (can be overridden with -repositoryPath)
www (can be overridden with -wwwStaticPath)
etc/jazigo.conf. (can be overridden with -configPathPrefix)
log/jazigo.log. (can be overridden with -logPathPrefix)
repo (can be overridden with -repositoryPath)
www (can be overridden with -wwwStaticPath)
If $JAZIGO_HOME is not defined, jazigo home defaults to /var/jazigo.
Since root privileges are usually not needed, run the jazigo application as a regular user.
*/
package main
Loading

0 comments on commit 66bdcf1

Please sign in to comment.