Skip to content
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

Add namespace to wego-app manifests #1041

Merged
merged 11 commits into from Nov 11, 2021
Merged

Conversation

luizbafilho
Copy link
Contributor

@luizbafilho luizbafilho commented Nov 5, 2021

Closes: #988 #963

What changed?

  • Adding the namespace to the wego-app manifests we deploy since that's a requirement from flux 0.18.0
  • Fixes deployment template image

Why?

How did you test it?

Release notes

Documentation Changes

@luizbafilho luizbafilho changed the title Adding namespace to templates Add namespace to templates Nov 5, 2021
@luizbafilho luizbafilho self-assigned this Nov 5, 2021
@luizbafilho luizbafilho added the bug Something isn't working label Nov 5, 2021
@luizbafilho luizbafilho changed the title Add namespace to templates Add namespace to wego-app manifests Nov 5, 2021
@luizbafilho luizbafilho marked this pull request as ready for review November 5, 2021 16:33
Copy link
Contributor

@jrryjcksn jrryjcksn left a comment

Choose a reason for hiding this comment

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

A few nits; otherwise, LGTM


//go:embed wego-app/deployment.yaml
var WegoAppDeployment []byte
// GenerateWegoManifests generates wego-app manifest from a template
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: manifest => manifests

//go:embed crds/wego.weave.works_apps.yaml
AppCRD []byte
//go:embed wego-app/*
wegoAppTemplates embed.FS
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Cleans things up a lot 👍

Expect(Deployment.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring(v))
for _, m := range manifests {
if strings.Contains(string(m), "kind: Deployment") {
Expect(string(manifests[0])).To(ContainSubstring("namespace: my-namespace"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This line and the next: manifests[0] => m

@@ -39,7 +39,7 @@ var _ = Describe("Sync", func() {
Expect(err.Error()).To(HavePrefix("failed getting application"))
})

It("sets proper annotation tag to the resource", func() {
XIt("sets proper annotation tag to the resource", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a temporary fix until the sync test is working?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

return nil, fmt.Errorf("could not apply wego-app deployment manifest: %w", err)
for _, m := range wegoAppManifests {
if err := g.kube.Apply(ctx, m, params.Namespace); err != nil {
return nil, fmt.Errorf("error applying wego-app manifest %s: %w", string(m), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "string" not needed here

Expect(err).ShouldNot(HaveOccurred())
})

installAndVerifyWego(namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need a URL with the new directory structure changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean?


//go:embed wego-app/role-binding.yaml
var WegoAppRoleBinding []byte

func init() {
Manifests = [][]byte{
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we think this will ever have more than one manifest in it any more? If not, maybe this should just be an "AppCRDManifest" variable 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I'll remove it

@@ -74,15 +74,17 @@ func (g *Gitops) Install(params InstallParams) (map[string][]byte, error) {
version = "latest"
}

wegoAppDeploymentManifest, err := manifests.GenerateWegoAppDeploymentManifest(version)
wegoAppManifests, err := manifests.GenerateWegoAppManifests(manifests.WegoAppParams{Version: version, Namespace: params.Namespace})
if err != nil {
return nil, fmt.Errorf("error generating wego-app deployment, %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we update this error message to match the new behavior?

type deploymentParameters struct {
Version string
}
templates, _ := fs.ReadDir(wegoAppTemplates, wegoManifestsDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we handle error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's very unlikely this will ever return any error because it's reading directly from memory, but it doesn't hurt adding the err check

)

var Manifests [][]byte
var (
Manifests [][]byte
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we can remove this array now? It is being filled out in init but only with the AppCRD which is already public, so then we can access AppCRD directly instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

Copy link
Contributor

@josecordaz josecordaz left a comment

Choose a reason for hiding this comment

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

Nice work

@luizbafilho luizbafilho merged commit fb943d8 into main Nov 11, 2021
@luizbafilho luizbafilho deleted the 988-fix-wego-app-namespace branch November 11, 2021 12:35
@luizbafilho luizbafilho restored the 988-fix-wego-app-namespace branch December 8, 2021 17:36
@ozamosi ozamosi deleted the 988-fix-wego-app-namespace branch May 12, 2022 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We need to set the wego-app deployment namespace
3 participants