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

refactor build tooling #114

Merged
merged 7 commits into from
Jul 31, 2019
Merged

refactor build tooling #114

merged 7 commits into from
Jul 31, 2019

Conversation

montmanu
Copy link
Contributor

@montmanu montmanu commented Jul 18, 2019

Summary

Adds required GCLOUD_SDK_TAG --build-arg to Dockerfile.

Removes Dockerfile.1.10, Dockerfile.1.11; the cloud-sdk version (and by proxy, the kubectl version) can / must now be customized via the new GCLOUD_SDK_VERSION build arg.

Removes bin/dist; replaced with make-based implementation.

Adds several misc config / rc files (e.g., .dockerignore, .editorconfig, etc).

Updates README, DOCS.md to reflect changes, address lint issues.

Motivation

This changeset evolved from the changes included in #115 and the primary motivation was to enable a tighter local development cycle / shorter iterations. These changes were separated from #115 primarily to simplify code review.

With these two changes, we may be able to address improvements / feature requests (e.g., #29 , #104 , #105 , etc) with less friction, barriers to entry for new contributors, more flexibility, etc.

@montmanu montmanu requested review from tonglil and fsouza July 18, 2019 15:45
montmanu added a commit that referenced this pull request Jul 18, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
Copy link

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Looks good! Just one question about the Dockerfile.

Dockerfile Outdated Show resolved Hide resolved
Copy link
Contributor Author

@montmanu montmanu left a comment

Choose a reason for hiding this comment

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

some notes to self

README.md Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Copy link
Member

@tonglil tonglil left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring the build process.

Can you move the usage information above the develop information?

I like the changes to the pipeline, but I have concerns about the makefile:

  • it adds maintenance complexity
  • it's probably better to keep the publishing task to the ci/cd pipeline, vs documenting the publishing flow through the make file - now there are 2 ways to accomplish the same thing
  • see other comment

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
usage :
@echo "Usage:"
@echo ""
@echo " \$$ make check # run tests for required software"
Copy link
Member

Choose a reason for hiding this comment

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

is checking necessary - wouldn't the commands fail if it's not installed anyways, or does make hide the error message?

Copy link
Contributor Author

@montmanu montmanu Jul 20, 2019

Choose a reason for hiding this comment

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

the commands would fail, but the thinking behind these check-* targets is that each could be added as a prerequisite to another target .. effectively becoming a hook to provide some feedback to a user about installing whatever dependency they're missing:

# compile binary
$(binary_name) : check-go # ...

if the user doesn't have go installed, we could include something like a link to install documentation

that said, not at all opposed to removing these.. is that what you'd prefer?

Copy link
Member

Choose a reason for hiding this comment

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

Since it's written, let's keep it.
I think if it becomes a cause of errors then we can remove it then to reduce points of maintenance :)

README.md Show resolved Hide resolved
@montmanu

This comment has been minimized.

- adds required `GCLOUD_SDK_VERSION` `--build-arg` to `Dockerfile`
- removes `Dockerfile.1.10`, `Dockerfile.1.11` (can now be customized via `GCLOUD_SDK_VERSION` build arg)
- removes `bin/dist`; replaced with `make`-based implementation
- adds several misc config / rc files
- updates `README`, `DOCS.md` to reflect changes, address linting

refactor build tooling

- adds required `GCLOUD_SDK_VERSION` `--build-arg` to `Dockerfile`
- removes `Dockerfile.1.10`, `Dockerfile.1.11` (can now be customized via `GCLOUD_SDK_VERSION` build arg)
- removes `bin/dist`; replaced with `make`-based implementation
- adds several misc config / rc files
- updates `README`, `DOCS.md` to reflect changes, address linting

Apply suggestions from code review

Co-Authored-By: Chris Montoro <[email protected]>
- remove cloud-sdk stage from Dockerfile
- remove bin/install-kubectl ; add installation steps inline within Dockerfile
- replaced references to CLOUD_SDK_VERSION / GCLOUD_SDK_VERSION with GCLOUD_SDK_TAG
- move developer focused documentation to CONTRIBUTING.md
- move .PHONY blocks to the line above each related target definition
- add coverage.out make target
- add check for go v 1.12+
- rename docker-release, docker-run-local make targets
- add terraform integration to automate test resource provisioning
- update DOCS.md to support deep links to individual parameters within API reference
- update local-example app, image, API_TOKEN variable names to avoid potential confusion with drone-gke parameters
montmanu added a commit that referenced this pull request Jul 22, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
montmanu added a commit that referenced this pull request Jul 22, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
@tonglil
Copy link
Member

tonglil commented Jul 25, 2019

perhaps some of the make-related documentation here would be better off in CONTRIBUTING.md?

Yes.

