web

package
v0.0.0-...-127e4a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: BSD-3-Clause Imports: 42 Imported by: 0

Documentation

Overview

Package web is responsible for logging users in to the validator service, listing the user's repositories and their validation status/results, enabling and disabling hooks on the GIN server running the validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableHook

func DisableHook(w http.ResponseWriter, r *http.Request)

DisableHook removes a hook from the server.

func EnableHook

func EnableHook(w http.ResponseWriter, r *http.Request)

EnableHook creates a new hook on the server for the specific repository.

func ListRepos

func ListRepos(w http.ResponseWriter, r *http.Request)

ListRepos queries the GIN server for a list of repositories owned (or accessible) by a given user and renders the page which displays the repositories and their validation status.

func LoginGet

func LoginGet(w http.ResponseWriter, r *http.Request)

LoginGet renders the login form

func LoginPost

func LoginPost(w http.ResponseWriter, r *http.Request)

LoginPost logs in the user to the GIN server, storing a session token.

func Logout

func Logout(w http.ResponseWriter, r *http.Request)

Logout logouts the current user

func PubValidateGet

func PubValidateGet(w http.ResponseWriter, r *http.Request)

PubValidateGet renders the one-time validation form, which allows the user to manually run a validator on a publicly accessible repository, without using a web hook.

func PubValidatePost

func PubValidatePost(w http.ResponseWriter, r *http.Request)

PubValidatePost parses the POST data from the root form and calls the validator using the built-in ServiceWaiter.

func Results

func Results(w http.ResponseWriter, r *http.Request)

Results returns the results of a previously run validation.

func Root

func Root(w http.ResponseWriter, r *http.Request)

Root handles the root path of the service. If the user is logged in, it redirects to the user's repository listing. If the user is not logged in, it redirects to the login form.

func ShowRepo

func ShowRepo(w http.ResponseWriter, r *http.Request)

ShowRepo renders the repository information page where the user can enable or disable validator hooks.

func Status

func Status(w http.ResponseWriter, r *http.Request)

Status returns the status of the latest BIDS validation for a provided gin user repository.

func Validate

func Validate(w http.ResponseWriter, r *http.Request)

Validate temporarily clones a provided repository from a gin server and checks whether the content of the repository is a valid BIDS dataset. Any cloned files are cleaned up after the check is done.

Types

type BidsMessages

type BidsMessages struct {
	Errors   []interface{} `json:"errors"`
	Warnings []interface{} `json:"warnings"`
	Ignored  []interface{} `json:"ignored"`
}

BidsMessages contains Errors, Warnings and Ignored messages. Currently its just the number of individual messages we are interested in. If this changes, the messages will be expanded into proper structs of their own.

type BidsResultStruct

type BidsResultStruct struct {
	Issues struct {
		Errors []struct {
			Key      string `json:"key"`
			Severity string `json:"severity"`
			Reason   string `json:"reason"`
			Files    []struct {
				Key  string `json:"key"`
				Code int    `json:"code"`
				File struct {
					Path         string `json:"path"`
					RelativePath string `json:"relativePath"`
					// contains filtered or unexported fields
				} `json:"file"`
				Evidence  interface{} `json:"evidence"`
				Line      interface{} `json:"line"`
				Character interface{} `json:"character"`
				Severity  string      `json:"severity"`
				Reason    string      `json:"reason"`
			} `json:"files"`
			AdditionalFileCount int `json:"additionalFileCount"`
			Code                int `json:"code"`
		} `json:"errors"`
		Warnings []struct {
			Key      string `json:"key"`
			Severity string `json:"severity"`
			Reason   string `json:"reason"`
			Files    []struct {
				Key  string `json:"key"`
				Code int    `json:"code"`
				File struct {
					Name         string `json:"name"`
					Path         string `json:"path"`
					RelativePath string `json:"relativePath"`
					Stats        struct {
						Dev         int       `json:"dev"`
						Mode        int       `json:"mode"`
						Nlink       int       `json:"nlink"`
						UID         int       `json:"uid"`
						Gid         int       `json:"gid"`
						Rdev        int       `json:"rdev"`
						Blksize     int       `json:"blksize"`
						Ino         int       `json:"ino"`
						Size        int       `json:"size"`
						Blocks      int       `json:"blocks"`
						AtimeMs     float64   `json:"atimeMs"`
						MtimeMs     float64   `json:"mtimeMs"`
						CtimeMs     float64   `json:"ctimeMs"`
						BirthtimeMs float64   `json:"birthtimeMs"`
						Atime       time.Time `json:"atime"`
						Mtime       time.Time `json:"mtime"`
						Ctime       time.Time `json:"ctime"`
						Birthtime   time.Time `json:"birthtime"`
					} `json:"stats"`
				} `json:"file"`
				Evidence  interface{} `json:"evidence"`
				Line      interface{} `json:"line"`
				Character interface{} `json:"character"`
				Severity  string      `json:"severity"`
				Reason    string      `json:"reason"`
			} `json:"files"`
			AdditionalFileCount int `json:"additionalFileCount"`
			Code                int `json:"code"`
		} `json:"warnings"`
		Ignored []interface{} `json:"ignored"`
	} `json:"issues"`
	Summary struct {
		Sessions   []interface{} `json:"sessions"`
		Subjects   []string      `json:"subjects"`
		Tasks      []string      `json:"tasks"`
		Modalities []string      `json:"modalities"`
		TotalFiles int           `json:"totalFiles"`
		Size       int           `json:"size"`
	} `json:"summary"`
}

BidsResultStruct is the struct to parse a full BIDS validation json.

type BidsRoot

type BidsRoot struct {
	Issues BidsMessages `json:"issues"`
}

BidsRoot contains only the root issues element.

type Result

type Result struct {
	Href  string
	Alt   string
	Text1 string
	Text2 string
	Badge template.HTML
}

Result is the struct containing info about a single validator run

type ResultsHistoryStruct

type ResultsHistoryStruct struct {
	Results []Result
}

ResultsHistoryStruct is the struct containing references to all validations already performed

type Validationcfg

type Validationcfg struct {
	Bidscfg struct {
		BidsRoot      string `yaml:"bidsroot"`
		ValidateNifti bool   `yaml:"validatenifti"`
	} `yaml:"bidsconfig"`
}

Validationcfg is used to unmarshall a config file holding information specific for running the various validations. e.g. where the root folder of a bids directory can be found or whether the NiftiHeaders should be ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL