Skip to content

Commit

Permalink
Merge pull request #270 from joereuss12/add-stage-plugin-to-params-br…
Browse files Browse the repository at this point in the history
…anch

Added the StagePlugin.* params to the param table
  • Loading branch information
turetske authored Oct 25, 2023
2 parents 81c53cd + d03607e commit e86ba50
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmd/plugin_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/pelicanplatform/pelican/classads"
"github.com/pelicanplatform/pelican/client"
"github.com/pelicanplatform/pelican/param"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -41,7 +42,7 @@ func init() {
Run: stagePluginMain,
}
stageCmd.Flags().StringP("token", "t", "", "Token file to use for reading and/or writing")
if err := viper.BindPFlag("StagePlugin.Token", stageCmd.Flags().Lookup("token")); err != nil {
if err := viper.BindPFlag("Plugin.Token", stageCmd.Flags().Lookup("token")); err != nil {
panic(err)
}
stageCmd.Flags().Bool("hook", false, "Implement the HTCondor hook behavior")
Expand Down Expand Up @@ -85,7 +86,7 @@ Terminology:

func stagePluginMain(cmd *cobra.Command, args []string) {

originPrefixStr := viper.GetString("StagePlugin.OriginPrefix")
originPrefixStr := param.StagePlugin_OriginPrefix.GetString()
if len(originPrefixStr) == 0 {
log.Errorln("Origin prefix not specified; must be a URL (osdf://...)")
os.Exit(1)
Expand All @@ -102,20 +103,20 @@ func stagePluginMain(cmd *cobra.Command, args []string) {
originPrefixPath := path.Clean("/" + originPrefixUri.Host + "/" + originPrefixUri.Path)
log.Debugln("Local origin prefix:", originPrefixPath)

mountPrefixStr := viper.GetString("StagePlugin.MountPrefix")
mountPrefixStr := param.StagePlugin_MountPrefix.GetString()
if len(mountPrefixStr) == 0 {
log.Errorln("Mount prefix is required; must be a local path (/mnt/foo/...)")
os.Exit(1)
}

shadowOriginPrefixStr := viper.GetString("StagePlugin.ShadowOriginPrefix")
shadowOriginPrefixStr := param.StagePlugin_ShadowOriginPrefix.GetString()
if len(shadowOriginPrefixStr) == 0 {
log.Errorln("Shadow origin prefix is required; must be a URL (osdf://....)")
os.Exit(1)
}

// Set the progress bars to the command line option
client.ObjectClientOptions.Token = viper.GetString("StagePlugin.Token")
client.ObjectClientOptions.Token = param.Plugin_Token.GetString()
client.ObjectClientOptions.Plugin = true

// Check if the program was executed from a terminal
Expand All @@ -128,7 +129,7 @@ func stagePluginMain(cmd *cobra.Command, args []string) {

var sources []string
var extraSources []string
isHook := viper.GetBool("StagePlugin.Hook")
isHook := param.StagePlugin_Hook.GetBool()
if isHook {
buffer := make([]byte, 100*1024)
bytesread, err := os.Stdin.Read(buffer)
Expand Down
39 changes: 39 additions & 0 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,42 @@ description: >-
type: int
default: 9999
components: ["origin"]
---

############################
# Plugin-level configs #
############################
name: Plugin.Token
description: >-
The specified token for pelican plugin staging
type: string
default: none
components: ["plugin"]
---
name: StagePlugin.Hook
description: >-
Flag to specify HTCondor hook behavior
type: bool
default: false
components: ["plugin"]
---
name: StagePlugin.MountPrefix
description: >-
Prefix corresponding to the local mount point of the origin
type: string
default: none
components: ["plugin"]
---
name: StagePlugin.OriginPrefix
description: >-
Prefix corresponding to the local origin
type: string
default: none
components: ["plugin"]
---
name: StagePlugin.ShadowOriginPrefix
description: >-
Prefix corresponding to the shadow origin
type: string
default: none
components: ["plugin"]

0 comments on commit e86ba50

Please sign in to comment.