* `vars` - variables to use in `template` and `secret_template` (see [below](#available-vars) for details)
* `secrets` - credential and variables to use in `secret_template` (see [below](#secrets) for details)
* *optional* `expand_env_vars` - expand environment variables for values in `vars` for reference (defaults to `false`)
### `image`
Copy link
Member

Choose a reason for hiding this comment

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

This is very verbose, I'd like to stick to the original format, or in the drone plugins registry format:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there any automation built around those formats? happy to use a less verbose alternative, just thinking it would be helpful to enable deep linking directly to a specific parameter's documentation..

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK no there isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm if there isn't any automation built around the previous format or the other formats used, is there a functional downside to these changes (aside from the more verbose markdown source)?

in addition to the deep links, i think some folks might find the in-context examples helpful.. for a concrete case, i myself had to view the source of the plugin to find out how to use the wait_deployments option (do i provide a string? if so, separated by what character? there aren't any other options that accept an array of values so it wasn't clear that this one was expected to be provided as such) .. for another, i wasn't aware that values within vars could be any arbitrary value (e.g., could include more than the primitive string / int types).. that might have been more obvious if the type info was included in the docs for each option

@@ -68,7 +417,7 @@ If connecting to a [zonal cluster](https://cloud.google.com/kubernetes-engine/do

The `zone` and `region` parameters are mutually exclusive; providing both to the plugin for the same execution will result in an error.

## Secrets
## Using `secrets`
Copy link
Member

Choose a reason for hiding this comment

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

👍

"namespace": "",
"project": "my-gcp-proj",
"zone": "us-east1-a"
"BRANCH": "master",
Copy link
Member

Choose a reason for hiding this comment

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

👍


Executing locally from the working directory:

```
```sh
Copy link
Member

Choose a reason for hiding this comment

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

👍


spec:
replicas: 3
template:
metadata:
labels:
app: {{.app}}
app: {{.app_name}}
Copy link
Member

Choose a reason for hiding this comment

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

can we keep this as {{.app}}?

env: {{.env}}
spec:
containers:
- name: app
image: {{.image}}
image: {{.app_image}}
Copy link
Member

Choose a reason for hiding this comment

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

and this as {{.image}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so while working with the project and documenting a few commands / parameters, i noticed this (as well as the {{.app}} and {{.API_TOKEN}} references) were potentially confusing

specifically, it seemed like folks might be easily confused between{{.API_TOKEN}} and secrets: { source: GOOGLE_CREDENTIALS, target: token } especially when looking for token and seeing references to both the SA credential use case and the secretRef use case.. same with the k8s container spec image use case and the drone step image use case, as well as in the k8s container spec name use and the pod spec label use case..

more generally, the idea here was to try and distinguish between references related to a user's use case and references related to the plugin's use case..

mind elaborating a bit on your concerns here?

@@ -0,0 +1,21 @@
root = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure you want to check this in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oliver-nyt happy to remove, but i think projects tend to set this to prevent configurations higher up in the filesystem tree (e.g, user settings) from resulting in auto generated changes that may not be desired within the project.. here are a few selected examples from the projects listed here:

htop
qemu
SpringBoot

wdyt? keep or remove?

Copy link
Contributor

Choose a reason for hiding this comment

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

Your call. I personally don't like checking in user tools specific stuff like editor configs (this is for VSCode only, right?) but I see your point, it makes life of some users easier. Interesting that so many projects do it.

Copy link

Choose a reason for hiding this comment

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

editorconfig isn't specific to vscode: https://editorconfig.org/#download 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

CONTRIBUTING.md Outdated Show resolved Hide resolved
Copy link

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

I second @oliver-nyt's comment on Go version, LGTM otherwise 🚀

Copy link

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

One question about check-go, because if failed locally 😬

Makefile Outdated Show resolved Hide resolved
@montmanu
Copy link
Contributor Author

@oliver-nyt @fsouza re: the version of go there, i was basing that off of

go 1.12

happy to remove the golang version checks if thats going to be a pain point

montmanu added a commit that referenced this pull request Jul 29, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
montmanu added a commit that referenced this pull request Jul 29, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
@montmanu
Copy link
Contributor Author

@tonglil @fsouza @oliver-nyt any other feedback / requested changes here, or is everyone comfortable merging at this point?

@oliver-nyt
Copy link
Contributor

Go for it

@fsouza
Copy link

fsouza commented Jul 31, 2019

good to go!

@montmanu montmanu merged commit 6c66920 into master Jul 31, 2019
montmanu added a commit that referenced this pull request Jul 31, 2019
- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114
montmanu added a commit that referenced this pull request Jul 31, 2019
* add new `kubectl_version` param

- enables running the plugin using a non-default `kubectl` executable
- updates image `ENTRYPOINT` to support setting of `EXTRA_KUBECTL_VERSIONS` environment variable used by plugin to validate against `kubectl_version`

depends on #114

* update DOCS

* update validation implementation, docs; add new option to make run target

* rename entrypoint to set-env-versions
@montmanu montmanu deleted the refactor-build branch July 31, 2019 09:21
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.

4 participants