-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate JSON properties with relative-path format #83
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package validator | ||
|
||
func adjustErrorDescription(description string) string { | ||
if description == "Does not match format 'relative-path'" { | ||
return "relative path is invalid or target doesn't exist" | ||
} | ||
return description | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package validator | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// RelativePathChecker is responsible for checking presence of the file path | ||
type RelativePathChecker struct { | ||
currentPath string | ||
} | ||
|
||
// IsFormat method checks if the path exists. | ||
func (r RelativePathChecker) IsFormat(input interface{}) bool { | ||
asString, ok := input.(string) | ||
if !ok { | ||
return false | ||
} | ||
|
||
path := filepath.Join(r.currentPath, asString) | ||
_, err := os.Stat(path) | ||
if err != nil { | ||
return false | ||
} | ||
return true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
- name: source | ||
title: Source | ||
group: 2 | ||
type: group | ||
fields: | ||
- name: geo.city_name | ||
level: core | ||
type: keyword | ||
description: City name. | ||
ignore_above: 1024 | ||
- name: geo.location | ||
level: core | ||
type: geo_point | ||
description: Longitude and latitude. | ||
- name: geo.region_iso_code | ||
level: core | ||
type: keyword | ||
description: Region ISO code. | ||
ignore_above: 1024 | ||
- name: geo.region_name | ||
level: core | ||
type: keyword | ||
description: Region name. | ||
ignore_above: 1024 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
title: pe sample | ||
type: logs | ||
release: experimental | ||
streams: | ||
- input: logfile | ||
vars: | ||
- name: paths | ||
type: text | ||
title: Paths | ||
multi: true | ||
required: true | ||
show_user: true | ||
default: | ||
- /var/log/nginx/access.log* | ||
- name: server_status_path | ||
type: text | ||
title: Server Status Path | ||
multi: false | ||
required: true | ||
show_user: false | ||
default: /server-status | ||
title: Nginx access logs | ||
description: Collect Nginx access logs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
format_version: 1.0.4 | ||
name: missing_image_files | ||
title: Missing Image Files | ||
description: This package is bad. | ||
version: 0.1.2 | ||
release: beta | ||
conditions: | ||
kibana.version: '^7.9.0' | ||
policy_templates: | ||
- name: apache | ||
title: Apache logs and metrics | ||
description: Collect logs and metrics from Apache instances | ||
inputs: | ||
- type: apache/metrics | ||
title: Collect metrics from Apache instances | ||
description: Collecting Apache status metrics | ||
vars: | ||
- name: hosts | ||
type: text | ||
title: Hosts | ||
multi: true | ||
required: true | ||
show_user: true | ||
default: | ||
- http://127.0.0.1 | ||
owner: | ||
github: elastic/foobar | ||
screenshots: | ||
- src: /img/kibana-system-wrong.png | ||
title: kibana system | ||
size: 1220x852 | ||
type: image/png | ||
- src: /img/metricbeat_system_dashboard.png | ||
title: metricbeat system dashboard | ||
size: 2097x1933 | ||
type: image/png | ||
icons: | ||
- src: /img/system-wrong.svg | ||
title: system | ||
size: 1000x1000 | ||
type: image/svg+xml | ||
- src: /img/system.svg | ||
title: system | ||
size: 1000x1000 | ||
type: image/svg+xml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,7 @@ spec: | |
src: | ||
description: Relative path to the icon's image file. | ||
type: string | ||
format: relative-path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be documented in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
examples: | ||
- "/img/logo_apache.svg" | ||
title: | ||
|
@@ -143,6 +144,7 @@ spec: | |
src: | ||
description: Relative path to the scrennshot's image file. | ||
type: string | ||
format: relative-path | ||
examples: | ||
- "/img/apache_httpd_server_status.png" | ||
title: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making
relative-path
a constant, now that we are using it in a few places in code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed