diff --git a/internal/feature/feature.go b/internal/feature/feature.go index ebf257c128da6a9d6e6a14ef4b7faa9431dfef92..d5c340ff45452a1db2c77cf58262b1b7c18e3160 100644 --- a/internal/feature/feature.go +++ b/internal/feature/feature.go @@ -19,13 +19,6 @@ var HandleReadErrors = Feature{ EnvVariable: "FF_HANDLE_READ_ERRORS", } -// ConfigurableRoot enables a project's root directory to be customized using -// the GitLab API -var ConfigurableRoot = Feature{ - EnvVariable: "FF_CONFIGURABLE_ROOT_DIR", - defaultEnabled: true, -} - // Enabled reads the environment variable responsible for the feature flag // if FF is disabled by default, the environment variable needs to be "true" to explicitly enable it // if FF is enabled by default, variable needs to be "false" to explicitly disable it diff --git a/internal/serving/disk/projectroot/root.go b/internal/serving/disk/projectroot/root.go index 64f830c0c28495768558c262a6a013a53344ad98..2c924fa1d9c0ab38f044bd41ed15a35d15e91d08 100644 --- a/internal/serving/disk/projectroot/root.go +++ b/internal/serving/disk/projectroot/root.go @@ -5,7 +5,6 @@ import ( "os" "path/filepath" - "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/vfs" ) @@ -18,7 +17,7 @@ type projectRoot struct { } func New(rootDirectory string, vfsRoot vfs.Root) vfs.Root { - if !feature.ConfigurableRoot.Enabled() || rootDirectory == "" { + if rootDirectory == "" { // In case the GitLab API is not up-to-date this string may be empty. // In that case default to the legacy behavior rootDirectory = "public" diff --git a/internal/serving/disk/projectroot/root_test.go b/internal/serving/disk/projectroot/root_test.go index b8549d1029d3e7e174447aa0646c432ef7d1bc59..9a13c89e8428f7d7572c5d17191368cf66d0fdec 100644 --- a/internal/serving/disk/projectroot/root_test.go +++ b/internal/serving/disk/projectroot/root_test.go @@ -3,12 +3,10 @@ package projectroot import ( "context" "os" - "strconv" "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/vfs" ) @@ -38,41 +36,24 @@ func (m *mockRoot) Open(ctx context.Context, name string) (vfs.File, error) { func TestProjectRoot(t *testing.T) { tests := map[string]struct { - path string - rootDir string - expectedPath string - featureEnabled bool + path string + rootDir string + expectedPath string }{ "when the root dir is provided": { - path: "some/path", - rootDir: "my_root_dir", - expectedPath: "my_root_dir/some/path", - featureEnabled: true, + path: "some/path", + rootDir: "my_root_dir", + expectedPath: "my_root_dir/some/path", }, "when the root dir is not provided": { - path: "some/path", - rootDir: "", - expectedPath: "public/some/path", - featureEnabled: true, - }, - "when the feature is disabled": { - path: "some/path", - rootDir: "my_root_dir", - expectedPath: "public/some/path", - featureEnabled: false, - }, - "when the feature is disabled and no root path is provided": { - path: "some/path", - rootDir: "", - expectedPath: "public/some/path", - featureEnabled: false, + path: "some/path", + rootDir: "", + expectedPath: "public/some/path", }, } for name, test := range tests { t.Run(name, func(t *testing.T) { - t.Setenv(feature.ConfigurableRoot.EnvVariable, - strconv.FormatBool(test.featureEnabled)) originalRoot := &mockRoot{} wrappedRoot := New(test.rootDir, originalRoot) diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go index 7a1af61b04d5991f1da5ed4c609a284a4c9583f1..a483a8fee1d87b6d9f72f1fc3ff5757e4a525b51 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -294,8 +294,7 @@ func (reader *Reader) root(h serving.Handler) (vfs.Root, bool) { if err == nil { // The project root directory changes based on the response obtained - // from the API. It currently depends on feature.ConfigurableRoot - // being enabled. + // from the API. root := projectroot.New(h.LookupPath.RootDirectory, vfsRoot) return root, false } diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go index 373e981869988c2fbe872940f5c3f8fdad3397a4..fb13d10045adfbc30360410dbf3d74ffd986f052 100644 --- a/internal/vfs/zip/archive.go +++ b/internal/vfs/zip/archive.go @@ -9,14 +9,12 @@ import ( "os" "path" "strconv" - "strings" "sync" "sync/atomic" "time" "gitlab.com/gitlab-org/labkit/log" - "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/httprange" "gitlab.com/gitlab-org/gitlab-pages/internal/vfs" "gitlab.com/gitlab-org/gitlab-pages/metrics" @@ -145,10 +143,6 @@ func (a *zipArchive) readArchive(url string) { // TODO: Improve preprocessing of zip archives https://gitlab.com/gitlab-org/gitlab-pages/-/issues/432 for _, file := range archive.File { - if !feature.ConfigurableRoot.Enabled() && !strings.HasPrefix(file.Name, dirPrefix) { - continue - } - // Each Modified timestamp contains a pointer to a unique timezone // object. This wastes a lot of memory. By setting the timezone to UTC on // each timestamp, we allow the unique timezone objects to be diff --git a/test/acceptance/custom_root_folder_test.go b/test/acceptance/custom_root_folder_test.go index 24ebe2d1a9689d1da18d1de2ad0c350b4e8361e5..eee947097b2e4d0042f34646771d42330aa02e91 100644 --- a/test/acceptance/custom_root_folder_test.go +++ b/test/acceptance/custom_root_folder_test.go @@ -6,13 +6,10 @@ import ( "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-pages/internal/feature" "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) func TestCustomRoot(t *testing.T) { - t.Setenv(feature.ConfigurableRoot.EnvVariable, "true") - RunPagesProcess(t) tests := []struct {