Skip to content

Commit 89220e1

Browse files
committed
Prepare repo to be public
1 parent 8f90a1d commit 89220e1

File tree

9 files changed

+36
-111
lines changed

9 files changed

+36
-111
lines changed

COOKBOOK.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
IRIS COOKBOOK
1+
IRISCTL COOKBOOK
22

33
1. Analyze Command (irisctl analyze)
44
1.1. Measurements

DEV.md

+10-52
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,5 @@
1-
# CLI
2-
3-
irisctl [--brief] [--curl] [--no-delete] [--no-auto-login] [--verbose] <command>
4-
5-
agents [--tag]
6-
agents [<agent>...]
7-
8-
analyze [--before] [--after] [--state <state>] [--tag <tag>] [--tags-and] [--links-file <file>]
9-
analyze hours [--chart]
10-
analyze tags
11-
analyze states
12-
13-
auth <subcommand>
14-
auth login [--cookie]
15-
auth logout [--cookie]
16-
auth register <user-details>...
17-
18-
check <subcommand>
19-
check agents [--uptime] [--net]
20-
check containers [--errors] [--logs]
21-
22-
maint <subcommand>
23-
maint dq <queue-name>...
24-
maint dq --upload <queue-name> <actor-string>
25-
maint dq --delete <queue-name> <redis-message-id>
26-
maint delete <meas-uuid>
27-
28-
meas [--state <state>] [--tag <tag>] [--all] [--public]
29-
meas --uuid <meas-uuid>...
30-
meas --target-list <meas-uuid> <agent-uuid>
31-
meas request <meas-md-file>...
32-
meas delete <meas-uuid>...
33-
meas edit <meas-uuid> <meas-md-file>
34-
35-
status (has no flags)
36-
37-
targets <subcommand>
38-
targets all
39-
targets [--with-conent] key <key>...
40-
targets upload [--probe] <file>
41-
targets delete <key>
42-
43-
users <subcommand>
44-
users me
45-
users all [--verified]
46-
users delete [--dry-run] <user-id>...
47-
users patch <user-id> <user-details>
48-
users services <meas-uuid>
1+
The source code for `irisctl` follows specific conventions.
2+
If you'd like to contribute, please adhere to these guidelines.
493

504
# Naming Conventions
515

@@ -58,7 +12,7 @@ users services <meas-uuid>
5812
f<subcmd><flag> // irisctl monitor agents --status => fAgentStatus
5913

6014

61-
## cobra.Command Initialization
15+
# cobra.Command Initialization
6216

6317
## Usage() and Help() functions should be set where the command is defined. For example:
6418

@@ -86,6 +40,10 @@ users services <meas-uuid>
8640
return nil
8741
}
8842

89-
## Fatal Functions
90-
- cliFatal()
91-
- fatal()
43+
# Fatal Functions
44+
cliFatal() // invalid command line
45+
fatal() // errors that should terminate execution
46+
47+
# Annotations
48+
// TODO: mark incomplete work or improvements to be made
49+
// XXX: mark hacky code that needs a better solution but is left as-is for now

Makefile

+1-37
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ SRC=cmd/irisctl/main.go \
1717
CMD=irisctl
1818

1919
.PHONY: $(CMD)
20-
build: $(CMD)
21-
@echo cp ./$(CMD) "$(HOME)/Google\\ Drive/My\ Drive/irisctl/$(CMD)"
22-
2320
$(CMD): $(SRC)
2421
go build -o $(CMD) ./cmd/irisctl/...
25-
@ls -l $(CMD)
2622

2723
.PHONY: tags
2824
tags:
@@ -32,37 +28,5 @@ good:
3228
for i in $(SRC); do echo $$i; gofmt -w -s $$i; done
3329
golangci-lint run ./...
3430

