-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and simplify consent manager functions
- Loading branch information
Showing
31 changed files
with
129 additions
and
690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package consent | ||
|
||
// GetAllSourceConsentStates gets the consent states for all sources. | ||
// It does not get the global consent state. | ||
// If continueOnErr is true, it will continue to the next source if an error occurs. | ||
func (cm Manager) GetAllSourceConsentStates(continueOnErr bool) (map[string]bool, error) { | ||
p, err := cm.getConsentFiles() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
consentStates := make(map[string]bool) | ||
for source, path := range p { | ||
consent, err := readConsentFile(path) | ||
if err != nil && !continueOnErr { | ||
return nil, err | ||
} | ||
if err != nil { | ||
continue | ||
} | ||
|
||
consentStates[source] = consent.ConsentState | ||
} | ||
|
||
return consentStates, nil | ||
} |
1 change: 1 addition & 0 deletions
1
internal/consent/testdata/TestGetConsentState/golden/valid_false_global_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
false |
1 change: 1 addition & 0 deletions
1
internal/consent/testdata/TestGetConsentState/golden/valid_true_global_file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
true |
1 change: 1 addition & 0 deletions
1
...al/consent/testdata/TestGetConsentState/golden/valid_true_global_file,_valid_false_source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
false |
1 change: 1 addition & 0 deletions
1
...nal/consent/testdata/TestGetConsentState/golden/valid_true_global_file,_valid_true_source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
true |
29 changes: 0 additions & 29 deletions
29
internal/consent/testdata/TestGetConsentStates/golden/invalid_file_global_file
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
internal/consent/testdata/TestGetConsentStates/golden/invalid_value_global_file
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.