Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Handle gittracks flag #171

Merged
merged 10 commits into from
Sep 17, 2019
Merged

Conversation

DanielMorsing
Copy link
Contributor

Final piece: Add a flag for disallowing (regular) GitTracks

Copy link
Contributor

@mthssdrbrg mthssdrbrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The consistency pleases me, even though it might look odd 😅

pkg/controller/gittrack/gittrack_controller_test.go Outdated Show resolved Hide resolved
// don't reconcile if it's a gittrack and they're disabled
// we shouldn't ever get here because reconcile should be turned off at the controller level,
// but for testing and safeguarding, check anyway
if _, ok := gt.(*farosv1alpha1.ClusterGitTrack); ok && r.gitTrackMode == farosflags.GTMDisabled {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should perform this evaluation, given it is going to happen for every reconcile and we don't have it's counterpart for ClusterGitTracks, we should just test and rely on the controller level off switches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the grand scheme of things, this evaluation doesn't cost anything and it only makes the code more robust.

The controller level watches are being turned off, so it's not a case of checking on every reconcile. Since reconcile being called on a type with the mode disabled is a logic error, I'm going to change this into being a panic

@@ -57,6 +60,7 @@ func init() {
FlagSet.BoolVar(&ServerDryRun, "server-dry-run", true, "Enable/Disable server side dry run before updating resources")
FlagSet.DurationVar(&FetchTimeout, "fetch-timeout", 30*time.Second, "Timeout in seconds for fetching changes from repositories")
FlagSet.StringVar(&RepositoryDir, "repository-dir", "", "Directory in which to clone repositories. Defaults to cloning in memory if unset.")
FlagSet.Var(&GitTrack, "gittrack-mode", "Whether to manage GitTracks. Valid values are Disabled and Enabled")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to set defaults? We should have a default for cluster-gittrack-mode too preferably

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is already set by virtue of the zero-value being false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to be more explicit? That's quite "magic" and kinda not obvious IMO. What's the default value for the other flag, clustergittrack-mode?

We didn't catch this, because we set this value explicitly in the tests
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DanielMorsing
Copy link
Contributor Author

/retest

@DanielMorsing DanielMorsing merged commit 93d35c1 into disallow-gt-to-cgto Sep 17, 2019
Fix Ownership bug automation moved this from In progress to Done Sep 17, 2019
@pusher-ci pusher-ci deleted the handleGittracks-flag branch September 17, 2019 10:56
@DanielMorsing DanielMorsing restored the handleGittracks-flag branch September 17, 2019 11:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants