mirror of
https://github.com/stashapp/stash.git
synced 2026-04-28 09:55:05 +02:00
Lint and format
This commit is contained in:
parent
aa7107a242
commit
6cfb249f3b
6 changed files with 634 additions and 576 deletions
|
|
@ -270,7 +270,9 @@ type Query {
|
|||
allMovies: [Movie!]! @deprecated(reason: "Use findGroups instead")
|
||||
|
||||
users: [User!]! @hasRole(role: ADMIN)
|
||||
"""Returns currently authenticated user"""
|
||||
"""
|
||||
Returns currently authenticated user
|
||||
"""
|
||||
me: User
|
||||
|
||||
# Version
|
||||
|
|
@ -289,29 +291,36 @@ type Mutation {
|
|||
"Downloads and installs ffmpeg and ffprobe binaries into the configuration directory. Returns the job ID."
|
||||
downloadFFMpeg: ID! @hasRole(role: ADMIN)
|
||||
|
||||
sceneCreate(input: SceneCreateInput!): Scene @hasRole(role: MODIFY)
|
||||
sceneUpdate(input: SceneUpdateInput!): Scene @hasRole(role: MODIFY)
|
||||
sceneMerge(input: SceneMergeInput!): Scene @hasRole(role: MODIFY)
|
||||
bulkSceneUpdate(input: BulkSceneUpdateInput!): [Scene!] @hasRole(role: MODIFY)
|
||||
sceneDestroy(input: SceneDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
scenesDestroy(input: ScenesDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
scenesUpdate(input: [SceneUpdateInput!]!): [Scene] @hasRole(role: MODIFY)
|
||||
sceneCreate(input: SceneCreateInput!): Scene @hasRole(role: MODIFY)
|
||||
sceneUpdate(input: SceneUpdateInput!): Scene @hasRole(role: MODIFY)
|
||||
sceneMerge(input: SceneMergeInput!): Scene @hasRole(role: MODIFY)
|
||||
bulkSceneUpdate(input: BulkSceneUpdateInput!): [Scene!] @hasRole(role: MODIFY)
|
||||
sceneDestroy(input: SceneDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
scenesDestroy(input: ScenesDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
scenesUpdate(input: [SceneUpdateInput!]!): [Scene] @hasRole(role: MODIFY)
|
||||
|
||||
"Increments the o-counter for a scene. Returns the new value"
|
||||
sceneIncrementO(id: ID!): Int! @deprecated(reason: "Use sceneAddO instead") @hasRole(role: MODIFY)
|
||||
sceneIncrementO(id: ID!): Int!
|
||||
@deprecated(reason: "Use sceneAddO instead")
|
||||
@hasRole(role: MODIFY)
|
||||
"Decrements the o-counter for a scene. Returns the new value"
|
||||
sceneDecrementO(id: ID!): Int! @deprecated(reason: "Use sceneRemoveO instead") @hasRole(role: MODIFY)
|
||||
sceneDecrementO(id: ID!): Int!
|
||||
@deprecated(reason: "Use sceneRemoveO instead")
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Increments the o-counter for a scene. Uses the current time if none provided."
|
||||
sceneAddO(id: ID!, times: [Timestamp!]): HistoryMutationResult! @hasRole(role: MODIFY)
|
||||
sceneAddO(id: ID!, times: [Timestamp!]): HistoryMutationResult!
|
||||
@hasRole(role: MODIFY)
|
||||
"Decrements the o-counter for a scene, removing the last recorded time if specific time not provided. Returns the new value"
|
||||
sceneDeleteO(id: ID!, times: [Timestamp!]): HistoryMutationResult! @hasRole(role: MODIFY)
|
||||
sceneDeleteO(id: ID!, times: [Timestamp!]): HistoryMutationResult!
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Resets the o-counter for a scene to 0. Returns the new value"
|
||||
sceneResetO(id: ID!): Int! @hasRole(role: MODIFY)
|
||||
|
||||
"Sets the resume time point (if provided) and adds the provided duration to the scene's play duration"
|
||||
sceneSaveActivity(id: ID!, resume_time: Float, playDuration: Float): Boolean! @hasRole(role: MODIFY)
|
||||
sceneSaveActivity(id: ID!, resume_time: Float, playDuration: Float): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Resets the resume time point and play duration"
|
||||
sceneResetActivity(
|
||||
|
|
@ -322,21 +331,27 @@ type Mutation {
|
|||
|
||||
"Increments the play count for the scene. Returns the new play count value."
|
||||
sceneIncrementPlayCount(id: ID!): Int!
|
||||
@deprecated(reason: "Use sceneAddPlay instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use sceneAddPlay instead")
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Increments the play count for the scene. Uses the current time if none provided."
|
||||
sceneAddPlay(id: ID!, times: [Timestamp!]): HistoryMutationResult! @hasRole(role: MODIFY)
|
||||
sceneAddPlay(id: ID!, times: [Timestamp!]): HistoryMutationResult!
|
||||
@hasRole(role: MODIFY)
|
||||
"Decrements the play count for the scene, removing the specific times or the last recorded time if not provided."
|
||||
sceneDeletePlay(id: ID!, times: [Timestamp!]): HistoryMutationResult! @hasRole(role: MODIFY)
|
||||
sceneDeletePlay(id: ID!, times: [Timestamp!]): HistoryMutationResult!
|
||||
@hasRole(role: MODIFY)
|
||||
"Resets the play count for a scene to 0. Returns the new play count value."
|
||||
sceneResetPlayCount(id: ID!): Int! @hasRole(role: MODIFY)
|
||||
|
||||
"Generates screenshot at specified time in seconds. Leave empty to generate default screenshot"
|
||||
sceneGenerateScreenshot(id: ID!, at: Float): String! @hasRole(role: ADMIN)
|
||||
|
||||
sceneMarkerCreate(input: SceneMarkerCreateInput!): SceneMarker @hasRole(role: MODIFY)
|
||||
sceneMarkerUpdate(input: SceneMarkerUpdateInput!): SceneMarker @hasRole(role: MODIFY)
|
||||
bulkSceneMarkerUpdate(input: BulkSceneMarkerUpdateInput!): [SceneMarker!] @hasRole(role: MODIFY)
|
||||
sceneMarkerCreate(input: SceneMarkerCreateInput!): SceneMarker
|
||||
@hasRole(role: MODIFY)
|
||||
sceneMarkerUpdate(input: SceneMarkerUpdateInput!): SceneMarker
|
||||
@hasRole(role: MODIFY)
|
||||
bulkSceneMarkerUpdate(input: BulkSceneMarkerUpdateInput!): [SceneMarker!]
|
||||
@hasRole(role: MODIFY)
|
||||
sceneMarkerDestroy(id: ID!): Boolean! @hasRole(role: MODIFY)
|
||||
sceneMarkersDestroy(ids: [ID!]!): Boolean! @hasRole(role: MODIFY)
|
||||
|
||||
|
|
@ -357,42 +372,58 @@ type Mutation {
|
|||
|
||||
galleryCreate(input: GalleryCreateInput!): Gallery @hasRole(role: MODIFY)
|
||||
galleryUpdate(input: GalleryUpdateInput!): Gallery @hasRole(role: MODIFY)
|
||||
bulkGalleryUpdate(input: BulkGalleryUpdateInput!): [Gallery!] @hasRole(role: MODIFY)
|
||||
bulkGalleryUpdate(input: BulkGalleryUpdateInput!): [Gallery!]
|
||||
@hasRole(role: MODIFY)
|
||||
galleryDestroy(input: GalleryDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
galleriesUpdate(input: [GalleryUpdateInput!]!): [Gallery] @hasRole(role: MODIFY)
|
||||
galleriesUpdate(input: [GalleryUpdateInput!]!): [Gallery]
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
addGalleryImages(input: GalleryAddInput!): Boolean! @hasRole(role: MODIFY)
|
||||
removeGalleryImages(input: GalleryRemoveInput!): Boolean! @hasRole(role: MODIFY)
|
||||
removeGalleryImages(input: GalleryRemoveInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
setGalleryCover(input: GallerySetCoverInput!): Boolean! @hasRole(role: MODIFY)
|
||||
resetGalleryCover(input: GalleryResetCoverInput!): Boolean! @hasRole(role: MODIFY)
|
||||
resetGalleryCover(input: GalleryResetCoverInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
galleryChapterCreate(input: GalleryChapterCreateInput!): GalleryChapter @hasRole(role: MODIFY)
|
||||
galleryChapterUpdate(input: GalleryChapterUpdateInput!): GalleryChapter @hasRole(role: MODIFY)
|
||||
galleryChapterCreate(input: GalleryChapterCreateInput!): GalleryChapter
|
||||
@hasRole(role: MODIFY)
|
||||
galleryChapterUpdate(input: GalleryChapterUpdateInput!): GalleryChapter
|
||||
@hasRole(role: MODIFY)
|
||||
galleryChapterDestroy(id: ID!): Boolean! @hasRole(role: MODIFY)
|
||||
|
||||
performerCreate(input: PerformerCreateInput!): Performer @hasRole(role: MODIFY)
|
||||
performerUpdate(input: PerformerUpdateInput!): Performer @hasRole(role: MODIFY)
|
||||
performerDestroy(input: PerformerDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
performerCreate(input: PerformerCreateInput!): Performer
|
||||
@hasRole(role: MODIFY)
|
||||
performerUpdate(input: PerformerUpdateInput!): Performer
|
||||
@hasRole(role: MODIFY)
|
||||
performerDestroy(input: PerformerDestroyInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
performersDestroy(ids: [ID!]!): Boolean! @hasRole(role: MODIFY)
|
||||
bulkPerformerUpdate(input: BulkPerformerUpdateInput!): [Performer!] @hasRole(role: MODIFY)
|
||||
bulkPerformerUpdate(input: BulkPerformerUpdateInput!): [Performer!]
|
||||
@hasRole(role: MODIFY)
|
||||
performerMerge(input: PerformerMergeInput!): Performer! @hasRole(role: MODIFY)
|
||||
|
||||
studioCreate(input: StudioCreateInput!): Studio @hasRole(role: MODIFY)
|
||||
studioUpdate(input: StudioUpdateInput!): Studio @hasRole(role: MODIFY)
|
||||
studioDestroy(input: StudioDestroyInput!): Boolean! @hasRole(role: MODIFY)
|
||||
studiosDestroy(ids: [ID!]!): Boolean! @hasRole(role: MODIFY)
|
||||
bulkStudioUpdate(input: BulkStudioUpdateInput!): [Studio!] @hasRole(role: MODIFY)
|
||||
bulkStudioUpdate(input: BulkStudioUpdateInput!): [Studio!]
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
movieCreate(input: MovieCreateInput!): Movie
|
||||
@deprecated(reason: "Use groupCreate instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use groupCreate instead")
|
||||
@hasRole(role: MODIFY)
|
||||
movieUpdate(input: MovieUpdateInput!): Movie
|
||||
@deprecated(reason: "Use groupUpdate instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use groupUpdate instead")
|
||||
@hasRole(role: MODIFY)
|
||||
movieDestroy(input: MovieDestroyInput!): Boolean!
|
||||
@deprecated(reason: "Use groupDestroy instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use groupDestroy instead")
|
||||
@hasRole(role: MODIFY)
|
||||
moviesDestroy(ids: [ID!]!): Boolean!
|
||||
@deprecated(reason: "Use groupsDestroy instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use groupsDestroy instead")
|
||||
@hasRole(role: MODIFY)
|
||||
bulkMovieUpdate(input: BulkMovieUpdateInput!): [Movie!]
|
||||
@deprecated(reason: "Use bulkGroupUpdate instead") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "Use bulkGroupUpdate instead")
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
groupCreate(input: GroupCreateInput!): Group @hasRole(role: MODIFY)
|
||||
groupUpdate(input: GroupUpdateInput!): Group @hasRole(role: MODIFY)
|
||||
|
|
@ -400,11 +431,14 @@ type Mutation {
|
|||
groupsDestroy(ids: [ID!]!): Boolean! @hasRole(role: MODIFY)
|
||||
bulkGroupUpdate(input: BulkGroupUpdateInput!): [Group!] @hasRole(role: MODIFY)
|
||||
|
||||
addGroupSubGroups(input: GroupSubGroupAddInput!): Boolean! @hasRole(role: MODIFY)
|
||||
removeGroupSubGroups(input: GroupSubGroupRemoveInput!): Boolean! @hasRole(role: MODIFY)
|
||||
addGroupSubGroups(input: GroupSubGroupAddInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
removeGroupSubGroups(input: GroupSubGroupRemoveInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Reorder sub groups within a group. Returns true if successful."
|
||||
reorderSubGroups(input: ReorderSubGroupsInput!): Boolean! @hasRole(role: MODIFY)
|
||||
reorderSubGroups(input: ReorderSubGroupsInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
tagCreate(input: TagCreateInput!): Tag @hasRole(role: MODIFY)
|
||||
tagUpdate(input: TagUpdateInput!): Tag @hasRole(role: MODIFY)
|
||||
|
|
@ -431,15 +465,21 @@ type Mutation {
|
|||
|
||||
# Saved filters
|
||||
saveFilter(input: SaveFilterInput!): SavedFilter! @hasRole(role: MODIFY)
|
||||
destroySavedFilter(input: DestroyFilterInput!): Boolean! @hasRole(role: MODIFY)
|
||||
destroySavedFilter(input: DestroyFilterInput!): Boolean!
|
||||
@hasRole(role: MODIFY)
|
||||
setDefaultFilter(input: SetDefaultFilterInput!): Boolean!
|
||||
@deprecated(reason: "now uses UI config") @hasRole(role: MODIFY)
|
||||
@deprecated(reason: "now uses UI config")
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Change general configuration options"
|
||||
configureGeneral(input: ConfigGeneralInput!): ConfigGeneralResult! @hasRole(role: ADMIN)
|
||||
configureInterface(input: ConfigInterfaceInput!): ConfigInterfaceResult! @hasRole(role: ADMIN)
|
||||
configureDLNA(input: ConfigDLNAInput!): ConfigDLNAResult! @hasRole(role: ADMIN)
|
||||
configureScraping(input: ConfigScrapingInput!): ConfigScrapingResult! @hasRole(role: ADMIN)
|
||||
configureGeneral(input: ConfigGeneralInput!): ConfigGeneralResult!
|
||||
@hasRole(role: ADMIN)
|
||||
configureInterface(input: ConfigInterfaceInput!): ConfigInterfaceResult!
|
||||
@hasRole(role: ADMIN)
|
||||
configureDLNA(input: ConfigDLNAInput!): ConfigDLNAResult!
|
||||
@hasRole(role: ADMIN)
|
||||
configureScraping(input: ConfigScrapingInput!): ConfigScrapingResult!
|
||||
@hasRole(role: ADMIN)
|
||||
configureDefaults(
|
||||
input: ConfigDefaultSettingsInput!
|
||||
): ConfigDefaultSettingsResult! @hasRole(role: ADMIN)
|
||||
|
|
@ -488,12 +528,14 @@ type Mutation {
|
|||
"Migrate generated files for the current hash naming"
|
||||
migrateHashNaming: ID! @hasRole(role: ADMIN)
|
||||
"Migrates legacy scene screenshot files into the blob storage"
|
||||
migrateSceneScreenshots(input: MigrateSceneScreenshotsInput!): ID! @hasRole(role: ADMIN)
|
||||
migrateSceneScreenshots(input: MigrateSceneScreenshotsInput!): ID!
|
||||
@hasRole(role: ADMIN)
|
||||
"Migrates blobs from the old storage system to the current one"
|
||||
migrateBlobs(input: MigrateBlobsInput!): ID! @hasRole(role: ADMIN)
|
||||
|
||||
"Anonymise the database in a separate file. Optionally returns a link to download the database file"
|
||||
anonymiseDatabase(input: AnonymiseDatabaseInput!): String @hasRole(role: ADMIN)
|
||||
anonymiseDatabase(input: AnonymiseDatabaseInput!): String
|
||||
@hasRole(role: ADMIN)
|
||||
|
||||
"Optimises the database. Returns the job ID"
|
||||
optimiseDatabase: ID! @hasRole(role: ADMIN)
|
||||
|
|
@ -538,7 +580,8 @@ type Mutation {
|
|||
If an error occurs when installing a package, the job will continue to install the remaining packages.
|
||||
Returns the job ID
|
||||
"""
|
||||
installPackages(type: PackageType!, packages: [PackageSpecInput!]!): ID! @hasRole(role: ADMIN)
|
||||
installPackages(type: PackageType!, packages: [PackageSpecInput!]!): ID!
|
||||
@hasRole(role: ADMIN)
|
||||
"""
|
||||
Updates the given packages.
|
||||
If a package is not installed, it will not be installed.
|
||||
|
|
@ -547,13 +590,15 @@ type Mutation {
|
|||
If an error occurs when updating a package, the job will continue to update the remaining packages.
|
||||
Returns the job ID.
|
||||
"""
|
||||
updatePackages(type: PackageType!, packages: [PackageSpecInput!]): ID! @hasRole(role: ADMIN)
|
||||
updatePackages(type: PackageType!, packages: [PackageSpecInput!]): ID!
|
||||
@hasRole(role: ADMIN)
|
||||
"""
|
||||
Uninstalls the given packages.
|
||||
If an error occurs when uninstalling a package, the job will continue to uninstall the remaining packages.
|
||||
Returns the job ID
|
||||
"""
|
||||
uninstallPackages(type: PackageType!, packages: [PackageSpecInput!]!): ID! @hasRole(role: ADMIN)
|
||||
uninstallPackages(type: PackageType!, packages: [PackageSpecInput!]!): ID!
|
||||
@hasRole(role: ADMIN)
|
||||
|
||||
stopJob(job_id: ID!): Boolean! @hasRole(role: ADMIN)
|
||||
stopAllJobs: Boolean! @hasRole(role: ADMIN)
|
||||
|
|
@ -564,9 +609,11 @@ type Mutation {
|
|||
): Boolean! @hasRole(role: MODIFY)
|
||||
|
||||
"Submit scene as draft to stash-box instance"
|
||||
submitStashBoxSceneDraft(input: StashBoxDraftSubmissionInput!): ID @hasRole(role: MODIFY)
|
||||
submitStashBoxSceneDraft(input: StashBoxDraftSubmissionInput!): ID
|
||||
@hasRole(role: MODIFY)
|
||||
"Submit performer as draft to stash-box instance"
|
||||
submitStashBoxPerformerDraft(input: StashBoxDraftSubmissionInput!): ID @hasRole(role: MODIFY)
|
||||
submitStashBoxPerformerDraft(input: StashBoxDraftSubmissionInput!): ID
|
||||
@hasRole(role: MODIFY)
|
||||
|
||||
"Backup the database. Optionally returns a link to download the database file"
|
||||
backupDatabase(input: BackupDatabaseInput!): String @hasRole(role: ADMIN)
|
||||
|
|
@ -578,9 +625,11 @@ type Mutation {
|
|||
execSQL(sql: String!, args: [Any]): SQLExecResult! @hasRole(role: ADMIN)
|
||||
|
||||
"Run batch performer tag task. Returns the job ID."
|
||||
stashBoxBatchPerformerTag(input: StashBoxBatchTagInput!): String! @hasRole(role: ADMIN)
|
||||
stashBoxBatchPerformerTag(input: StashBoxBatchTagInput!): String!
|
||||
@hasRole(role: ADMIN)
|
||||
"Run batch studio tag task. Returns the job ID."
|
||||
stashBoxBatchStudioTag(input: StashBoxBatchTagInput!): String! @hasRole(role: ADMIN)
|
||||
stashBoxBatchStudioTag(input: StashBoxBatchTagInput!): String!
|
||||
@hasRole(role: ADMIN)
|
||||
|
||||
"Enables DLNA for an optional duration. Has no effect if DLNA is enabled by default"
|
||||
enableDLNA(input: EnableDLNAInput!): Boolean! @hasRole(role: ADMIN)
|
||||
|
|
@ -589,12 +638,14 @@ type Mutation {
|
|||
"Enables an IP address for DLNA for an optional duration"
|
||||
addTempDLNAIP(input: AddTempDLNAIPInput!): Boolean! @hasRole(role: ADMIN)
|
||||
"Removes an IP address from the temporary DLNA whitelist"
|
||||
removeTempDLNAIP(input: RemoveTempDLNAIPInput!): Boolean! @hasRole(role: ADMIN)
|
||||
removeTempDLNAIP(input: RemoveTempDLNAIPInput!): Boolean!
|
||||
@hasRole(role: ADMIN)
|
||||
|
||||
userCreate(input: UserCreateInput!): User @hasRole(role: ADMIN)
|
||||
userUpdate(input: UserUpdateInput!): User @hasRole(role: ADMIN)
|
||||
userDestroy(input: UserDestroyInput!): Boolean! @hasRole(role: ADMIN)
|
||||
changeUserPassword(input: ChangeUserPasswordInput!): Boolean! @hasRole(role: ADMIN)
|
||||
changeUserPassword(input: ChangeUserPasswordInput!): Boolean!
|
||||
@hasRole(role: ADMIN)
|
||||
changePassword(input: UserChangePasswordInput!): Boolean!
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,17 @@ type User {
|
|||
Should not be visible to other users
|
||||
"""
|
||||
roles: [RoleEnum!] @isUserOwner
|
||||
"""Should not be visible to other users"""
|
||||
"""
|
||||
Should not be visible to other users
|
||||
"""
|
||||
api_key: String @isUserOwner
|
||||
}
|
||||
|
||||
input UserCreateInput {
|
||||
name: String!
|
||||
"""Password in plain text"""
|
||||
"""
|
||||
Password in plain text
|
||||
"""
|
||||
password: String!
|
||||
roles: [RoleEnum!]!
|
||||
}
|
||||
|
|
@ -32,11 +36,13 @@ input UserUpdateInput {
|
|||
}
|
||||
|
||||
input UserDestroyInput {
|
||||
name: String!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input UserChangePasswordInput {
|
||||
"""Password in plain text"""
|
||||
"""
|
||||
Password in plain text
|
||||
"""
|
||||
existingPassword: String!
|
||||
newPassword: String!
|
||||
}
|
||||
|
|
@ -44,4 +50,4 @@ input UserChangePasswordInput {
|
|||
input ChangeUserPasswordInput {
|
||||
name: String!
|
||||
newPassword: String!
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -117,8 +117,8 @@ func InitializeEmpty() *Config {
|
|||
return instance
|
||||
}
|
||||
|
||||
func (i *Config) loadFromCommandLine() {
|
||||
v := i.overrides
|
||||
func (s *Config) loadFromCommandLine() {
|
||||
v := s.overrides
|
||||
|
||||
if err := v.Load(posflag.ProviderWithFlag(pflag.CommandLine, ".", v, func(f *pflag.Flag) (string, interface{}) {
|
||||
// ignore flags that have not been changed
|
||||
|
|
@ -132,8 +132,8 @@ func (i *Config) loadFromCommandLine() {
|
|||
}
|
||||
}
|
||||
|
||||
func (i *Config) loadFromEnv() {
|
||||
v := i.overrides
|
||||
func (s *Config) loadFromEnv() {
|
||||
v := s.overrides
|
||||
|
||||
if err := v.Load(env.ProviderWithValue("STASH_", ".", func(key, value string) (string, interface{}) {
|
||||
key = strings.ToLower(strings.TrimPrefix(key, "STASH_"))
|
||||
|
|
@ -147,12 +147,12 @@ func (i *Config) loadFromEnv() {
|
|||
}
|
||||
}
|
||||
|
||||
func (i *Config) initOverrides() {
|
||||
i.loadFromCommandLine()
|
||||
i.loadFromEnv()
|
||||
func (s *Config) initOverrides() {
|
||||
s.loadFromCommandLine()
|
||||
s.loadFromEnv()
|
||||
}
|
||||
|
||||
func (i *Config) initConfig() error {
|
||||
func (s *Config) initConfig() error {
|
||||
configFile := ""
|
||||
envConfigFile := os.Getenv("STASH_CONFIG_FILE")
|
||||
|
||||
|
|
@ -165,8 +165,8 @@ func (i *Config) initConfig() error {
|
|||
if configFile != "" {
|
||||
// if file does not exist, assume it is a new system
|
||||
if exists, _ := fsutil.FileExists(configFile); !exists {
|
||||
i.isNewSystem = true
|
||||
i.SetConfigFile(configFile)
|
||||
s.isNewSystem = true
|
||||
s.SetConfigFile(configFile)
|
||||
|
||||
// ensure we can write to the file
|
||||
if err := fsutil.Touch(configFile); err != nil {
|
||||
|
|
@ -179,15 +179,15 @@ func (i *Config) initConfig() error {
|
|||
return nil
|
||||
} else {
|
||||
// load from provided config file
|
||||
if err := i.loadFirstFromFiles([]string{configFile}); err != nil {
|
||||
if err := s.loadFirstFromFiles([]string{configFile}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// load from default locations
|
||||
if err := i.loadFirstFromFiles(defaultConfigLocations); err != nil {
|
||||
if err := s.loadFirstFromFiles(defaultConfigLocations); err != nil {
|
||||
if errors.Is(err, errConfigNotFound) {
|
||||
i.isNewSystem = true
|
||||
s.isNewSystem = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -198,10 +198,10 @@ func (i *Config) initConfig() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *Config) loadFirstFromFiles(f []string) error {
|
||||
func (s *Config) loadFirstFromFiles(f []string) error {
|
||||
for _, ff := range f {
|
||||
if exists, _ := fsutil.FileExists(ff); exists {
|
||||
return i.load(ff)
|
||||
return s.load(ff)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ func (s *Config) GetUsername() string {
|
|||
return s.getString(Username)
|
||||
}
|
||||
|
||||
func (i *Config) GetPasswordHash() string {
|
||||
return i.getString(Password)
|
||||
func (s *Config) GetPasswordHash() string {
|
||||
return s.getString(Password)
|
||||
}
|
||||
|
||||
func (s *UserStore) legacyUser() *StoredUser {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
|
@ -13,7 +14,7 @@ type config struct {
|
|||
securityTripwireAccessedFromPublicInternet string
|
||||
}
|
||||
|
||||
func (c *config) HasCredentials() bool {
|
||||
func (c *config) LoginRequired(ctx context.Context) bool {
|
||||
return c.username != "" && c.password != ""
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ func TestCheckAllowPublicWithoutAuth(t *testing.T) {
|
|||
|
||||
doTest := func(caseIndex int, r *http.Request, expectedErr interface{}) {
|
||||
t.Helper()
|
||||
err := CheckAllowPublicWithoutAuth(c, r)
|
||||
err := CheckAllowPublicWithoutAuth(c, c, r)
|
||||
|
||||
if expectedErr == nil && err == nil {
|
||||
return
|
||||
|
|
@ -120,7 +121,7 @@ func TestCheckAllowPublicWithoutAuth(t *testing.T) {
|
|||
RemoteAddr: remoteAddr,
|
||||
}
|
||||
|
||||
err := CheckAllowPublicWithoutAuth(c, r)
|
||||
err := CheckAllowPublicWithoutAuth(c, c, r)
|
||||
if err == nil {
|
||||
t.Errorf("[%s]: expected error", remoteAddr)
|
||||
continue
|
||||
|
|
@ -137,7 +138,7 @@ func TestCheckAllowPublicWithoutAuth(t *testing.T) {
|
|||
c.username = "admin"
|
||||
c.password = "admin"
|
||||
|
||||
if err := CheckAllowPublicWithoutAuth(c, r); err != nil {
|
||||
if err := CheckAllowPublicWithoutAuth(c, c, r); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +147,7 @@ func TestCheckAllowPublicWithoutAuth(t *testing.T) {
|
|||
|
||||
c.dangerousAllowPublicWithoutAuth = true
|
||||
|
||||
if err := CheckAllowPublicWithoutAuth(c, r); err != nil {
|
||||
if err := CheckAllowPublicWithoutAuth(c, c, r); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +161,7 @@ func TestCheckExternalAccessTripwire(t *testing.T) {
|
|||
c.username = "admin"
|
||||
c.password = "admin"
|
||||
|
||||
if err := CheckExternalAccessTripwire(c); err != nil {
|
||||
if err := CheckExternalAccessTripwire(c, c); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
|
|
@ -170,19 +171,19 @@ func TestCheckExternalAccessTripwire(t *testing.T) {
|
|||
// HACK - this key isn't publically exposed
|
||||
c.dangerousAllowPublicWithoutAuth = true
|
||||
|
||||
if err := CheckExternalAccessTripwire(c); err != nil {
|
||||
if err := CheckExternalAccessTripwire(c, c); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
c.dangerousAllowPublicWithoutAuth = false
|
||||
|
||||
if err := CheckExternalAccessTripwire(c); err == nil {
|
||||
if err := CheckExternalAccessTripwire(c, c); err == nil {
|
||||
t.Errorf("expected error %v", ExternalAccessError("4.4.4.4"))
|
||||
}
|
||||
|
||||
c.securityTripwireAccessedFromPublicInternet = ""
|
||||
|
||||
if err := CheckExternalAccessTripwire(c); err != nil {
|
||||
if err := CheckExternalAccessTripwire(c, c); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue