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

Standardize dependency checking for kne deploy #150

Merged
merged 3 commits into from May 20, 2022
Merged

Standardize dependency checking for kne deploy #150

merged 3 commits into from May 20, 2022

Conversation

alexmasi
Copy link
Collaborator

Before the dependency checking was not uniform, some methods checked for required binaries and others didn't.

Now "docker" and "kubectl" are considered dependencies to make any deployment

"kind" is a dependency to make deployments with kind cluster

"gcloud" is only a dependency when using kind linked with GAR

Other changes:

  • removed kind provider deployment without kind cli (now that "kind" cli is a hard requirement, also some of the optional fields like gar support, container loading, deletion etc. were only compatible with cli deployment)
  • recycle is now checked using kubectl instead of the kind provider
  • clean up code in tests
  • go fmt all of kne

@coveralls
Copy link

coveralls commented May 13, 2022

Pull Request Test Coverage Report for Build 2360529480

  • 38 of 49 (77.55%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 54.078%

Changes Missing Coverage Covered Lines Changed/Added Lines %
deploy/deploy.go 20 31 64.52%
Totals Coverage Status
Change from base Build 2303430309: -0.02%
Covered Lines: 1883
Relevant Lines: 3482

💛 - Coveralls

marcushines
marcushines previously approved these changes May 19, 2022
deploy/deploy.go Outdated
func checkDependencies() error {
bins := []string{"docker", "kubectl"}
var errs errlist.List
for _, bin := range bins {
Copy link
Contributor

Choose a reason for hiding this comment

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

for _, bin := []string{"docker", "kubectl"}

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, will push a commit soon

deploy/deploy.go Outdated
return nil
}
}
if _, err := execLookPath("kind"); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should codify for each spec a "depends" on func like you did above but attach it to the struct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah I agree, we can have a depends for the spec, additionally options such as googleArtifactRegistry access requires an additional dep (gcloud) which we could check in the depends func based on the optional fields provided

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 errors.Wrap(err, "failed to create cluster using kind client")
if k.Recycle {
log.Infof("Attempting to recycle existing cluster %q...", k.Name)
if err := execer.Exec("kubectl", "cluster-info", "--context", fmt.Sprintf("kind-%s", k.Name)); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

should you have a dep check on kubectl? - like is there a guarantee that this order is always maintained?

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 see two ways of doing it:

  1. having each "Spec" list out the dependencies and call checkDependencies for each one before any method

  2. having docker and kubectl be dependencies of any deployment and have the spec dependencies only include the remainder of the dependencies (this is the standard that this PR implements)

I can see potentially a 3rd design that steals from (1) and (2) where docker and kubectl are checked for a deployment regardless of the specs and spec dependencies are checked before ever method call, not just deploy.

I think the 3rd option is the best considering these specs should not be called outside of Deployment.Deploy() and are only exported due to yaml marshaling

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 merged commit f30a4f2 into main May 20, 2022
@alexmasi alexmasi deleted the check branch May 24, 2022 21:14
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

3 participants