mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 15:01:29 +02:00
Fix review
This commit is contained in:
@@ -213,10 +213,10 @@ func (pm *ProfileManager) getProfileConfigPath(id string) (string, error) {
|
||||
return filepath.Join(profilesDir, id+".json"), nil
|
||||
}
|
||||
|
||||
// GetConfigPath returns the config file path for a given profile
|
||||
// GetConfigPath returns the config file path for a given profile id
|
||||
// Java should call this instead of constructing paths with Preferences.configFile()
|
||||
func (pm *ProfileManager) GetConfigPath(profileName string) (string, error) {
|
||||
return pm.getProfileConfigPath(profileName)
|
||||
func (pm *ProfileManager) GetConfigPath(id string) (string, error) {
|
||||
return pm.getProfileConfigPath(id)
|
||||
}
|
||||
|
||||
// GetStateFilePath returns the state file path for a given profile
|
||||
|
||||
@@ -171,7 +171,7 @@ func getActiveProfile(ctx context.Context, pm *profilemanager.ProfileManager, pr
|
||||
}
|
||||
|
||||
func switchProfileOnDaemon(ctx context.Context, pm *profilemanager.ProfileManager, handle string, username string) error {
|
||||
resolvedID, err := switchProfile(context.Background(), handle, username)
|
||||
resolvedID, err := switchProfile(ctx, handle, username)
|
||||
if err != nil {
|
||||
return fmt.Errorf("switch profile on daemon: %v", err)
|
||||
}
|
||||
|
||||
@@ -843,6 +843,7 @@ func TestAddConfig_AllFieldsCovered(t *testing.T) {
|
||||
"PreSharedKey": "sensitive: WireGuard pre-shared key",
|
||||
"SSHKey": "sensitive: SSH private key",
|
||||
"ClientCertKeyPair": "non-config: parsed cert pair, not serialized",
|
||||
"Name": "non-config: profile name is not needed for debug purposes",
|
||||
}
|
||||
|
||||
mURL, _ := url.Parse("https://api.example.com:443")
|
||||
|
||||
@@ -442,7 +442,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) {
|
||||
ID: defaultProfileName,
|
||||
Name: defaultProfileName,
|
||||
Path: DefaultConfigPath,
|
||||
IsActive: activeIsDefault || activeID == defaultProfileName,
|
||||
IsActive: activeIsDefault,
|
||||
}}
|
||||
|
||||
configDir, err := s.getConfigDir(username)
|
||||
@@ -487,7 +487,7 @@ func (s *ServiceManager) loadAllProfiles(username string) ([]Profile, error) {
|
||||
ID: stem,
|
||||
Name: name,
|
||||
Path: path,
|
||||
IsActive: stem == activeID && !activeIsDefault,
|
||||
IsActive: stem == activeID,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -131,16 +131,6 @@ func TestServiceProfile_LegacyFilenameCoexists(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddProfile_RejectsDuplicateNameByDefault(t *testing.T) {
|
||||
withTestSM(t, func(sm *ServiceManager, username string) {
|
||||
_, err := sm.AddProfile("work", username)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = sm.AddProfile("work", username)
|
||||
assert.ErrorIs(t, err, ErrProfileAlreadyExists)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddProfile_AllowsDuplicateWithFlag(t *testing.T) {
|
||||
withTestSM(t, func(sm *ServiceManager, username string) {
|
||||
first, err := sm.AddProfile("work", username)
|
||||
|
||||
@@ -493,7 +493,7 @@ func (s *serviceClient) getConnectionForm() *widget.Form {
|
||||
if err != nil {
|
||||
log.Errorf("get active profile: %v", err)
|
||||
} else {
|
||||
activeProfName = activeProf.ID
|
||||
activeProfName = activeProf.Name
|
||||
}
|
||||
return &widget.Form{
|
||||
Items: []*widget.FormItem{
|
||||
|
||||
Reference in New Issue
Block a user