Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Merge requests
!175
Couldn't fetch the linked file.
Load controller defaults from config
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Load controller defaults from config
istaester/load-controller-defaults-from-config
into
develop
Overview
3
Commits
15
Pipelines
16
Changes
10
Merged
Ghost User
requested to merge
istaester/load-controller-defaults-from-config
into
develop
3 years ago
Overview
3
Commits
15
Pipelines
16
Changes
1
Expand
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation.
I have updated the documentation accordingly.
I have read the
CONTRIBUTING
document.
I have added tests to cover my changes.
All new and existing tests passed.
Edited
3 years ago
by
Ghost User
0
0
Merge request reports
Compare
version 1
version 13
9fafcd33
3 years ago
version 12
1a4b4b74
3 years ago
version 11
497568f8
3 years ago
version 10
b8dee43e
3 years ago
version 9
f5d86c04
3 years ago
version 8
ff032665
3 years ago
version 7
794f6ab5
3 years ago
version 6
4273a907
3 years ago
version 5
8563c069
3 years ago
version 4
c858537f
3 years ago
version 3
4700025b
3 years ago
version 2
2c6270ca
3 years ago
version 1
5e10fd6e
3 years ago
develop (base)
and
version 3
latest version
701d6847
15 commits,
3 years ago
version 13
9fafcd33
14 commits,
3 years ago
version 12
1a4b4b74
13 commits,
3 years ago
version 11
497568f8
12 commits,
3 years ago
version 10
b8dee43e
11 commits,
3 years ago
version 9
f5d86c04
10 commits,
3 years ago
version 8
ff032665
9 commits,
3 years ago
version 7
794f6ab5
8 commits,
3 years ago
version 6
4273a907
7 commits,
3 years ago
version 5
8563c069
6 commits,
3 years ago
version 4
c858537f
4 commits,
3 years ago
version 3
4700025b
3 commits,
3 years ago
version 2
2c6270ca
2 commits,
3 years ago
version 1
5e10fd6e
1 commit,
3 years ago
Show latest version
1 file
+
31
−
25
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
nucleus/config.go
+
31
−
25
Options
@@ -5,51 +5,57 @@ import (
"github.com/spf13/viper"
)
// Config represents the nucleus configuration
type
Config
struct
{
BasePndUUID
uuid
.
UUID
BaseSouthBoundType
int32
BaseSouthBoundUUID
uuid
.
UUID
}
func
getUUIDFromViper
(
viperKey
string
)
(
uuid
.
UUID
,
error
)
{
UUIDAsString
:=
viper
.
GetString
(
viperKey
)
if
UUIDAsString
==
""
{
newUUID
:=
uuid
.
New
()
viper
.
Set
(
viperKey
,
newUUID
.
String
())
viper
.
WriteConfig
()
return
newUUID
,
nil
}
parsedUUID
,
err
:=
uuid
.
Parse
(
UUIDAsString
)
if
err
!=
nil
{
return
uuid
.
Nil
,
err
}
return
parsedUUID
,
nil
}
// InitializeConfig loads the configuration
func
(
c
*
Config
)
InitializeConfig
()
error
{
var
err
error
basePNDUUIDConfigLookupKey
:=
"basePNDUUID"
baseSouthBoundTypeConfigLookupKey
:=
"baseSouthBoundType"
baseSouthBoundUUIDConfigLookupKey
:=
"baseSouthBoundUUID"
// Check if there is already an PND uuid persistet in the viper config.
pndUUIDAsString
:=
viper
.
GetString
(
basePNDUUIDConfigLookupKey
)
basePNDUUID
,
err
:=
getUUIDFromViper
(
basePNDUUIDConfigLookupKey
)
if
err
!=
nil
{
return
err
}
if
pndUUIDAsString
==
""
{
c
.
BasePndUUID
=
uuid
.
New
()
viper
.
Set
(
basePNDUUIDConfigLookupKey
,
c
.
BasePndUUID
.
String
())
viper
.
WriteConfig
()
}
else
{
c
.
BasePndUUID
,
err
=
uuid
.
Parse
(
pndUUIDAsString
)
if
err
!=
nil
{
return
err
}
c
.
BasePndUUID
=
basePNDUUID
baseSouthBoundUUID
,
err
:=
getUUIDFromViper
(
baseSouthBoundUUIDConfigLookupKey
)
if
err
!=
nil
{
return
err
}
c
.
BaseSouthBoundUUID
=
baseSouthBoundUUID
c
.
BaseSouthBoundType
=
viper
.
GetInt32
(
"BaseSouthBoundType"
)
if
c
.
BaseSouthBoundType
!=
0
{
viper
.
Set
(
baseSouthBoundTypeConfigLookupKey
,
0
)
viper
.
WriteConfig
()
}
// Check if there is already an PND uuid persistet in the viper config.
southBoundUUIDAsString
:=
viper
.
GetString
(
basePNDUUIDConfigLookupKey
)
if
southBoundUUIDAsString
==
""
{
c
.
BaseSouthBoundUUID
=
uuid
.
New
()
viper
.
Set
(
baseSouthBoundUUIDConfigLookupKey
,
c
.
BaseSouthBoundUUID
.
String
())
viper
.
WriteConfig
()
}
else
{
c
.
BaseSouthBoundUUID
,
err
=
uuid
.
Parse
(
southBoundUUIDAsString
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
Loading