Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Clavis = &cobra.Command{ Use: "clavis", Short: "Preparing and securing RSConnect", Long: `This utility provisions an admin user in RSConnect. A password is generated and effort is made to surface those details to the user for login purposes.`, Run: func(cmd *cobra.Command, args []string) { var ViperConfiguration ViperConfig err := viper.Unmarshal(&ViperConfiguration) if err != nil { log.Fatalf("Failure unmarshalling viper contents") } log.Debug("Successfully marshalled viper down") if ViperConfiguration.Debug { log.SetLevel(log.DebugLevel) } log.Debugf("After starting and taking in arguments, location is currently %s", ViperConfiguration.Location) err = ViperConfiguration.Prepare() if err != nil { log.Fatalf("Failure locating requested user %s on the system. Error details are %s", ViperConfiguration.Username, err) } log.WithFields(log.Fields{ "location": ViperConfiguration.Location, "username": ViperConfiguration.Username, "username_from_user": ViperConfiguration.UserDetails.Username, }).Debug("Complex logic for config defaults completed") if ViperConfiguration.Name == "" || ViperConfiguration.Organization == "" || ViperConfiguration.Email == "" { log.Fatal("Either Name, Organization, or Email have not been provided! Please provide these flags at" + "runtime in order to use Clavis") } log.Debugf("Located username as %s", ViperConfiguration.Username) log.Debug("Looking for an existing configuration") existingConfig, err := readConfig(ViperConfiguration) if err == nil && existingConfig.Completed { log.Info("A config already exists for this user. No work to be done") return } if ok, _ := afero.Exists(afero.NewOsFs(), filepath.Join(ViperConfiguration.Location, ViperConfiguration.File)); ok { log.Errorf("An RSConnect password file already exists at %s", filepath.Join(ViperConfiguration.Location, ViperConfiguration.File)) return } log.Debug("Attempting to create new user struct from Viper details") u := newRSConnectUser(ViperConfiguration) u, err = u.Create(ViperConfiguration) if err != nil { log.Fatalf("An error occurred while creating the user in RSConnect: %s", err) return } newConfig := Configuration{ Completed: true, PasswordFile: filepath.Join(ViperConfiguration.Location, ViperConfiguration.File), ShellConfigurationFile: ViperConfiguration.ShellConfig, Location: ViperConfiguration.Location, } log.Debug("Writing the details of the clavis config") err = newConfig.Store(ViperConfiguration.UserDetails) if err != nil { cmd.PrintErr(err) return } log.Info("Successfully provisioned user") }, }
Clavis is the root level command
var GeneratedPassword string
GeneratedPassword is the GUID generated for the purpose of one-time authentication
var Hush = &cobra.Command{ Use: "hush", Short: "Remove hush MOTD", Long: `Remove the MOTD file originally generated by hush, but also update the users shell configuration to no longer attempt to display it`, Run: func(cmd *cobra.Command, args []string) { err := hush(cmd) if err != nil { cmd.PrintErr(err) } }, }
Hush will use the existing configuration to remove the MOTD file and remove the line displaying it from the shell configuration
Functions ¶
func GetFiglyWithIt ¶
GetFiglyWithIt Produces figlet output
Types ¶
type Configuration ¶
type Configuration struct { Completed bool `yaml:"completed"` PasswordFile string `yaml:"password_file"` ShellConfigurationFile string `yaml:"shell_config"` Location string `yaml:"location"` }
Configuration represents a way to store the results of a run in a hidden file in the home directory (.clavis) so that other commands can be run referencing it later.
func (Configuration) Store ¶
func (c Configuration) Store(userdetail *user.User) error
Store is responsible for writing the configuration to the home directory for use later
func (Configuration) YAML ¶
func (c Configuration) YAML() ([]byte, error)
YAML will render the configuration to YAML structures
type RSConnectUser ¶
type RSConnectUser struct { //Components required for transmission Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Password string `json:"password"` SetOwnPassword bool `json:"user_must_set_password"` Username string `json:"username"` //Additional components for serializing response ActiveTime string `json:"active_time,omitempty"` Confirmed bool `json:"confirmed,omitempty"` CreatedTime string `json:"created_time,omitempty"` GUID string `json:"guid,omitempty"` Locked bool `json:"locked,omitempty"` UpdatedTime string `json:"updated_time,omitempty"` UserRole string `json:"user_role,omitempty"` }
RSConnectUser is the structure defining an RSConnect User
func (RSConnectUser) Create ¶
func (u RSConnectUser) Create(config ViperConfig) (RSConnectUser, error)
Create performs the request to the RS Connect server
func (RSConnectUser) JSON ¶
func (u RSConnectUser) JSON() ([]byte, error)
JSON returns the json representative string for the object
func (RSConnectUser) Request ¶
func (u RSConnectUser) Request() (*http.Request, error)
Request generates the HTTP request to be made
func (RSConnectUser) TemplateSpec ¶
func (u RSConnectUser) TemplateSpec(config ViperConfig) (TemplateSpec, error)
TemplateSpec creates a TemplateSpec from the RSConnect User
type TemplateSpec ¶
type TemplateSpec struct { OrganizationFiglet string Organization string Username string PasswordFile string }
TemplateSpec is a struct used for the outputTemplate file template
func (TemplateSpec) Render ¶
func (t TemplateSpec) Render() (string, error)
Render is used to generate content to the template structure
func (TemplateSpec) Write ¶
func (t TemplateSpec) Write(config ViperConfig) error
Write will write the rendered content down to the desired File
type ViperConfig ¶ added in v0.0.3
type ViperConfig struct { Username string `mapstructure:"username" json:"username" yaml:"username"` File string `mapstructure:"file" json:"file" yaml:"file"` Location string `mapstructure:"location" json:"location" yaml:"location"` Email string `mapstructure:"email" json:"email" yaml:"email"` Name string `mapstructure:"name" json:"name" yaml:"name"` Organization string `mapstructure:"organization" json:"organization" yaml:"organization"` ShellConfig string `mapstructure:"shell_config" json:"shell_config" yaml:"shell_config"` Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"` CreateMOTD bool `mapstructure:"create_motd" json:"create_motd" yaml:"create_motd"` UserDetails *user.User }
func (*ViperConfig) Prepare ¶ added in v0.0.8
func (v *ViperConfig) Prepare() error