Drop the 'FF' prefix from feature flag constants

The constants are now defined inside of the 'featureflags' package,
so there is no need for the 'FF' prefix. The fact that it's a feature
flag is quite obvious when looking on an entry like:

    IsFeatureFlagOn(featureflags.UseLegacyBuildsDirForDocker)
parent c91c6b17
Pipeline #57529744 passed with stages
in 56 minutes and 20 seconds
......@@ -271,7 +271,7 @@ func (e *executor) getPrebuiltImage() (*types.ImageInspect, error) {
imageNameFromConfig = common.AppVersion.Variables().ExpandValue(imageNameFromConfig)
e.Debugln("Pull configured helper_image for predefined container instead of import bundled image", imageNameFromConfig, "...")
if !e.Build.IsFeatureFlagOn(featureflags.FFDockerHelperImageV2) {
if !e.Build.IsFeatureFlagOn(featureflags.DockerHelperImageV2) {
e.Warningln("DEPRECATION: With gitlab-runner 12.0 we will change some tools inside the helper image, please make sure your image is compliant with the new API. https://gitlab.com/gitlab-org/gitlab-runner/issues/4013")
}
......@@ -390,7 +390,7 @@ func (e *executor) createCacheVolume(containerName, containerPath string) (strin
cmd := []string{"gitlab-runner-helper", "cache-init", containerPath}
// TODO: Remove in 12.0 to start using the command from `gitlab-runner-helper`
if e.checkOutdatedHelperImage() {
e.Debugln(featureflags.FFDockerHelperImageV2, "is not set, falling back to old command")
e.Debugln(featureflags.DockerHelperImageV2, "is not set, falling back to old command")
cmd = []string{"gitlab-runner-cache", containerPath}
}
......@@ -509,7 +509,7 @@ func fakeContainer(id string, names ...string) *types.Container {
func (e *executor) createBuildVolume() error {
parentDir := e.Build.RootDir
if e.Build.IsFeatureFlagOn(featureflags.FFUseLegacyBuildsDirForDocker) {
if e.Build.IsFeatureFlagOn(featureflags.UseLegacyBuildsDirForDocker) {
// Cache Git sources:
// take path of the projects directory,
// because we use `rm -rf` which could remove the mounted volume
......@@ -1312,7 +1312,7 @@ func (e *executor) runServiceHealthCheckContainer(service *types.Container, time
cmd := []string{"gitlab-runner-helper", "health-check"}
// TODO: Remove in 12.0 to start using the command from `gitlab-runner-helper`
if e.checkOutdatedHelperImage() {
e.Debugln(featureflags.FFDockerHelperImageV2, "is not set, falling back to old command")
e.Debugln(featureflags.DockerHelperImageV2, "is not set, falling back to old command")
cmd = []string{"gitlab-runner-service"}
}
......@@ -1418,5 +1418,5 @@ func (e *executor) readContainerLogs(containerID string) string {
}
func (e *executor) checkOutdatedHelperImage() bool {
return !e.Build.IsFeatureFlagOn(featureflags.FFDockerHelperImageV2) && e.Config.Docker.HelperImage != ""
return !e.Build.IsFeatureFlagOn(featureflags.DockerHelperImageV2) && e.Config.Docker.HelperImage != ""
}
......@@ -1183,7 +1183,7 @@ func TestCreateCacheVolumeFeatureFlag(t *testing.T) {
{
name: "Helper image is not specified and FF still turned on",
variables: common.JobVariables{
common.JobVariable{Key: featureflags.FFDockerHelperImageV2, Value: "true"},
common.JobVariable{Key: featureflags.DockerHelperImageV2, Value: "true"},
},
helperImage: "",
expectedCmd: []string{"gitlab-runner-helper", "cache-init", cacheDir},
......@@ -1197,7 +1197,7 @@ func TestCreateCacheVolumeFeatureFlag(t *testing.T) {
{
name: "Helper image is specified & FF variable is set to true",
variables: common.JobVariables{
common.JobVariable{Key: featureflags.FFDockerHelperImageV2, Value: "true"},
common.JobVariable{Key: featureflags.DockerHelperImageV2, Value: "true"},
},
helperImage: "gitlab/gitlab-runner-helper:x86_64-latest",
expectedCmd: []string{"gitlab-runner-helper", "cache-init", cacheDir},
......@@ -1264,7 +1264,7 @@ func TestRunServiceHealthCheckContainerFeatureFlag(t *testing.T) {
{
name: "Helper image is not specified and FF still turned on",
variables: common.JobVariables{
common.JobVariable{Key: featureflags.FFDockerHelperImageV2, Value: "true"},
common.JobVariable{Key: featureflags.DockerHelperImageV2, Value: "true"},
},
helperImage: "",
expectedCmd: []string{"gitlab-runner-helper", "health-check"},
......@@ -1278,7 +1278,7 @@ func TestRunServiceHealthCheckContainerFeatureFlag(t *testing.T) {
{
name: "Helper image is specified & FF variable is set to true",
variables: common.JobVariables{
common.JobVariable{Key: featureflags.FFDockerHelperImageV2, Value: "true"},
common.JobVariable{Key: featureflags.DockerHelperImageV2, Value: "true"},
},
helperImage: "gitlab/gitlab-runner-helper:x86_64-latest",
expectedCmd: []string{"gitlab-runner-helper", "health-check"},
......
......@@ -220,7 +220,7 @@ func (s *executor) buildContainer(name, image string, imageDefinition common.Ima
}
func (s *executor) getCommandAndArgs(imageDefinition common.Image, command ...string) ([]string, []string) {
if s.Build.IsFeatureFlagOn(featureflags.FFK8sEntrypointOverCommand) {
if s.Build.IsFeatureFlagOn(featureflags.K8sEntrypointOverCommand) {
return s.getCommandsAndArgsV2(imageDefinition, command...)
}
......
......@@ -1328,7 +1328,7 @@ func TestSetupBuildPod(t *testing.T) {
},
},
Variables: []common.JobVariable{
{Key: featureflags.FFK8sEntrypointOverCommand, Value: "true"},
{Key: featureflags.K8sEntrypointOverCommand, Value: "true"},
},
Options: &kubernetesOptions{
Image: common.Image{
......@@ -1390,7 +1390,7 @@ func TestSetupBuildPod(t *testing.T) {
},
},
Variables: []common.JobVariable{
{Key: featureflags.FFK8sEntrypointOverCommand, Value: "false"},
{Key: featureflags.K8sEntrypointOverCommand, Value: "false"},
},
Options: &kubernetesOptions{
Image: common.Image{
......
......@@ -5,11 +5,11 @@ import (
)
const (
FFK8sEntrypointOverCommand string = "FF_K8S_USE_ENTRYPOINT_OVER_COMMAND"
FFDockerHelperImageV2 string = "FF_DOCKER_HELPER_IMAGE_V2"
FFCmdDisableDelayedErrorLevelExpansion string = "FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION"
FFUseLegacyGitCleanStrategy string = "FF_USE_LEGACY_GIT_CLEAN_STRATEGY"
FFUseLegacyBuildsDirForDocker string = "FF_USE_LEGACY_BUILDS_DIR_FOR_DOCKER"
K8sEntrypointOverCommand string = "FF_K8S_USE_ENTRYPOINT_OVER_COMMAND"
DockerHelperImageV2 string = "FF_DOCKER_HELPER_IMAGE_V2"
CmdDisableDelayedErrorLevelExpansion string = "FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION"
UseLegacyGitCleanStrategy string = "FF_USE_LEGACY_GIT_CLEAN_STRATEGY"
UseLegacyBuildsDirForDocker string = "FF_USE_LEGACY_BUILDS_DIR_FOR_DOCKER"
)
type FeatureFlag struct {
......@@ -27,35 +27,35 @@ type FeatureFlag struct {
// basing on the values below
var flags = []FeatureFlag{
{
Name: FFK8sEntrypointOverCommand,
Name: K8sEntrypointOverCommand,
DefaultValue: "true",
Deprecated: true,
ToBeRemovedWith: "12.0",
Description: "Enables [the fix](https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/1010) for entrypoint configuration when `kubernetes` executor is used",
},
{
Name: FFDockerHelperImageV2,
Name: DockerHelperImageV2,
DefaultValue: "false",
Deprecated: true,
ToBeRemovedWith: "12.0",
Description: "Enable the helper image to use the new commands when [helper_image](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section) is specified. This will start using the new API that will be used in 12.0 and stop showing the warning message in the build log",
},
{
Name: FFCmdDisableDelayedErrorLevelExpansion,
Name: CmdDisableDelayedErrorLevelExpansion,
DefaultValue: "false",
Deprecated: false,
ToBeRemovedWith: "",
Description: "Disables [EnableDelayedExpansion](https://ss64.com/nt/delayedexpansion.html) for error checking for when using [Window Batch](https://docs.gitlab.com/runner/shells/#windows-batch) shell",
},
{
Name: FFUseLegacyGitCleanStrategy,
Name: UseLegacyGitCleanStrategy,
DefaultValue: "false",
Deprecated: true,
ToBeRemovedWith: "12.0",
Description: "Enables the new strategy for `git clean` that moves the clean operation after checkout and enables support for `GIT_CLEAN_FLAGS`",
},
{
Name: FFUseLegacyBuildsDirForDocker,
Name: UseLegacyBuildsDirForDocker,
DefaultValue: "false",
Deprecated: true,
ToBeRemovedWith: "13.0",
......
......@@ -97,7 +97,7 @@ func (b *AbstractShell) writeGitCleanup(w ShellWriter, build *common.Build) {
w.RmFile(".git/hooks/post-checkout")
// TODO: Remove in 12.0
if build.IsFeatureFlagOn(featureflags.FFUseLegacyGitCleanStrategy) {
if build.IsFeatureFlagOn(featureflags.UseLegacyGitCleanStrategy) {
w.Command("git", "clean", "-ffdx")
w.IfCmd("git", "diff", "--no-ext-diff", "--quiet", "--exit-code")
// git 1.7 cannot reset before a checkout, if no diffs we can avoid git reset
......@@ -187,7 +187,7 @@ func (b *AbstractShell) writeCheckoutCmd(w ShellWriter, build *common.Build) {
w.Notice("Checking out %s as %s...", build.GitInfo.Sha[0:8], build.GitInfo.Ref)
w.Command("git", "checkout", "-f", "-q", build.GitInfo.Sha)
if !build.IsFeatureFlagOn(featureflags.FFUseLegacyGitCleanStrategy) {
if !build.IsFeatureFlagOn(featureflags.UseLegacyGitCleanStrategy) {
cleanFlags := build.GetGitCleanFlags()
if len(cleanFlags) > 0 {
cleanArgs := append([]string{"clean"}, cleanFlags...)
......
......@@ -246,7 +246,7 @@ func TestGitCleanFlags(t *testing.T) {
GitInfo: common.GitInfo{Sha: dummySha, Ref: dummyRef},
Variables: common.JobVariables{
{Key: "GIT_CLEAN_FLAGS", Value: test.value},
{Key: featureflags.FFUseLegacyGitCleanStrategy, Value: test.legacyCleanStrategy},
{Key: featureflags.UseLegacyGitCleanStrategy, Value: test.legacyCleanStrategy},
},
},
}
......
......@@ -257,7 +257,7 @@ func (b *CmdShell) GetConfiguration(info common.ShellScriptInfo) (script *common
func (b *CmdShell) GenerateScript(buildStage common.BuildStage, info common.ShellScriptInfo) (script string, err error) {
w := &CmdWriter{
TemporaryPath: info.Build.TmpProjectDir(),
disableDelayedErrorLevelExpansion: info.Build.IsFeatureFlagOn(featureflags.FFCmdDisableDelayedErrorLevelExpansion),
disableDelayedErrorLevelExpansion: info.Build.IsFeatureFlagOn(featureflags.CmdDisableDelayedErrorLevelExpansion),
}
if buildStage == common.BuildStagePrepare {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment