mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Moved fleetctl to fleetctl package. (#28932)
For #28932 No functional changes. Left the parent directory (also named fleetctl) with the main package as is not to break/change any other flows. This PR is the first step before refactoring integration tests to speed up (parallelize) fleetctl tests.
This commit is contained in:
parent
48de857dca
commit
2db0959c15
204 changed files with 111 additions and 109 deletions
|
|
@ -88,13 +88,13 @@ issues:
|
|||
- path: cmd/fleet/serve.go
|
||||
linters:
|
||||
- gosec
|
||||
- path: cmd/fleetctl/api.go
|
||||
- path: cmd/fleetctl/fleetctl/api.go
|
||||
linters:
|
||||
- gosec
|
||||
- path: cmd/fleetctl/get.go
|
||||
- path: cmd/fleetctl/fleetctl/get.go
|
||||
linters:
|
||||
- gosec
|
||||
- path: cmd/fleetctl/preview.go
|
||||
- path: cmd/fleetctl/fleetctl/preview.go
|
||||
linters:
|
||||
- gosec
|
||||
# Orbit gosec exclusions https://github.com/fleetdm/fleet/issues/4452
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1215,7 +1215,7 @@ func TestApplyAsGitOps(t *testing.T) {
|
|||
// Mock Apple DEP API
|
||||
depStorage := SetupMockDEPStorageAndMockDEPServer(t)
|
||||
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
|
||||
_, ds := runServerWithMockedDS(t, &service.TestServerOpts{
|
||||
License: license,
|
||||
|
|
@ -1455,7 +1455,7 @@ spec:
|
|||
}, currentAppConfig.MDM)
|
||||
|
||||
// start a server to return the bootstrap package
|
||||
srv, _ := serveMDMBootstrapPackage(t, "../../server/service/testdata/bootstrap-packages/signed.pkg", "signed.pkg")
|
||||
srv, _ := serveMDMBootstrapPackage(t, "../../../server/service/testdata/bootstrap-packages/signed.pkg", "signed.pkg")
|
||||
|
||||
// Apply global config with bootstrap package
|
||||
bootstrapURL := srv.URL + "/signed.pkg"
|
||||
|
|
@ -2553,7 +2553,7 @@ spec:
|
|||
|
||||
for _, c := range cases {
|
||||
t.Run(c.pkgName, func(t *testing.T) {
|
||||
srv, pkgLen := serveMDMBootstrapPackage(t, filepath.Join("../../server/service/testdata/bootstrap-packages", c.pkgName), c.pkgName)
|
||||
srv, pkgLen := serveMDMBootstrapPackage(t, filepath.Join("../../../server/service/testdata/bootstrap-packages", c.pkgName), c.pkgName)
|
||||
ds := setupServer(t, true)
|
||||
ds.InsertMDMAppleBootstrapPackageFunc = func(ctx context.Context, bp *fleet.MDMAppleBootstrapPackage, pkgStore fleet.MDMBootstrapPackageStore) error {
|
||||
require.Equal(t, len(bp.Bytes), pkgLen)
|
||||
|
|
@ -2595,7 +2595,7 @@ spec:
|
|||
|
||||
t.Run("bootstrap package with manual agent install", func(t *testing.T) {
|
||||
pkgName := "signed.pkg"
|
||||
srv, pkgLen := serveMDMBootstrapPackage(t, filepath.Join("../../server/service/testdata/bootstrap-packages", pkgName), pkgName)
|
||||
srv, pkgLen := serveMDMBootstrapPackage(t, filepath.Join("../../../server/service/testdata/bootstrap-packages", pkgName), pkgName)
|
||||
ds := setupServer(t, true)
|
||||
ds.InsertMDMAppleBootstrapPackageFunc = func(ctx context.Context, bp *fleet.MDMAppleBootstrapPackage, pkgStore fleet.MDMBootstrapPackageStore) error {
|
||||
require.Equal(t, len(bp.Bytes), pkgLen)
|
||||
|
|
@ -2635,7 +2635,7 @@ spec:
|
|||
|
||||
t.Run("replace bootstrap package", func(t *testing.T) {
|
||||
pkgName := "signed.pkg"
|
||||
pkgBytes, err := os.ReadFile(filepath.Join("../../server/service/testdata/bootstrap-packages", pkgName))
|
||||
pkgBytes, err := os.ReadFile(filepath.Join("../../../server/service/testdata/bootstrap-packages", pkgName))
|
||||
require.NoError(t, err)
|
||||
pkgHash := sha256.New()
|
||||
n, err := io.Copy(pkgHash, bytes.NewReader(pkgBytes))
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import "github.com/urfave/cli/v2"
|
||||
|
||||
|
|
@ -1,15 +1,8 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
eefleetctl "github.com/fleetdm/fleet/v4/ee/fleetctl"
|
||||
"github.com/fleetdm/fleet/v4/server/version"
|
||||
|
|
@ -20,38 +13,7 @@ const (
|
|||
defaultFileMode = 0o600
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := createApp(os.Stdin, os.Stdout, os.Stderr, exitErrHandler)
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
fmt.Fprintf(os.Stdout, "Error: %+v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// exitErrHandler implements cli.ExitErrHandlerFunc. If there is an error, prints it to stderr and exits with status 1.
|
||||
func exitErrHandler(c *cli.Context, err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintf(c.App.ErrWriter, "Error: %+v\n", err)
|
||||
|
||||
if errors.Is(err, fs.ErrPermission) {
|
||||
switch runtime.GOOS {
|
||||
case "darwin", "linux":
|
||||
fmt.Fprintf(c.App.ErrWriter, "\nThis error can usually be resolved by fixing the permissions on the %s directory, or re-running this command with sudo.\n", path.Dir(c.String("config")))
|
||||
case "windows":
|
||||
fmt.Fprintf(c.App.ErrWriter, "\nThis error can usually be resolved by fixing the permissions on the %s directory, or re-running this command with 'Run as administrator'.\n", path.Dir(c.String("config")))
|
||||
}
|
||||
}
|
||||
cli.OsExiter(1)
|
||||
}
|
||||
|
||||
func createApp(
|
||||
func CreateApp(
|
||||
reader io.Reader,
|
||||
stdout io.Writer,
|
||||
stderr io.Writer,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// filepath: cmd/fleetctl/generate_gitops_test.go
|
||||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -64,7 +64,7 @@ func (s *enterpriseIntegrationGitopsTestSuite) SetupSuite() {
|
|||
testKeyPEM := tokenpki.PEMRSAPrivateKey(testKey)
|
||||
|
||||
fleetCfg := config.TestConfig()
|
||||
config.SetTestMDMConfig(s.T(), &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(s.T(), &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
fleetCfg.Osquery.EnrollCooldown = 0
|
||||
|
||||
err = s.ds.InsertMDMConfigAssets(context.Background(), []fleet.MDMConfigAsset{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -49,7 +49,7 @@ func (s *integrationGitopsTestSuite) SetupSuite() {
|
|||
testKeyPEM := tokenpki.PEMRSAPrivateKey(testKey)
|
||||
|
||||
fleetCfg := config.TestConfig()
|
||||
config.SetTestMDMConfig(s.T(), &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(s.T(), &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
fleetCfg.Osquery.EnrollCooldown = 0
|
||||
|
||||
mdmStorage, err := s.ds.NewMDMAppleMDMStorage()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -686,7 +686,7 @@ func TestGitOpsFullGlobal(t *testing.T) {
|
|||
testCertPEM := tokenpki.PEMCertificate(testCert.Raw)
|
||||
testKeyPEM := tokenpki.PEMRSAPrivateKey(testKey)
|
||||
fleetCfg := config.TestConfig()
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
|
||||
// License is not needed because we are not using any premium features in our config.
|
||||
_, ds := runServerWithMockedDS(
|
||||
|
|
@ -959,7 +959,7 @@ func TestGitOpsFullTeam(t *testing.T) {
|
|||
testCertPEM := tokenpki.PEMCertificate(testCert.Raw)
|
||||
testKeyPEM := tokenpki.PEMRSAPrivateKey(testKey)
|
||||
fleetCfg := config.TestConfig()
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
|
||||
// License is not needed because we are not using any premium features in our config.
|
||||
_, ds := runServerWithMockedDS(
|
||||
|
|
@ -2947,7 +2947,7 @@ func TestGitOpsCustomSettings(t *testing.T) {
|
|||
|
||||
func startSoftwareInstallerServer(t *testing.T) {
|
||||
// start the web server that will serve the installer
|
||||
b, err := os.ReadFile(filepath.Join("..", "..", "server", "service", "testdata", "software-installers", "ruby.deb"))
|
||||
b, err := os.ReadFile(filepath.Join("..", "..", "..", "server", "service", "testdata", "software-installers", "ruby.deb"))
|
||||
require.NoError(t, err)
|
||||
|
||||
srv := httptest.NewServer(
|
||||
|
|
@ -3164,7 +3164,7 @@ func setupFullGitOpsPremiumServer(t *testing.T) (*mock.Store, **fleet.AppConfig,
|
|||
testCertPEM := tokenpki.PEMCertificate(testCert.Raw)
|
||||
testKeyPEM := tokenpki.PEMRSAPrivateKey(testKey)
|
||||
fleetCfg := config.TestConfig()
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../server/service/testdata")
|
||||
config.SetTestMDMConfig(t, &fleetCfg, testCertPEM, testKeyPEM, "../../../server/service/testdata")
|
||||
|
||||
license := &fleet.LicenseInfo{Tier: fleet.TierPremium, Expiration: time.Now().Add(24 * time.Hour)}
|
||||
_, ds := runServerWithMockedDS(
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package main
|
||||
package fleetctl
|
||||
|
||||
import "syscall"
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package fleetctl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue