diff --git a/CONTRIBUTE.md b/.github/CONTRIBUTING.md similarity index 78% rename from CONTRIBUTE.md rename to .github/CONTRIBUTING.md index 21652cca5..87b43196b 100644 --- a/CONTRIBUTE.md +++ b/.github/CONTRIBUTING.md @@ -1,18 +1,20 @@ ![Mizu: The API Traffic Viewer for Kubernetes](assets/mizu-logo.svg) -# CONTRIBUTE + +# Contributing to Mizu + We welcome code contributions from the community. Please read and follow the guidelines below. ## Communication + * Before starting work on a major feature, please reach out to us via [GitHub](https://github.com/up9inc/mizu), [Slack](https://join.slack.com/share/zt-u6bbs3pg-X1zhQOXOH0yEoqILgH~csw), [email](mailto:mizu@up9.com), etc. We will make sure no one else is already working on it. A _major feature_ is defined as any change that is > 100 LOC altered (not including tests), or changes any user-facing behavior * Small patches and bug fixes don't need prior communication. -## Contribution requirements +## Contribution Requirements + * Code style - most of the code is written in Go, please follow [these guidelines](https://golang.org/doc/effective_go) -* Go-tools compatible (`go get`, `go test`, etc) -* Unit-test coverage can’t go down .. +* Go-tools compatible (`go get`, `go test`, etc.) +* Code coverage for unit tests must not decrease. * Code must be usefully commented. Not only for developers on the project, but also for external users of these packages * When reviewing PRs, you are encouraged to use Golang's [code review comments page](https://github.com/golang/go/wiki/CodeReviewComments) - - - +* Project follows [Google JSON Style Guide](https://google.github.io/styleguide/jsoncstyleguide.xml) for the REST APIs that are provided. diff --git a/tap/api/api.go b/tap/api/api.go index 60020222b..928734712 100644 --- a/tap/api/api.go +++ b/tap/api/api.go @@ -9,13 +9,13 @@ import ( type Protocol struct { Name string `json:"name"` - LongName string `json:"long_name"` + LongName string `json:"longName"` Abbreviation string `json:"abbreviation"` Version string `json:"version"` - BackgroundColor string `json:"background_color"` - ForegroundColor string `json:"foreground_color"` - FontSize int8 `json:"font_size"` - ReferenceLink string `json:"reference_link"` + BackgroundColor string `json:"backgroundColor"` + ForegroundColor string `json:"foregroundColor"` + FontSize int8 `json:"fontSize"` + ReferenceLink string `json:"referenceLink"` Ports []string `json:"ports"` Priority uint8 `json:"priority"` } @@ -50,8 +50,8 @@ type CounterPair struct { } type GenericMessage struct { - IsRequest bool `json:"is_request"` - CaptureTime time.Time `json:"capture_time"` + IsRequest bool `json:"isRequest"` + CaptureTime time.Time `json:"captureTime"` Payload interface{} `json:"payload"` } @@ -102,8 +102,8 @@ type MizuEntry struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time - ProtocolName string `json:"protocol_key" gorm:"column:protocolKey"` - ProtocolVersion string `json:"protocol_version" gorm:"column:protocolVersion"` + ProtocolName string `json:"protocolKey" gorm:"column:protocolKey"` + ProtocolVersion string `json:"protocolVersion" gorm:"column:protocolVersion"` Entry string `json:"entry,omitempty" gorm:"column:entry"` EntryId string `json:"entryId" gorm:"column:entryId"` Url string `json:"url" gorm:"column:url"` @@ -135,17 +135,17 @@ type BaseEntryDetails struct { Id string `json:"id,omitempty"` Protocol Protocol `json:"protocol,omitempty"` Url string `json:"url,omitempty"` - RequestSenderIp string `json:"request_sender_ip,omitempty"` + RequestSenderIp string `json:"requestSenderIp,omitempty"` Service string `json:"service,omitempty"` Path string `json:"path,omitempty"` Summary string `json:"summary,omitempty"` - StatusCode int `json:"status_code"` + StatusCode int `json:"statusCode"` Method string `json:"method,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` - SourceIp string `json:"source_ip,omitempty"` - DestinationIp string `json:"destination_ip,omitempty"` - SourcePort string `json:"source_port,omitempty"` - DestinationPort string `json:"destination_port,omitempty"` + SourceIp string `json:"sourceIp,omitempty"` + DestinationIp string `json:"destinationIp,omitempty"` + SourcePort string `json:"sourcePort,omitempty"` + DestinationPort string `json:"destinationPort,omitempty"` IsOutgoing bool `json:"isOutgoing,omitempty"` Latency int64 `json:"latency,omitempty"` Rules ApplicableRules `json:"rules,omitempty"` diff --git a/ui/src/components/EntriesList.tsx b/ui/src/components/EntriesList.tsx index 0de56c611..6b1ae69f9 100644 --- a/ui/src/components/EntriesList.tsx +++ b/ui/src/components/EntriesList.tsx @@ -54,8 +54,8 @@ export const EntriesList: React.FC = ({entries, setEntries, fo const filterEntries = useCallback((entry) => { if(methodsFilter.length > 0 && !methodsFilter.includes(entry.method.toLowerCase())) return; if(pathFilter && entry.path?.toLowerCase()?.indexOf(pathFilter) === -1) return; - if(statusFilter.includes(StatusType.SUCCESS) && entry.status_code >= 400) return; - if(statusFilter.includes(StatusType.ERROR) && entry.status_code < 400) return; + if(statusFilter.includes(StatusType.SUCCESS) && entry.statusCode >= 400) return; + if(statusFilter.includes(StatusType.ERROR) && entry.statusCode < 400) return; return entry; },[methodsFilter, pathFilter, statusFilter]) diff --git a/ui/src/components/EntryDetailed.tsx b/ui/src/components/EntryDetailed.tsx index 9527876fc..56ffd583b 100644 --- a/ui/src/components/EntryDetailed.tsx +++ b/ui/src/components/EntryDetailed.tsx @@ -72,7 +72,7 @@ export const EntryDetailed: React.FC = ({entryData}) => { /> {entryData.data && } <> - {entryData.data && } + {entryData.data && } }; diff --git a/ui/src/components/EntryListItem/EntryListItem.tsx b/ui/src/components/EntryListItem/EntryListItem.tsx index 529f65895..2d64c7793 100644 --- a/ui/src/components/EntryListItem/EntryListItem.tsx +++ b/ui/src/components/EntryListItem/EntryListItem.tsx @@ -16,13 +16,13 @@ interface Entry { summary: string, service: string, id: string, - status_code?: number; + statusCode?: number; url?: string; timestamp: Date; - source_ip: string, - source_port: string, - destination_ip: string, - destination_port: string, + sourceIp: string, + sourcePort: string, + destinationIp: string, + destinationPort: string, isOutgoing?: boolean; latency: number; rules: Rules; @@ -41,7 +41,7 @@ interface EntryProps { } export const EntryItem: React.FC = ({entry, setFocusedEntryId, isSelected}) => { - const classification = getClassification(entry.status_code) + const classification = getClassification(entry.statusCode) let ingoingIcon; let outgoingIcon; switch(classification) { @@ -103,11 +103,11 @@ export const EntryItem: React.FC = ({entry, setFocusedEntryId, isSel className={`${styles.row} ${isSelected ? styles.rowSelected : backgroundColor}`} onClick={() => setFocusedEntryId(entry.id)} - style={{border: isSelected ? `1px ${entry.protocol.background_color} solid` : "1px transparent solid"}} + style={{border: isSelected ? `1px ${entry.protocol.backgroundColor} solid` : "1px transparent solid"}} > - {((entry.protocol.name === "http" && "status_code" in entry) || entry.status_code !== 0) &&
- + {((entry.protocol.name === "http" && "statusCode" in entry) || entry.statusCode !== 0) &&
+
}
@@ -116,13 +116,13 @@ export const EntryItem: React.FC = ({entry, setFocusedEntryId, isSel
- {entry.source_port} + {entry.sourcePort} {entry.isOutgoing ? Ingoing traffic : Outgoing traffic } - {entry.destination_port} + {entry.destinationPort}
diff --git a/ui/src/components/UI/Protocol.tsx b/ui/src/components/UI/Protocol.tsx index 794bee8fc..0b031bf18 100644 --- a/ui/src/components/UI/Protocol.tsx +++ b/ui/src/components/UI/Protocol.tsx @@ -3,12 +3,12 @@ import styles from './style/Protocol.module.sass'; export interface ProtocolInterface { name: string - long_name: string + longName: string abbreviation: string - background_color: string - foreground_color: string - font_size: number - reference_link: string + backgroundColor: string + foregroundColor: string + fontSize: number + referenceLink: string ports: string[] inbound_ports: string } @@ -20,29 +20,29 @@ interface ProtocolProps { const Protocol: React.FC = ({protocol, horizontal}) => { if (horizontal) { - return + return - {protocol.long_name} + {protocol.longName} } else { - return + return {protocol.abbreviation}