Skip to content

Commit

Permalink
🥅 | concised error-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1sm0s1n committed Mar 23, 2024
1 parent bbdba1a commit 8366666
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ func CreateDockerComposeCA(orgPeers map[string]int) {

viper.Set(fmt.Sprintf("services.ca_%v.networks", org), networkSlice)

err := viper.SafeWriteConfig()
if err != nil {
if err := viper.SafeWriteConfig(); err != nil {
if _, ok := err.(viper.ConfigFileAlreadyExistsError); ok {
err = viper.WriteConfig()
if err != nil {
if err = viper.WriteConfig(); err != nil {
log.Fatalf("Error while updating config file %s", err)
}
} else {
Expand Down Expand Up @@ -324,11 +322,9 @@ func CreateDockerComposeMembers(domainName string, orgPeers map[string]int) {
CLIDepends = append(CLIDepends, fmt.Sprintf("peer%v.%v.%v", peer, org, domainName))
custom_viper.Set("services:cli:depends_on", CLIDepends)

err := custom_viper.SafeWriteConfig()
if err != nil {
if err := custom_viper.SafeWriteConfig(); err != nil {
if _, ok := err.(viper.ConfigFileAlreadyExistsError); ok {
err = custom_viper.WriteConfig()
if err != nil {
if err = custom_viper.WriteConfig(); err != nil {
log.Fatalf("Error while updating config file %s", err)
}
} else {
Expand Down

0 comments on commit 8366666

Please sign in to comment.