Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cscli/hub: don't return error if some file can't be recognized #3150

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/cwhub/sync.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cwhub

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -99,7 +100,7 @@

if ret.ftype != PARSERS && ret.ftype != POSTOVERFLOWS {
if !slices.Contains(ItemTypes, ret.stage) {
return nil, fmt.Errorf("unknown configuration type for file '%s'", path)
return nil, errors.New("unknown configuration type")

Check warning on line 103 in pkg/cwhub/sync.go

View check run for this annotation

Codecov / codecov/patch

pkg/cwhub/sync.go#L103

Added line #L103 was not covered by tests
}

ret.ftype = ret.stage
Expand Down Expand Up @@ -196,7 +197,8 @@

info, err := h.getItemFileInfo(path, h.logger)
if err != nil {
return err
h.logger.Warningf("Ignoring file %s: %s", path, err)
return nil

Check warning on line 201 in pkg/cwhub/sync.go

View check run for this annotation

Codecov / codecov/patch

pkg/cwhub/sync.go#L200-L201

Added lines #L200 - L201 were not covered by tests
}

// non symlinks are local user files or hub files
Expand Down
7 changes: 7 additions & 0 deletions test/bats/20_hub_items.bats
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,10 @@ teardown() {
rune -0 jq -c '.tainted' <(output)
assert_output 'false'
}

@test "skip files if we can't guess their type" {
rune -0 mkdir -p "$CONFIG_DIR/scenarios/foo"
rune -0 touch "$CONFIG_DIR/scenarios/foo/bar.yaml"
rune -0 cscli hub list
assert_stderr --partial "Ignoring file $CONFIG_DIR/scenarios/foo/bar.yaml: unknown configuration type"
}
Loading