Skip to content

Commit

Permalink
chore: remove internal
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Aug 27, 2024
1 parent 0145040 commit 63b29fe
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 34 deletions.
3 changes: 2 additions & 1 deletion artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"

artifactFS "github.com/flanksource/artifacts/fs"
"github.com/flanksource/duty/context"
"github.com/flanksource/duty/models"
"github.com/gabriel-vasile/mimetype"
Expand Down Expand Up @@ -43,7 +44,7 @@ type Artifact struct {

const maxBytesForMimeDetection = 512 * 1024 // 512KB

func SaveArtifact(ctx context.Context, fs FilesystemRW, artifact *models.Artifact, data Artifact) error {
func SaveArtifact(ctx context.Context, fs artifactFS.FilesystemRW, artifact *models.Artifact, data Artifact) error {
defer data.Content.Close()

checksum := sha256.New()
Expand Down
19 changes: 2 additions & 17 deletions connection_filesystem.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package artifacts

import (
gocontext "context"
"fmt"
"io"
"net/url"
"os"
"strconv"

"github.com/flanksource/artifacts/internal/fs"
"github.com/flanksource/artifacts/fs"
"github.com/google/uuid"

"github.com/flanksource/duty/connection"
Expand All @@ -17,19 +14,7 @@ import (
"github.com/flanksource/duty/types"
)

type Filesystem interface {
Close() error
ReadDir(name string) ([]fs.FileInfo, error)
Stat(name string) (os.FileInfo, error)
}

type FilesystemRW interface {
Filesystem
Read(ctx gocontext.Context, path string) (io.ReadCloser, error)
Write(ctx gocontext.Context, path string, data io.Reader) (os.FileInfo, error)
}

func GetFSForConnection(ctx context.Context, c models.Connection) (FilesystemRW, error) {
func GetFSForConnection(ctx context.Context, c models.Connection) (fs.FilesystemRW, error) {
switch c.Type {
case models.ConnectionTypeFolder:
path := c.Properties["path"]
Expand Down
31 changes: 31 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fs

import (
gocontext "context"
"io"
"os"
)

// FileInfo is a wrapper for os.FileInfo that also returns the full path of the file.
//
// FullPath is required to support globs with ReadDir()
type FileInfo interface {
os.FileInfo
FullPath() string
}

type ListItemLimiter interface {
SetMaxListItems(maxList int)
}

type Filesystem interface {
Close() error
ReadDir(name string) ([]FileInfo, error)
Stat(name string) (os.FileInfo, error)
}

type FilesystemRW interface {
Filesystem
Read(ctx gocontext.Context, path string) (io.ReadCloser, error)
Write(ctx gocontext.Context, path string, data io.Reader) (os.FileInfo, error)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/fs/s3_test.go → fs/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
s3Types "github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/flanksource/artifacts/internal/fs"
"github.com/flanksource/artifacts/fs"
"github.com/flanksource/duty/connection"
"github.com/flanksource/duty/context"
"github.com/flanksource/duty/types"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ require (
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/flanksource/commons v1.28.0
github.com/flanksource/duty v1.0.598
github.com/flanksource/s3fs/v2 v2.0.0-20240725044221-83a6635a9212
github.com/gabriel-vasile/mimetype v1.4.3
github.com/google/uuid v1.6.0
github.com/hirochachacha/go-smb2 v1.1.0
github.com/pkg/sftp v1.13.6
github.com/samber/lo v1.46.0
golang.org/x/crypto v0.26.0
google.golang.org/api v0.169.0
)
Expand Down Expand Up @@ -144,7 +144,6 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/robertkrimen/otto v0.3.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/samber/lo v1.46.0 // indirect
github.com/samber/oops v1.12.1 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,6 @@ github.com/flanksource/kommons v0.31.4 h1:zksAgYjZuwPgS8XTejDIWEYB0nPSU1i3Jxcavm
github.com/flanksource/kommons v0.31.4/go.mod h1:70BPMzjTvejsqRyVyAm/ZCeZ176toCvauaZjU03svnE=
github.com/flanksource/kubectl-neat v1.0.4 h1:t5/9CqgE84oEtB0KitgJ2+WIeLfD+RhXSxYrqb4X8yI=
github.com/flanksource/kubectl-neat v1.0.4/go.mod h1:Un/Voyh3cmiZNKQrW/TkAl28nAA7vwnwDGVjRErKjOw=
github.com/flanksource/s3fs/v2 v2.0.0-20240725044221-83a6635a9212 h1:HYf/+5pyMBSKMvU7b5dTDRihxjZxVYvUcp01FGfEpc8=
github.com/flanksource/s3fs/v2 v2.0.0-20240725044221-83a6635a9212/go.mod h1:uUe9wx3l0wIkTJvxOumTCgsESmooemk9di3q0BvJ4Bg=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down
11 changes: 0 additions & 11 deletions internal/fs/fs.go

This file was deleted.

0 comments on commit 63b29fe

Please sign in to comment.