35-
wc:
36-
wc -l $(SRC)
37-
38-
allmd:
39-
./$(CMD) meas all -a allmd
40-
jq . allmd | more
41-
4231
users: $(CMD)
43-
./$(CMD) users all > /tmp/__
44-
jq -r '.results[]|"\(.firstname) \(.lastname) \(.is_active) \(.is_superuser) \(.is_verified)"' /tmp/__
45-
rm -f /tmp/__
46-
47-
agents:
48-
./$(CMD).good agent all | tee /tmp/__
49-
jq -r '.results[] | "\(.uuid) \(.state) \(.parameters.hostname) \(.parameters.version)"' /tmp/__ | awk '{ printf("%s %s %-24s %s\n", $$1, $$2, $$3, $$4) }'
50-
#rm -f /tmp/__
51-
52-
whatis:
53-
-./$(CMD) users all | grep "${UUID}"
54-
-./$(CMD) agent all | grep "${UUID}"
55-
-./$(CMD) meaas all | grep "${UUID}"
56-
57-
examples:
58-
@echo ./$(CMD) analyze runs allmd
59-
@echo ./$(CMD) analyze -v runs allmd
60-
@echo ./$(CMD) analyze --after 2024-01-01 --state finished -t zeph runs allmd
61-
@echo ./$(CMD) analyze -v --after 2024-01-01 --state finished -t zeph runs allmd
62-
@echo ./$(CMD) analyze --before 2024-01-01 --state finished -t zeph runs allmd
63-
@echo ./$(CMD) analyze -v --after 2024-01-01 --state finished -t zeph runs allmd
64-
@echo ./$(CMD) analyze -v --after 2024-01-01 --state finished tags allmd
65-
@echo ./$(CMD) analyze -v --after 2024-01-01 --state finished hours allmd
66-
@echo ./$(CMD) analyze -v --after 2024-01-01 -t ipv6-hitlist.json runs allmd
67-
@echo ./$(CMD) analyze -v --after 2023-09-01 -t ipv6-hitlist.json hours allmd
68-
@echo ./$(CMD) analyze -v --after 2023-09-01 -t exhaustive-lip6.json hours allmd
32+
./$(CMD) users all | jq -r '.results[]|"\(.firstname) \(.lastname) \(.is_active) \(.is_superuser) \(.is_verified)"'

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11

22

3-
`irisctl` is a command line tool to make it easier to work Iris. It has two main command groups:
3+
`irisctl` is a command line tool to make it easier for Iris developers
4+
and users to work Iris.
5+
6+
**IMPORTANT:** Since Iris is not available as a public service at
7+
this time, `irisctl` unit tests and code coverage are still under
8+
development. We will bring `irisctl` up to production-quality
9+
standards as development continues.
10+
11+
`irisctl` has two main command groups:
12+
413
- Iris API commands
514
- Non-API commands for checking and analyzing Iris data
615

