-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support all three config modes #253
Conversation
I have concerns about the --app-config-url name. I would prefer --gitops-config-location or --gitops-automation-location @markramm thoughts? |
} | ||
|
||
var ignoreGitClient = gitfakes.FakeGit{ | ||
CloneStub: func(ctx context.Context, a, b, c string) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you explicitly want to see the print, there is no set all methods, it defaults to noop
@@ -171,17 +171,75 @@ func handleGitLsRemote(arglist ...interface{}) ([]byte, []byte, error) { | |||
return nil, nil, fmt.Errorf("NO!") | |||
} | |||
|
|||
var fakeGitClient = gitfakes.FakeGit{} | |||
var failGitClient = gitfakes.FakeGit{ | |||
CloneStub: func(ctx context.Context, a, b, c string) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a failure would probably be returning an error instead of exiting the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so that any use of the code anywhere downstream will fail the test w/o trying to propagate the failure to ensure dry run is working. Returning an error wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of invalid/non-existent repo addresses would probably accomplish the same, without requiring you to implement those, but I'm fine with it. It's up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense; I was just trying to be consistent across all the overrides and that was the simplest way. Not wedded to it :-)
@@ -216,7 +319,7 @@ var _ = Describe("Dry Run Add Test", func() { | |||
_ = override.WithOverrides( | |||
func() override.Result { | |||
deps := &AddDependencies{ | |||
GitClient: &fakeGitClient, | |||
GitClient: &failGitClient, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to exemplify the previous comment, this could be just GitClient: &gitfakes.FakeGit{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for dry run
|
||
_, err = fluxops.CallFlux(cmd) | ||
func getUrls(client git.Git, remote string) ([]string, error) { | ||
if _, ok := client.(*git.GoGit); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do this you won't be able to mock it in the test. It will ignore it every time.
With this, you should be able to mock that
GitClient: &gitfakes.FakeGit{
OpenStub: func(s string) (*gogit.Repository, error) {
r, err := gogit.Init(memory.NewStorage(), memfs.New())
Expect(err).ShouldNot(HaveOccurred())
_, err = r.CreateRemote(&config.RemoteConfig{
Name: "origin",
URLs: []string{"http://foo/foo.git"},
})
Expect(err).ShouldNot(HaveOccurred())
return r, nil
},
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a remote, everything panicked. I had no way to fake the remote at the time so I upleveled it. I'd be very happy to do something better later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
ccf5870
to
1c91135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Just a handful of nits you can choose to make or not.
@@ -38,8 +38,8 @@ func init() { | |||
Cmd.Flags().StringVar(¶ms.Branch, "branch", "main", "Branch to watch within git repository") | |||
Cmd.Flags().StringVar(¶ms.DeploymentType, "deployment-type", "kustomize", "deployment type [kustomize, helm]") | |||
Cmd.Flags().StringVar(¶ms.PrivateKey, "private-key", filepath.Join(os.Getenv("HOME"), ".ssh", "id_rsa"), "Private key that provides access to git repository") | |||
Cmd.Flags().StringVar(¶ms.AppConfigUrl, "app-config-url", "", "URL of external repository (if any) which will hold automation manifests; NONE to store only in the cluster") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - "URL of external repository" -> "URL of an external repository"
@@ -32,13 +31,12 @@ var _ = Describe("Weave GitOps Add Tests", func() { | |||
defaultSshKeyPath := os.Getenv("HOME") + "/.ssh/id_rsa" | |||
addCommand := "app add . " | |||
appRepoName := "wego-test-app-" + RandString(8) | |||
wegoRepoName := getClusterName() + "-wego" | |||
appName := wegoRepoName + "-" + appRepoName | |||
appName := appRepoName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIt: It string says command is wego add
and should bewego app add
if err != nil { | ||
return wrapError(err, "could not get flux repo name") | ||
return wrapError(err, fmt.Sprintf("could not create GitOps automation for '%s'", params.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error message is using a different value than what is passed to generateApplicationGoat
if err := writeAppYaml(gitClient, appYaml, ".wego"); err != nil { | ||
return err | ||
} | ||
if err := writeGoats(gitClient, ".wego", applicationGoat); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIt: Since writeAppYaml and writeGoats are performing similar operations, I'd prefer to have the arguments in the same order. i.e. base path then the manifests.
if err != nil { | ||
return wrapError(err, "could not generate wego source manifest") | ||
} | ||
func generateSource(repoName, repoUrl string, sourceType SourceType) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't using sourceType in the function. (I suspect it's because we have a different PR that will add the helm support)
72bedc6
to
5064b05
Compare
What changed?
Why?
This is the design favored by the CTO that she will demo at GitOps days
How did you test it?
Release notes
N/A
Documentation Changes
Yes, the getting started guide will need to be updated