Skip to content

Commit

Permalink
feat: move to pkg (#522)
Browse files Browse the repository at this point in the history
* feat: move distribution download to pkg

* feat: move dependencies download/validation to pkg

* feat: move x net hashicorp to pkg

* fix: move missing files to pkg x net

* fix: tests

* feat: move templates to pkg

* feat: move x yaml to pkg

* feat: move merge to pkg

* feat: move x map to pkg

* feat: mode diffs package to external pkg

* fix: missing files

* feat: move rules extractors to pkg

* chore: move rules and reducers to pkg

* chore: rename reducers package name

* fix: linting

* chore: refactor reducers builder function

* fix: reducers null in array

* fix: wrong import
  • Loading branch information
Al-Pragliola authored Jul 18, 2024
1 parent 8b137d6 commit e209887
Show file tree
Hide file tree
Showing 89 changed files with 361 additions and 430 deletions.
12 changes: 6 additions & 6 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

const WrappedErrMessage = "%w: %s"
Expand Down Expand Up @@ -126,17 +126,17 @@ func NewApplyCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

// Init first half of collaborators.
client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, flags.BinPath, flags.FuryctlPath, flags.VpnAutoConnect)

if flags.DistroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
}

// Init packages.
Expand Down
2 changes: 1 addition & 1 deletion cmd/connect/openvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/sighupio/furyctl/internal/app"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
yamlx "github.com/sighupio/furyctl/internal/x/yaml"
yamlx "github.com/sighupio/furyctl/pkg/x/yaml"
)

type OpenVPNCmdFlags struct {
Expand Down
12 changes: 6 additions & 6 deletions cmd/create/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
"github.com/sighupio/furyctl/internal/semver"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

var (
Expand Down Expand Up @@ -115,17 +115,17 @@ func NewConfigCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

// Init collaborators.
client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, "", "", false)

if distroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
}

// Init packages.
Expand Down
12 changes: 6 additions & 6 deletions cmd/delete/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
iox "github.com/sighupio/furyctl/internal/x/io"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

const WrappedErrMessage = "%w: %s"
Expand Down Expand Up @@ -116,17 +116,17 @@ func NewClusterCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

// Init first half of collaborators.
client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, flags.BinPath, flags.FuryctlPath, flags.VpnAutoConnect)

if flags.DistroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
}

execx.NoTTY = flags.NoTTY
Expand Down
12 changes: 6 additions & 6 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/diffs"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
"github.com/sighupio/furyctl/internal/state"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
yamlx "github.com/sighupio/furyctl/internal/x/yaml"
"github.com/sighupio/furyctl/pkg/diffs"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
yamlx "github.com/sighupio/furyctl/pkg/x/yaml"
)

type DiffCommandFlags struct {
Expand Down Expand Up @@ -100,10 +100,10 @@ func NewDiffCmd() *cobra.Command {

client := netx.NewGoGetterClient()

distrodl := distribution.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
distrodl := dist.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)

if flags.DistroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
}

logrus.Info("Downloading distribution...")
Expand Down
12 changes: 6 additions & 6 deletions cmd/download/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (

"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

var (
Expand Down Expand Up @@ -91,16 +91,16 @@ func NewDependenciesCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, binPath, furyctlPath, false)

if distroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
}

// Validate base requirements.
Expand Down
15 changes: 8 additions & 7 deletions cmd/dump/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import (
"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
"github.com/sighupio/furyctl/internal/template"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
yamlx "github.com/sighupio/furyctl/internal/x/yaml"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
"github.com/sighupio/furyctl/pkg/template"
netx "github.com/sighupio/furyctl/pkg/x/net"
yamlx "github.com/sighupio/furyctl/pkg/x/yaml"
)

type TemplateCmdFlags struct {
Expand Down Expand Up @@ -108,16 +109,16 @@ The generated folder will be created starting from a provided templates folder a
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, "", absFuryctlPath, false)

if flags.DistroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, flags.GitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, flags.GitProtocol, absDistroPatchesLocation)
}

if err := depsvl.ValidateBaseReqs(); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions cmd/get/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

var (
Expand Down Expand Up @@ -96,16 +96,16 @@ func NewKubeconfigCmd() *cobra.Command {

executor := execx.NewStdExecutor()

distrodl := &distribution.Downloader{}
distrodl := &dist.Downloader{}
depsvl := dependencies.NewValidator(executor, binPath, furyctlPath, false)

// Init first half of collaborators.
client := netx.NewGoGetterClient()

if distroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, parsedGitProtocol, "")
distrodl = dist.NewCachingDownloader(client, outDir, parsedGitProtocol, "")
} else {
distrodl = distribution.NewDownloader(client, parsedGitProtocol, "")
distrodl = dist.NewDownloader(client, parsedGitProtocol, "")
}