716
To build `irisctl` from source, you need the standard developments
8-
tools (make, git) and also the Go language compiler on your machine.
17+
tools (`make`, `git`) and also the Go language compiler on your machine.
918
```
1019
$ cd /to/your/work/directory
1120
$ git clone https://github.com/dioptra-io/irisctl.git
@@ -20,6 +29,3 @@ for your password (unless the `IRIS_PASSWORD` environment variable
2029
is set to your password).
2130

2231
There are usage examples in `COOKBOOK.txt`.
23-
24-
Please note that `irisctl` is work-in-progress and currently does
25-
not meet production-quality requirements (e.g., it lacks unit tests).

cmd/irisctl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func main() {
6666
irisctlCmd.PersistentFlags().BoolVarP(&fRootVerbose, "verbose", "v", false, "enable verbose mode (more output)")
6767
irisctlCmd.PersistentFlags().StringVarP(&fRootJqFilter, "jq-filter", "j", ".", "jq filter")
6868
irisctlCmd.PersistentFlags().StringVarP(&fIrisAPIUrl, "iris-api-url", "u", "https://api.iris.dioptra.io", "specify the iris api url")
69-
// XXX Instead of hard-coding a default value, we should find a measurement UUID of the user.
69+
// TODO: Instead of hard-coding a default value, we should find a measurement UUID of the user.
7070
irisctlCmd.PersistentFlags().StringVarP(&fMeasurementUUID, "meas-uuid", "m", "a75482d1-8c5c-4d56-845e-fc3861047992", "specify the measurement uuid for the gusethosue credentials")
7171
irisctlCmd.SetUsageFunc(common.Usage)
7272
irisctlCmd.SetHelpFunc(common.Help)

internal/analyze/analyze.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ func measDuration(measurement common.Measurement) int {
778778
}
779779
durationCS = append(durationCS, float64(s.Sub(c).Seconds()))
780780
durationSE = append(durationSE, float64(e.Sub(s).Seconds()))
781-
expectedDuration := []time.Duration{5, 24} // XXX Provide command line flags to specify these
781+
expectedDuration := []time.Duration{5, 24} // TODO: Provide command line flags to specify these
782782
for i, t := range []string{"zeph-gcp-daily.json", "collection:exhaustive"} {
783783
if common.MatchTag(measurement.Tags, []string{t}, fAnalyzeTagsAnd) && e.Sub(s) > expectedDuration[i]*time.Hour {
784784
return DurationTooLong

internal/list/list.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func listArgs(cmd *cobra.Command, args []string) error {
106106
return nil
107107
}
108108

109-
// XXX This function is pretty ugly and needs to be refactored.
109+
// TODO: This function is pretty ugly and needs to be refactored.
110110
func list(cmd *cobra.Command, args []string) {
111111
if fListUUID {
112112
for _, arg := range args {
@@ -218,8 +218,8 @@ func printMeasDetailsBQ(measurement common.Measurement) {
218218
}
219219

220220
fmt.Printf("%s,", measurement.Tool) // tool
221-
// XXX We need to parse the target list to determine ipv4 and ipv6 values.
222-
// This is a dirty hack for now and should be cleaned up.
221+
// XXX: We need to parse the target list to determine ipv4 and ipv6 values.
222+
// This is a dirty hack for now and should be cleaned up.
223223
ipv4 := false
224224
ipv6 := false
225225
if len(measurement.Agents) > 0 {

internal/maint/maint.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
var (
1616
// Command, its flags, subcommands, and their flags.
1717
// maint dq <queue-name>...
18-
// maint dq --post <queue-name> [<actor-string>] (XXX actor-string: watch_measurement_agent)
18+
// maint dq --post <queue-name> [<actor-string>] (actor-string: watch_measurement_agent)
1919
// maint dq --delete <queue-name> <redis-message-id>
2020
// maint meas delete <meas-uuid>
2121
cmdName = "maint"

internal/users/users.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,12 @@ func UsersCmd() *cobra.Command {
108108
// GetUserPass returns username and password obtained from
109109
// users/me/services of Iris API.
110110
//
111-
// XXX For now, this function receives the measurement UUID from flags
112-
//
113-
// but going forward it might use find a measurement UUID of the user
114-
// running this instance of irisctl.
115-
//
116-
// XXX We wait one second before returning because we have noticed that
117-
//
118-
// sometimes Iris hasn't fully read the user file that includes the
119-
// newly created username and password.
111+
// TODO: For now, this function receives the measurement UUID from
112+
// flags but going forward it might find a measurement UUID of
113+
// the user running this instance of irisctl.
120114
func GetUserPass() (string, error) {
121115
if meServices.ClickHouse.Username == "" {
122-
uuid := common.RootFlagString("meas-uuid") // it is slightly better than hardcoding the measurement but for now it's adequate
116+
uuid := common.RootFlagString("meas-uuid")
123117
url := fmt.Sprintf("%s/me/services?measurement_uuid=%v", common.APIEndpoint(common.UsersAPISuffix), uuid)
124118
jsonData, err := common.Curl(auth.GetAccessToken(), false, "GET", url)
125119
if err != nil {
@@ -129,6 +123,9 @@ func GetUserPass() (string, error) {
129123
return "", err
130124
}
131125
}
126+
// We wait one second before returning because we have noticed that
127+
// sometimes Iris hasn't fully read the user file that includes the
128+
// newly created username and password.
132129
time.Sleep(1 * time.Second)
133130
return meServices.ClickHouse.Username + ":" + meServices.ClickHouse.Password, nil
134131
}

0 commit comments

Comments
 (0)