Skip to content

Commit

Permalink
Fix startup err from the new credential
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Apr 30, 2024
1 parent c15e252 commit d3fc8c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
12 changes: 12 additions & 0 deletions scripts/init/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

SCRIPT_DIR=$(cd $(dirname "$0") && pwd)

# Check if python3-venv is installed
if ! dpkg -s python3-venv &> /dev/null; then
echo "python3-venv package is not installed. Installing..."
sudo apt-get update && sudo apt-get install python3-venv
if [ $? -ne 0 ]; then
echo "Failed to install python3-venv. Please install it manually."
exit 1
fi
else
echo "python3-venv package is already installed."
fi

echo "Creating and activating the virtual environment..."
python3 -m venv "$SCRIPT_DIR/initPyEnv"
source "$SCRIPT_DIR/initPyEnv/bin/activate"
Expand Down
31 changes: 17 additions & 14 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"flag"
"fmt"
"os"
"os/user"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -180,27 +181,29 @@ func setConfig() {
}

// Load credentials
usr, err := user.Current()
if err != nil {
log.Error().Err(err).Msg("")
}
credPath := usr.HomeDir + "/.cloud-barista"
credViper := viper.New()
fileName = "cred"
credViper.AddConfigPath(".")
credViper.AddConfigPath("./conf/.cred/")
credViper.AddConfigPath("../conf/.cred/")
fileName = "credentials"
credViper.AddConfigPath(credPath)
credViper.SetConfigName(fileName)
credViper.SetConfigType("yaml")
err = credViper.ReadInConfig()
if err != nil {
panic(fmt.Errorf("fatal error reading credential file: %w", err))
}

log.Info().Msg(credViper.ConfigFileUsed())
err = credViper.Unmarshal(&common.RuntimeCredential)
if err != nil {
log.Error().Err(err).Msg("")
panic(err)
log.Info().Err(err).Msg("")
} else {
log.Info().Msg(credViper.ConfigFileUsed())
err = credViper.Unmarshal(&common.RuntimeCredential)
if err != nil {
log.Error().Err(err).Msg("")
panic(err)
}
common.PrintCredentialInfo(common.RuntimeCredential)
}

common.PrintCredentialInfo(common.RuntimeCredential)

// err = common.RegisterAllCloudInfo()
// if err != nil {
// log.Error().Err(err).Msg("Failed to register credentials")
Expand Down

0 comments on commit d3fc8c1

Please sign in to comment.