Skip to content

Commit

Permalink
🟢 opinionated linter...
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus committed Mar 8, 2024
1 parent 77bb81a commit 673f417
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 304 deletions.
18 changes: 10 additions & 8 deletions providers-sdk/v1/inventory/asset_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func (a *AssetUrlSchema) Add(branch *AssetUrlBranch) error {
if branch == nil {
return errors.New("cannot attach empty asset url branch")
}
if len(branch.Path) == 0 {
if len(branch.PathSegments) == 0 {
return errors.New("don't know where to attach asset url branch")
}

urlChain, err := NewAssetUrlChain(branch.Path)
urlChain, err := NewAssetUrlChain(branch.PathSegments)
if err != nil {
return err
}
Expand All @@ -140,7 +140,7 @@ func (a *AssetUrlSchema) Add(branch *AssetUrlBranch) error {
}

if found == nil {
return errors.New("failed to attach asset url branch to any existing subtree for: " + strings.Join(branch.Path, "/"))
return errors.New("failed to attach asset url branch to any existing subtree for: " + strings.Join(branch.PathSegments, "/"))
}

if err = branch.validate(); err != nil {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (a *AssetUrlBranch) validate() error {
branch := branches[i]
i++

if len(branch.Reference) != 0 {
if len(branch.References) != 0 {
if len(branch.Key) != 0 {
return errors.New("asset url segment with reference cannot have a key set")
}
Expand Down Expand Up @@ -240,12 +240,12 @@ func (a *AssetUrlSchema) cloneBranch(branch *AssetUrlBranch, depth uint32, isDer
return nil, errors.New("maximum depth reached for asset url during clone (look for circular branch references)")
}

if len(branch.Reference) != 0 {
if len(branch.References) != 0 {
if isDereferenced {
return nil, errors.New("dereferenced an asset url branch with more references (reference to = '" + strings.Join(branch.Reference, "/") + "')")
return nil, errors.New("dereferenced an asset url branch with more references (reference to = '" + strings.Join(branch.References, "/") + "')")
}

urlChain, err := NewAssetUrlChain(branch.Reference)
urlChain, err := NewAssetUrlChain(branch.References)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -293,7 +293,7 @@ func (a *AssetUrlSchema) RefreshCache() error {
branch := branches[i]
i++

if len(branch.Reference) != 0 {
if len(branch.References) != 0 {
res, err := a.cloneBranch(branch, branch.Depth, false)
if err != nil {
return err
Expand Down Expand Up @@ -364,3 +364,5 @@ func buildParentQuery(leaf *AssetUrlBranch, value string) AssetUrlChain {

return res
}

func (a *AssetUrlSchema) PathToAssetUrlChain(path []string)

Check failure on line 368 in providers-sdk/v1/inventory/asset_url.go

View workflow job for this annotation

GitHub Actions / go-bench

missing function body
14 changes: 7 additions & 7 deletions providers-sdk/v1/inventory/asset_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func genTestSchema(t *testing.T) *AssetUrlSchema {
require.NoError(t, err)

err = root.Add(&AssetUrlBranch{
Path: []string{"technology=aws"},
Key: "account",
PathSegments: []string{"technology=aws"},
Key: "account",
Values: map[string]*AssetUrlBranch{
"*": {
Key: "service",
Values: map[string]*AssetUrlBranch{
"ec2": {
Reference: []string{"technology=os"},
References: []string{"technology=os"},
},
},
},
Expand All @@ -32,8 +32,8 @@ func genTestSchema(t *testing.T) *AssetUrlSchema {
require.NoError(t, err)

err = root.Add(&AssetUrlBranch{
Path: []string{"technology=os"},
Key: "family",
PathSegments: []string{"technology=os"},
Key: "family",
Values: map[string]*AssetUrlBranch{
"windows": {
Key: "platform",
Expand All @@ -46,8 +46,8 @@ func genTestSchema(t *testing.T) *AssetUrlSchema {
require.NoError(t, err)

err = root.Add(&AssetUrlBranch{
Path: []string{"technology=os", "family=windows", "platform=windows server"},
Key: "version",
PathSegments: []string{"technology=os", "family=windows", "platform=windows server"},
Key: "version",
Values: map[string]*AssetUrlBranch{
"2019": nil,
"2022": nil,
Expand Down
Loading

0 comments on commit 673f417

Please sign in to comment.