// Validate base requirements.
Expand Down
12 changes: 6 additions & 6 deletions cmd/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/config"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

var (
Expand Down Expand Up @@ -84,16 +84,16 @@ func NewConfigCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, "", furyctlPath, false)

if distroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
}

// Validate base requirements.
Expand Down
12 changes: 6 additions & 6 deletions cmd/validate/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (

"github.com/sighupio/furyctl/internal/analytics"
"github.com/sighupio/furyctl/internal/app"
"github.com/sighupio/furyctl/internal/dependencies"
"github.com/sighupio/furyctl/internal/dependencies/envvars"
"github.com/sighupio/furyctl/internal/dependencies/tools"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/git"
cobrax "github.com/sighupio/furyctl/internal/x/cobra"
execx "github.com/sighupio/furyctl/internal/x/exec"
netx "github.com/sighupio/furyctl/internal/x/net"
"github.com/sighupio/furyctl/pkg/dependencies"
dist "github.com/sighupio/furyctl/pkg/distribution"
netx "github.com/sighupio/furyctl/pkg/x/net"
)

var ErrDependencies = errors.New("dependencies are not satisfied")
Expand Down Expand Up @@ -87,16 +87,16 @@ func NewDependenciesCmd() *cobra.Command {
}
}

var distrodl *distribution.Downloader
var distrodl *dist.Downloader

client := netx.NewGoGetterClient()
executor := execx.NewStdExecutor()
depsvl := dependencies.NewValidator(executor, "", furyctlPath, false)

if distroLocation == "" {
distrodl = distribution.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewCachingDownloader(client, outDir, typedGitProtocol, absDistroPatchesLocation)
} else {
distrodl = distribution.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
distrodl = dist.NewDownloader(client, typedGitProtocol, absDistroPatchesLocation)
}

// Validate base requirements.
Expand Down
4 changes: 2 additions & 2 deletions internal/apis/kfd/v1alpha2/common/create/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"github.com/sighupio/fury-distribution/pkg/apis/config"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/distribution"
"github.com/sighupio/furyctl/internal/template"
"github.com/sighupio/furyctl/internal/tool/helmfile"
"github.com/sighupio/furyctl/internal/tool/shell"
execx "github.com/sighupio/furyctl/internal/x/exec"
iox "github.com/sighupio/furyctl/internal/x/io"
yamlx "github.com/sighupio/furyctl/internal/x/yaml"
"github.com/sighupio/furyctl/pkg/template"
yamlx "github.com/sighupio/furyctl/pkg/x/yaml"
)

type Plugins struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/apis/kfd/v1alpha2/common/create/preupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (

"github.com/sighupio/fury-distribution/pkg/apis/config"
"github.com/sighupio/furyctl/configs"
"github.com/sighupio/furyctl/internal/apis/kfd/v1alpha2"
"github.com/sighupio/furyctl/internal/cluster"
"github.com/sighupio/furyctl/internal/semver"
"github.com/sighupio/furyctl/internal/template"
"github.com/sighupio/furyctl/internal/upgrade"
iox "github.com/sighupio/furyctl/internal/x/io"
yamlx "github.com/sighupio/furyctl/internal/x/yaml"
"github.com/sighupio/furyctl/pkg/reducers"
"github.com/sighupio/furyctl/pkg/template"
yamlx "github.com/sighupio/furyctl/pkg/x/yaml"
)

var (
Expand All @@ -42,7 +42,7 @@ type PreUpgrade struct {
kind string
upgrade *upgrade.Upgrade
upgradeFlag bool
reducers v1alpha2.Reducers
reducers reducers.Reducers
diffs diff.Changelog
forceFlag []string
paths cluster.CreatorPaths
Expand All @@ -59,7 +59,7 @@ func NewPreUpgrade(
upgradeFlag bool,
forceFlag []string,
upgr *upgrade.Upgrade,
reducers v1alpha2.Reducers,
reducers reducers.Reducers,
diffs diff.Changelog,
externalUpgradesPath string,
skipNodesUpgrade bool,
Expand Down
Loading

0 comments on commit e209887

Please sign in to comment.