Skip to content

Commit

Permalink
Update LDA references
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzvonimir committed Nov 10, 2024
1 parent d656379 commit 69d62a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func newInstallCmd() *cobra.Command {
return installCmd
}

func NewLdaCmd() *cobra.Command {
func NewOdaCmd() *cobra.Command {
odaCmd := &cobra.Command{
Use: "oda",
Short: "Command line manager for ODA project.",
Expand Down Expand Up @@ -175,12 +175,12 @@ func setupConfig() {
fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get home directory: %s\n", err)
os.Exit(1)
}
odaDir, err := config.GetLdaDir(homeDir, sudoExecUser)
odaDir, err := config.GetOdaDir(homeDir, sudoExecUser)
if err != nil {
fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get ODA directory: %s\n", err)
os.Exit(1)
}
exePath, err := config.GetLdaBinaryPath()
exePath, err := config.GetOdaBinaryPath()
if err != nil {
fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get executable path: %s\n", err)
os.Exit(1)
Expand All @@ -206,7 +206,7 @@ func setupConfig() {
Os: int64(osConf),
OsName: osName,
HomeDir: homeDir,
LdaDir: odaDir,
OdaDir: odaDir,
IsRoot: isRoot,
ExePath: exePath,
User: sudoExecUser,
Expand All @@ -218,7 +218,7 @@ func setupConfig() {

// Execute is the entry point for the command line
func Execute() {
odaCmd := NewLdaCmd()
odaCmd := NewOdaCmd()
if err := odaCmd.Execute(); err != nil {
logging.Log.Err(err).Msg("Failed to execute main oda command")
os.Exit(1)
Expand Down Expand Up @@ -368,7 +368,7 @@ func install(cmd *cobra.Command, _ []string) error {
ShellLocation: shellLocation,
IsRoot: user.Conf.IsRoot,
SudoExecUser: user.Conf.User,
LdaDir: user.Conf.LdaDir,
OdaDir: user.Conf.OdaDir,
HomeDir: user.Conf.HomeDir,
}

Expand Down Expand Up @@ -415,7 +415,7 @@ func uninstall(_ *cobra.Command, _ []string) error {
ShellLocation: shellLocation,
IsRoot: user.Conf.IsRoot,
SudoExecUser: user.Conf.User,
LdaDir: user.Conf.LdaDir,
OdaDir: user.Conf.OdaDir,
HomeDir: user.Conf.HomeDir,
}
shl, err := shell.NewShell(shellConfig, logging.Log)
Expand Down
8 changes: 4 additions & 4 deletions config/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func GetHomeDir(isRoot bool, user *user.User) (string, error) {
return home, nil
}

// GetLdaDir returns the directory for the shell configuration
func GetLdaDir(homeDir string, user *user.User) (string, error) {
// GetOdaDir returns the directory for the shell configuration
func GetOdaDir(homeDir string, user *user.User) (string, error) {
dir := filepath.Join(homeDir, ".oda")
if err := util.CreateDirAndChown(dir, os.ModePerm, user); err != nil {
return "", err
Expand All @@ -108,8 +108,8 @@ func GetLdaDir(homeDir string, user *user.User) (string, error) {
return dir, nil
}

// GetLdaBinaryPath returns the path to the oda binary
func GetLdaBinaryPath() (string, error) {
// GetOdaBinaryPath returns the path to the oda binary
func GetOdaBinaryPath() (string, error) {
exePath, err := os.Executable()
if err != nil {
return "", err
Expand Down
10 changes: 5 additions & 5 deletions shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type Config struct {
ShellLocation string
IsRoot bool
SudoExecUser *user.User
LdaDir string
OdaDir string
HomeDir string
}

Expand All @@ -92,9 +92,9 @@ func NewShell(config *Config, logger zerolog.Logger) (*Shell, error) {
// InstallShellConfiguration installs the shell configuration
func (s *Shell) InstallShellConfiguration() error {

filePath := filepath.Join(s.Config.LdaDir, shellScriptName[s.Config.ShellType])
filePath := filepath.Join(s.Config.OdaDir, shellScriptName[s.Config.ShellType])

collectorFilePath := filepath.Join(s.Config.LdaDir, CollectorName)
collectorFilePath := filepath.Join(s.Config.OdaDir, CollectorName)

cmdTmpl, err := template.ParseFS(templateFS, CollectorScript)
if err != nil {
Expand Down Expand Up @@ -148,14 +148,14 @@ func (s *Shell) InstallShellConfiguration() error {
// DeleteShellConfiguration removes the shell configuration
func (s *Shell) DeleteShellConfiguration() error {

filePath := filepath.Join(s.Config.LdaDir, "oda.sh")
filePath := filepath.Join(s.Config.OdaDir, "oda.sh")

if err := os.Remove(filePath); err != nil {
s.logger.Err(err).Msg("Failed to remove shell configuration")
return err
}

filePath = filepath.Join(s.Config.LdaDir, "collector.sh")
filePath = filepath.Join(s.Config.OdaDir, "collector.sh")
if err := os.Remove(filePath); err != nil {
s.logger.Err(err).Msg("Failed to remove shell configuration")
return err
Expand Down
8 changes: 4 additions & 4 deletions user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ type Config struct {
OsName string `json:"os_name" db:"os_name"`
// HomeDir is the user home directory
HomeDir string `json:"home_dir" db:"home_dir"`
// LdaDir is the home ODA directory where all configurations are stored.
LdaDir string `json:"oda_dir" db:"oda_dir"`
// OdaDir is the home ODA directory where all configurations are stored.
OdaDir string `json:"oda_dir" db:"oda_dir"`
// IsRoot is a value to check if the user is root
IsRoot bool `json:"is_root" db:"is_root"`
// ExePath is the path to the oda binary
Expand Down Expand Up @@ -256,8 +256,8 @@ func CompareConfig(existingConf, currentConf *Config) (bool, []string) {
if existingConf.HomeDir != currentConf.HomeDir {
diffs = append(diffs, fmt.Sprintf("Home Directory changed from %s to %s", existingConf.HomeDir, currentConf.HomeDir))
}
if existingConf.LdaDir != currentConf.LdaDir {
diffs = append(diffs, fmt.Sprintf("ODA Directory changed from %s to %s", existingConf.LdaDir, currentConf.LdaDir))
if existingConf.OdaDir != currentConf.OdaDir {
diffs = append(diffs, fmt.Sprintf("ODA Directory changed from %s to %s", existingConf.OdaDir, currentConf.OdaDir))
}
if existingConf.IsRoot != currentConf.IsRoot {
diffs = append(diffs, fmt.Sprintf("IsRoot status changed from %t to %t", existingConf.IsRoot, currentConf.IsRoot))
Expand Down

0 comments on commit 69d62a3

Please sign in to comment.