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

Update cloudbuild configuration making use of added deploy support for pulling images from GAR #65

Merged
merged 23 commits into from
Oct 15, 2021

Conversation

alexmasi
Copy link
Collaborator

Changes:

  • update cloudbuild to pull desired version of gh repo
  • use ubuntu instead of debian
  • fork manifests and deployment yaml for internal and external versions (changes where images are pulled from)
  • add private google artifact registry support for created kind clusters
  • reworked execer to expose stdout/err destinations, added more robust fake
  • unit tests

TODO in future change:

  • add option to use a different init container to support internal use (add option in topo proto?)

@coveralls
Copy link

coveralls commented Oct 12, 2021

Pull Request Test Coverage Report for Build 1343992846

  • 58 of 66 (87.88%) changed or added relevant lines in 1 file are covered.
  • 38 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+1.4%) to 57.595%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/deploy/specs.go 58 66 87.88%
Files with Coverage Reduction New Missed Lines %
topo/node/node.go 38 7.62%
Totals Coverage Status
Change from base Build 1338865613: 1.4%
Covered Lines: 982
Relevant Lines: 1705

💛 - Coveralls

c := exec.Command(cmd, args...)
c.Stdout = e.stdout
c.Stderr = e.stderr
log.Info(c.String())
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 really want to log here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the current behavior, but I agree it is unnecessary and I have removed it.

@@ -59,7 +75,8 @@ type KindSpec struct {
Wait time.Duration `yaml:"wait"`
Kubecfg string `yaml:"kubecfg"`
DeployWithClient bool `yaml:"deployWithClient"`
execer func(string, ...string) error
GoogleArtifactRegistries []string `yaml:"googleArtifactRegistries"`
execer execerInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

why attach this here?
i would prefer to keep the config "pure"

if we want to have an "execer" then we should wrap the spec with another struct wiith that attached

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would argue this is no less "pure" than before, adding the extra layer is an option that I can implement. If there is no reason for an execer to belong to each spec (and if each spec may need access to it) then what about a global variable:

var (
execer execerInterface = exec.NewExecer()
)

Specs in the file can directly call execer.Exec() and tests can stub execer to equal exec.NewFakeExecer()

That would work in my head but not sure which is better, any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

it is fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,64 @@
package deploy
Copy link
Contributor

Choose a reason for hiding this comment

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

this feels like there should be an implementation here in a seperate package

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this code into its own package (exec) that can be used here or elsewhere, there is nothing inherent to deployment. Where do you think the best place for this file is? Maybe a new top level directory for utilities?

Not sure what you mean by implementation. My idea was to have this library provide the implementation of an execer/fake only, and the user of the library to define an interface (like in specs.go). This is following the internal google style guide, are you suggesting something different?

Copy link
Contributor

Choose a reason for hiding this comment

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

i was saying the have a package just for exec
and then do exactly what you are saying - users would just use an interface to make it testable

I don't like "collection" directories

kne/os/execer seems fine path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

return nil
}

func writeDockerConfig(path string, registries []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

would a template be nicer to use here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,72 @@
apiVersion: apiextensions.k8s.io/v1
Copy link
Contributor

Choose a reason for hiding this comment

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

err wrong path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -0,0 +1,61 @@
package exec
Copy link
Contributor

Choose a reason for hiding this comment

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

go build will not like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

return err
}
defer os.RemoveAll(tempDockerDir)
originalConfig := os.Getenv(dockerConfigEnvVar)
Copy link
Contributor

Choose a reason for hiding this comment

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

i would maybe suggest a docstring here on why and what you are doing here - it probably isn't super obvious why this is necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@alexmasi alexmasi mentioned this pull request Oct 13, 2021
@shubh90 shubh90 merged commit 1484d9b into main Oct 15, 2021
@alexmasi alexmasi deleted the cloudbuild branch October 15, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants