Fix the JSON style to camelCase and rename CONTRIBUTE.md to CONTRIBUTING.md (#274)

* Fix the JSON style to camelCase and rename `CONTRIBUTE.md` to `CONTRIBUTING.md`

* Move `CONTRIBUTING.md` to `.github/` directory
This commit is contained in:
M. Mert Yıldıran 2021-09-13 10:55:46 +03:00 committed by GitHub
parent 7f880417e9
commit 30f07479cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 50 deletions

View File

@ -1,18 +1,20 @@
![Mizu: The API Traffic Viewer for Kubernetes](assets/mizu-logo.svg) ![Mizu: The API Traffic Viewer for Kubernetes](assets/mizu-logo.svg)
# CONTRIBUTE
# Contributing to Mizu
We welcome code contributions from the community. We welcome code contributions from the community.
Please read and follow the guidelines below. Please read and follow the guidelines below.
## Communication ## 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 * 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. * 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) * 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) * Go-tools compatible (`go get`, `go test`, etc.)
* Unit-test coverage cant go down .. * 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 * 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) * 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.

View File

@ -9,13 +9,13 @@ import (
type Protocol struct { type Protocol struct {
Name string `json:"name"` Name string `json:"name"`
LongName string `json:"long_name"` LongName string `json:"longName"`
Abbreviation string `json:"abbreviation"` Abbreviation string `json:"abbreviation"`
Version string `json:"version"` Version string `json:"version"`
BackgroundColor string `json:"background_color"` BackgroundColor string `json:"backgroundColor"`
ForegroundColor string `json:"foreground_color"` ForegroundColor string `json:"foregroundColor"`
FontSize int8 `json:"font_size"` FontSize int8 `json:"fontSize"`
ReferenceLink string `json:"reference_link"` ReferenceLink string `json:"referenceLink"`
Ports []string `json:"ports"` Ports []string `json:"ports"`
Priority uint8 `json:"priority"` Priority uint8 `json:"priority"`
} }
@ -50,8 +50,8 @@ type CounterPair struct {
} }
type GenericMessage struct { type GenericMessage struct {
IsRequest bool `json:"is_request"` IsRequest bool `json:"isRequest"`
CaptureTime time.Time `json:"capture_time"` CaptureTime time.Time `json:"captureTime"`
Payload interface{} `json:"payload"` Payload interface{} `json:"payload"`
} }
@ -102,8 +102,8 @@ type MizuEntry struct {
ID uint `gorm:"primarykey"` ID uint `gorm:"primarykey"`
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
ProtocolName string `json:"protocol_key" gorm:"column:protocolKey"` ProtocolName string `json:"protocolKey" gorm:"column:protocolKey"`
ProtocolVersion string `json:"protocol_version" gorm:"column:protocolVersion"` ProtocolVersion string `json:"protocolVersion" gorm:"column:protocolVersion"`
Entry string `json:"entry,omitempty" gorm:"column:entry"` Entry string `json:"entry,omitempty" gorm:"column:entry"`
EntryId string `json:"entryId" gorm:"column:entryId"` EntryId string `json:"entryId" gorm:"column:entryId"`
Url string `json:"url" gorm:"column:url"` Url string `json:"url" gorm:"column:url"`
@ -135,17 +135,17 @@ type BaseEntryDetails struct {
Id string `json:"id,omitempty"` Id string `json:"id,omitempty"`
Protocol Protocol `json:"protocol,omitempty"` Protocol Protocol `json:"protocol,omitempty"`
Url string `json:"url,omitempty"` Url string `json:"url,omitempty"`
RequestSenderIp string `json:"request_sender_ip,omitempty"` RequestSenderIp string `json:"requestSenderIp,omitempty"`
Service string `json:"service,omitempty"` Service string `json:"service,omitempty"`
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
Summary string `json:"summary,omitempty"` Summary string `json:"summary,omitempty"`
StatusCode int `json:"status_code"` StatusCode int `json:"statusCode"`
Method string `json:"method,omitempty"` Method string `json:"method,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"` Timestamp int64 `json:"timestamp,omitempty"`
SourceIp string `json:"source_ip,omitempty"` SourceIp string `json:"sourceIp,omitempty"`
DestinationIp string `json:"destination_ip,omitempty"` DestinationIp string `json:"destinationIp,omitempty"`
SourcePort string `json:"source_port,omitempty"` SourcePort string `json:"sourcePort,omitempty"`
DestinationPort string `json:"destination_port,omitempty"` DestinationPort string `json:"destinationPort,omitempty"`
IsOutgoing bool `json:"isOutgoing,omitempty"` IsOutgoing bool `json:"isOutgoing,omitempty"`
Latency int64 `json:"latency,omitempty"` Latency int64 `json:"latency,omitempty"`
Rules ApplicableRules `json:"rules,omitempty"` Rules ApplicableRules `json:"rules,omitempty"`

View File

@ -54,8 +54,8 @@ export const EntriesList: React.FC<EntriesListProps> = ({entries, setEntries, fo
const filterEntries = useCallback((entry) => { const filterEntries = useCallback((entry) => {
if(methodsFilter.length > 0 && !methodsFilter.includes(entry.method.toLowerCase())) return; if(methodsFilter.length > 0 && !methodsFilter.includes(entry.method.toLowerCase())) return;
if(pathFilter && entry.path?.toLowerCase()?.indexOf(pathFilter) === -1) return; if(pathFilter && entry.path?.toLowerCase()?.indexOf(pathFilter) === -1) return;
if(statusFilter.includes(StatusType.SUCCESS) && entry.status_code >= 400) return; if(statusFilter.includes(StatusType.SUCCESS) && entry.statusCode >= 400) return;
if(statusFilter.includes(StatusType.ERROR) && entry.status_code < 400) return; if(statusFilter.includes(StatusType.ERROR) && entry.statusCode < 400) return;
return entry; return entry;
},[methodsFilter, pathFilter, statusFilter]) },[methodsFilter, pathFilter, statusFilter])

View File

@ -72,7 +72,7 @@ export const EntryDetailed: React.FC<EntryDetailedProps> = ({entryData}) => {
/> />
{entryData.data && <EntrySummary data={entryData.data}/>} {entryData.data && <EntrySummary data={entryData.data}/>}
<> <>
{entryData.data && <EntryViewer representation={entryData.representation} color={entryData.protocol.background_color}/>} {entryData.data && <EntryViewer representation={entryData.representation} color={entryData.protocol.backgroundColor}/>}
</> </>
</> </>
}; };

View File

@ -16,13 +16,13 @@ interface Entry {
summary: string, summary: string,
service: string, service: string,
id: string, id: string,
status_code?: number; statusCode?: number;
url?: string; url?: string;
timestamp: Date; timestamp: Date;
source_ip: string, sourceIp: string,
source_port: string, sourcePort: string,
destination_ip: string, destinationIp: string,
destination_port: string, destinationPort: string,
isOutgoing?: boolean; isOutgoing?: boolean;
latency: number; latency: number;
rules: Rules; rules: Rules;
@ -41,7 +41,7 @@ interface EntryProps {
} }
export const EntryItem: React.FC<EntryProps> = ({entry, setFocusedEntryId, isSelected}) => { export const EntryItem: React.FC<EntryProps> = ({entry, setFocusedEntryId, isSelected}) => {
const classification = getClassification(entry.status_code) const classification = getClassification(entry.statusCode)
let ingoingIcon; let ingoingIcon;
let outgoingIcon; let outgoingIcon;
switch(classification) { switch(classification) {
@ -103,11 +103,11 @@ export const EntryItem: React.FC<EntryProps> = ({entry, setFocusedEntryId, isSel
className={`${styles.row} className={`${styles.row}
${isSelected ? styles.rowSelected : backgroundColor}`} ${isSelected ? styles.rowSelected : backgroundColor}`}
onClick={() => setFocusedEntryId(entry.id)} 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"}}
> >
<Protocol protocol={entry.protocol} horizontal={false}/> <Protocol protocol={entry.protocol} horizontal={false}/>
{((entry.protocol.name === "http" && "status_code" in entry) || entry.status_code !== 0) && <div> {((entry.protocol.name === "http" && "statusCode" in entry) || entry.statusCode !== 0) && <div>
<StatusCode statusCode={entry.status_code}/> <StatusCode statusCode={entry.statusCode}/>
</div>} </div>}
<div className={styles.endpointServiceContainer}> <div className={styles.endpointServiceContainer}>
<EndpointPath method={entry.method} path={entry.summary}/> <EndpointPath method={entry.method} path={entry.summary}/>
@ -116,13 +116,13 @@ export const EntryItem: React.FC<EntryProps> = ({entry, setFocusedEntryId, isSel
</div> </div>
</div> </div>
<div className={styles.directionContainer}> <div className={styles.directionContainer}>
<span className={styles.port} title="Source Port">{entry.source_port}</span> <span className={styles.port} title="Source Port">{entry.sourcePort}</span>
{entry.isOutgoing ? {entry.isOutgoing ?
<img src={outgoingIcon} alt="Ingoing traffic" title="Ingoing"/> <img src={outgoingIcon} alt="Ingoing traffic" title="Ingoing"/>
: :
<img src={ingoingIcon} alt="Outgoing traffic" title="Outgoing"/> <img src={ingoingIcon} alt="Outgoing traffic" title="Outgoing"/>
} }
<span className={styles.port} title="Destination Port">{entry.destination_port}</span> <span className={styles.port} title="Destination Port">{entry.destinationPort}</span>
</div> </div>
<div className={styles.timestamp}> <div className={styles.timestamp}>
<span title="Timestamp"> <span title="Timestamp">

View File

@ -3,12 +3,12 @@ import styles from './style/Protocol.module.sass';
export interface ProtocolInterface { export interface ProtocolInterface {
name: string name: string
long_name: string longName: string
abbreviation: string abbreviation: string
background_color: string backgroundColor: string
foreground_color: string foregroundColor: string
font_size: number fontSize: number
reference_link: string referenceLink: string
ports: string[] ports: string[]
inbound_ports: string inbound_ports: string
} }
@ -20,29 +20,29 @@ interface ProtocolProps {
const Protocol: React.FC<ProtocolProps> = ({protocol, horizontal}) => { const Protocol: React.FC<ProtocolProps> = ({protocol, horizontal}) => {
if (horizontal) { if (horizontal) {
return <a target="_blank" rel="noopener noreferrer" href={protocol.reference_link}> return <a target="_blank" rel="noopener noreferrer" href={protocol.referenceLink}>
<span <span
className={`${styles.base} ${styles.horizontal}`} className={`${styles.base} ${styles.horizontal}`}
style={{ style={{
backgroundColor: protocol.background_color, backgroundColor: protocol.backgroundColor,
color: protocol.foreground_color, color: protocol.foregroundColor,
fontSize: 13, fontSize: 13,
}} }}
title={protocol.abbreviation} title={protocol.abbreviation}
> >
{protocol.long_name} {protocol.longName}
</span> </span>
</a> </a>
} else { } else {
return <a target="_blank" rel="noopener noreferrer" href={protocol.reference_link}> return <a target="_blank" rel="noopener noreferrer" href={protocol.referenceLink}>
<span <span
className={`${styles.base} ${styles.vertical}`} className={`${styles.base} ${styles.vertical}`}
style={{ style={{
backgroundColor: protocol.background_color, backgroundColor: protocol.backgroundColor,
color: protocol.foreground_color, color: protocol.foregroundColor,
fontSize: protocol.font_size, fontSize: protocol.fontSize,
}} }}
title={protocol.long_name} title={protocol.longName}
> >
{protocol.abbreviation} {protocol.abbreviation}
</span> </span>