diff --git a/pkg/manifest/account.go b/pkg/manifest/account.go index c343ad529..b482be550 100644 --- a/pkg/manifest/account.go +++ b/pkg/manifest/account.go @@ -40,7 +40,7 @@ func (e invalidUUIDError) Unwrap() error { return e.err } -func convertSingleAccount(c *LoaderContext, a account) (Account, error) { +func parseSingleAccount(c *LoaderContext, a account) (Account, error) { if a.AccountUUID == "" { return Account{}, errAccUidMissing @@ -75,8 +75,8 @@ func convertSingleAccount(c *LoaderContext, a account) (Account, error) { return acc, nil } -// convertAccounts converts the persistence definition to the in-memory definition -func convertAccounts(c *LoaderContext, accounts []account) (map[string]Account, error) { +// parseAccounts converts the persistence definition to the in-memory definition +func parseAccounts(c *LoaderContext, accounts []account) (map[string]Account, error) { result := make(map[string]Account, len(accounts)) @@ -85,7 +85,7 @@ func convertAccounts(c *LoaderContext, accounts []account) (map[string]Account, return nil, fmt.Errorf("failed to parse account on position %d: %w", i, errNameMissing) } - acc, err := convertSingleAccount(c, a) + acc, err := parseSingleAccount(c, a) if err != nil { return nil, fmt.Errorf("failed to parse account %q: %w", a.Name, err) } diff --git a/pkg/manifest/account_test.go b/pkg/manifest/account_test.go index eb8e30e2f..5894419e3 100644 --- a/pkg/manifest/account_test.go +++ b/pkg/manifest/account_test.go @@ -61,7 +61,7 @@ func TestValidAccounts(t *testing.T) { }, } - v, err := convertAccounts(&LoaderContext{}, []account{acc, acc2}) + v, err := parseAccounts(&LoaderContext{}, []account{acc, acc2}) assert.NoError(t, err) assert.Equal(t, v, map[string]Account{ @@ -119,7 +119,7 @@ func TestInvalidAccounts(t *testing.T) { } // validate that the default is valid - _, err := convertAccounts(&LoaderContext{}, []account{validAccount}) + _, err := parseAccounts(&LoaderContext{}, []account{validAccount}) assert.NoError(t, err) // tests @@ -127,7 +127,7 @@ func TestInvalidAccounts(t *testing.T) { a := validAccount a.Name = "" - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) assert.ErrorIs(t, err, errNameMissing) }) @@ -135,7 +135,7 @@ func TestInvalidAccounts(t *testing.T) { a := validAccount a.AccountUUID = "" - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) assert.ErrorIs(t, err, errAccUidMissing) }) @@ -143,7 +143,7 @@ func TestInvalidAccounts(t *testing.T) { a := deepCopy(t, validAccount) a.AccountUUID = "this-is-not-a-valid-uuid" - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) uuidErr := invalidUUIDError{} if assert.ErrorAs(t, err, &uuidErr) { assert.Equal(t, uuidErr.uuid, "this-is-not-a-valid-uuid") @@ -154,7 +154,7 @@ func TestInvalidAccounts(t *testing.T) { a := deepCopy(t, validAccount) a.OAuth = oAuth{} - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) assert.ErrorContains(t, err, "oAuth is invalid") }) @@ -162,7 +162,7 @@ func TestInvalidAccounts(t *testing.T) { a := deepCopy(t, validAccount) a.OAuth.ClientID = authSecret{} - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) assert.ErrorContains(t, err, "ClientID: no name given or empty") }) @@ -171,7 +171,7 @@ func TestInvalidAccounts(t *testing.T) { a := deepCopy(t, validAccount) a.OAuth.ClientSecret = authSecret{} - _, err := convertAccounts(&LoaderContext{}, []account{a}) + _, err := parseAccounts(&LoaderContext{}, []account{a}) assert.ErrorContains(t, err, "ClientSecret: no name given or empty") }) } diff --git a/pkg/manifest/manifest_loader.go b/pkg/manifest/manifest_loader.go index d99213fac..b72c42a2e 100644 --- a/pkg/manifest/manifest_loader.go +++ b/pkg/manifest/manifest_loader.go @@ -152,7 +152,7 @@ func LoadManifest(context *LoaderContext) (Manifest, []error) { var errs []error // projects - projectDefinitions, projectErrors := toProjectDefinitions(&projectLoaderContext{ + projectDefinitions, projectErrors := parseProjects(&projectLoaderContext{ fs: workingDirFs, manifestPath: relativeManifestPath, }, manifestYAML.Projects) @@ -163,7 +163,7 @@ func LoadManifest(context *LoaderContext) (Manifest, []error) { } // environments - environmentDefinitions, manifestErrors := toEnvironments(context, manifestYAML.EnvironmentGroups) + environmentDefinitions, manifestErrors := parseEnvironments(context, manifestYAML.EnvironmentGroups) if manifestErrors != nil { errs = append(errs, manifestErrors...) } else if len(environmentDefinitions) == 0 { @@ -171,7 +171,7 @@ func LoadManifest(context *LoaderContext) (Manifest, []error) { } // accounts - accounts, accErr := convertAccounts(context, manifestYAML.Accounts) + accounts, accErr := parseAccounts(context, manifestYAML.Accounts) if accErr != nil { errs = append(errs, newManifestLoaderError(context.ManifestPath, accErr.Error())) } @@ -330,7 +330,7 @@ func validateVersion(m manifest) error { return nil } -func toEnvironments(context *LoaderContext, groups []group) (map[string]EnvironmentDefinition, []error) { // nolint:gocognit +func parseEnvironments(context *LoaderContext, groups []group) (map[string]EnvironmentDefinition, []error) { // nolint:gocognit var errors []error environments := make(map[string]EnvironmentDefinition) @@ -367,7 +367,7 @@ func toEnvironments(context *LoaderContext, groups []group) (map[string]Environm continue } - parsedEnv, configErrors := parseEnvironment(context, env, group.Name) + parsedEnv, configErrors := parseSingleEnvironment(context, env, group.Name) if configErrors != nil { errors = append(errors, configErrors...) @@ -415,7 +415,7 @@ func shouldSkipEnv(context *LoaderContext, group group, env environment) bool { return true } -func parseEnvironment(context *LoaderContext, config environment, group string) (EnvironmentDefinition, []error) { +func parseSingleEnvironment(context *LoaderContext, config environment, group string) (EnvironmentDefinition, []error) { var errs []error a, err := parseAuth(context, config.Auth) @@ -489,7 +489,7 @@ func parseURLDefinition(context *LoaderContext, u url) (URLDefinition, error) { return URLDefinition{}, fmt.Errorf("%q is not a valid URL type", u.Type) } -func toProjectDefinitions(context *projectLoaderContext, definitions []project) (map[string]ProjectDefinition, []error) { +func parseProjects(context *projectLoaderContext, definitions []project) (map[string]ProjectDefinition, []error) { var errors []error result := make(map[string]ProjectDefinition) diff --git a/pkg/manifest/manifest_loader_test.go b/pkg/manifest/manifest_loader_test.go index 3eac06fa0..feb5581ed 100644 --- a/pkg/manifest/manifest_loader_test.go +++ b/pkg/manifest/manifest_loader_test.go @@ -483,11 +483,11 @@ func Test_toProjectDefinitions(t *testing.T) { t.Run(tt.name, func(t *testing.T) { context := &projectLoaderContext{testFs, "path/to/a/manifest.yaml"} - got, gotErrs := toProjectDefinitions(context, tt.projectDefinitions) + got, gotErrs := parseProjects(context, tt.projectDefinitions) numErrs := len(gotErrs) if (tt.wantErrs && numErrs <= 0) || (!tt.wantErrs && numErrs > 0) { - t.Errorf("toProjectDefinitions() returned unexpected Errors = %v", gotErrs) + t.Errorf("parseProjects() returned unexpected Errors = %v", gotErrs) } assert.Equal(t, tt.want, got)