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

feat: KBC ignore, pull command #2136

Merged
merged 11 commits into from
Nov 19, 2024
7 changes: 1 addition & 6 deletions internal/pkg/project/ignore/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,5 @@ func LoadFile(ctx context.Context, fs filesystem.Fs, state *state.Registry, path
return nil, err
}

f := &File{
state: state,
rawStringPattern: content.Content,
}

return f, nil
return newFile(content.Content, state), nil
}
20 changes: 10 additions & 10 deletions internal/pkg/project/ignore/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ func (f *File) IgnoreConfigsOrRows() error {
return f.applyIgnoredPatterns()
}

// applyIgnoredPatterns parses the content for ignore patterns and applies them to configurations or rows.
func (f *File) applyIgnoredPatterns() error {
for _, pattern := range f.parseIgnoredPatterns() {
if err := f.applyIgnorePattern(pattern); err != nil {
continue
}
}
return nil
}

func (f *File) parseIgnoredPatterns() []string {
var ignorePatterns []string
lines := strings.Split(f.rawStringPattern, "\n")
Expand Down Expand Up @@ -43,13 +53,3 @@ func (f *File) applyIgnorePattern(ignoreConfig string) error {

return nil
}

// applyIgnoredPatterns parses the content for ignore patterns and applies them to configurations or rows.
func (f *File) applyIgnoredPatterns() error {
for _, pattern := range f.parseIgnoredPatterns() {
if err := f.applyIgnorePattern(pattern); err != nil {
continue
}
}
return nil
}
16 changes: 0 additions & 16 deletions internal/pkg/state/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (

type pathsRO = knownpaths.PathsReadOnly

const KBCIgnoreFilePath = ".keboola/kbc_ignore"

type Registry struct {
*pathsRO
paths *knownpaths.Paths
Expand Down Expand Up @@ -235,20 +233,6 @@ func (s *Registry) ConfigRowsFrom(config ConfigKey) (rows []*ConfigRowState) {
return rows
}

// func (s *Registry) SetIgnoredConfigsOrRows(ctx context.Context, fs filesystem.Fs, path string) error {
jachym-tousek-keboola marked this conversation as resolved.
Show resolved Hide resolved
// //strukturu pattre.field
// content, err := fs.ReadFile(ctx, filesystem.NewFileDef(path))
// if err != nil {
// return err
// }
//
// if content.Content == "" {
// return nil
// }
//
// return s.applyIgnoredPatterns(content.Content)
//}

func (s *Registry) GetPath(key Key) (AbsPath, bool) {
objectState, found := s.Get(key)
if !found {
Expand Down
15 changes: 0 additions & 15 deletions internal/pkg/state/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,6 @@ func TestStateTrackRecordInvalid(t *testing.T) {
assert.Empty(t, s.UntrackedPaths())
}

// func TestRegistry_SetIgnoredConfigsOrRows(t *testing.T) {
// t.Parallel()
// ctx := context.Background()
// registry := newTestState(t, knownpaths.NewNop(ctx))
// fs := aferofs.NewMemoryFs()
// require.NoError(t, fs.WriteFile(ctx, filesystem.NewRawFile(`foo/bar1`, "keboola.bar/678/34\nkeboola.foo/345")))
//
// require.NoError(t, registry.SetIgnoredConfigsOrRows(ctx, fs, "foo/bar1"))
//
// assert.Len(t, registry.IgnoredConfigRows(), 1)
// assert.Len(t, registry.IgnoredConfigs(), 1)
// assert.Equal(t, registry.IgnoredConfigRows()[0].ID.String(), "34")
// assert.Equal(t, registry.IgnoredConfigs()[0].ID.String(), "345")
//}

func TestRegistry_GetPath(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down