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

Adding THE KUBERNETES MIXIN #228

Merged
merged 2 commits into from
Mar 19, 2019

Conversation

jeremyrickard
Copy link
Contributor

@jeremyrickard jeremyrickard commented Mar 18, 2019

This PR adds a Kubernetes mixin. It updates the design doc a little to reflect a couple of
param changes across the three verbs and harmonizes things using camelCase naming per the
style guide from the GOOG.

Closes #82

@ghost ghost assigned jeremyrickard Mar 18, 2019
@ghost ghost added the review label Mar 18, 2019
Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

not done yet, got as far as schema_test.go 😅

mixin.In = in
cmd := &cobra.Command{
Use: "kubernetes",
Long: "kuberetes is a porter 👩🏽‍✈️ mixin that you can you can use to leverage kubernetes manifests",
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe replace leverage with "apply"

e.g. "apply kubernetes manifests in your bundle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PersistentPreRun: func(cmd *cobra.Command, args []string) {
mixin.Out = cmd.OutOrStdout()
mixin.Err = cmd.OutOrStderr()
},
Copy link
Member

Choose a reason for hiding this comment

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

We've also figured out that we want SilenceUsage: true, here as well. Otherwise it prints the help text anytime the an error happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

func buildUnInstallCommand(mixin *kubernetes.Mixin) *cobra.Command {
return &cobra.Command{
Use: "uninstall",
Short: "Use kubectl to delete manifests from cluster",
Copy link
Member

Choose a reason for hiding this comment

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

nit: delete resources contained in a manifest from a cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

func buildUpgradeCommand(mixin *kubernetes.Mixin) *cobra.Command {
return &cobra.Command{
Use: "Upgrade",
Short: "Use kubectl to apply manifests to cluster",
Copy link
Member

Choose a reason for hiding this comment

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

nit: to a cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resource_type: "service"
resource_name: "super-cool-service"
jsonpath: "spec.clusterIP"
resourceType: "service"
Copy link
Member

Choose a reason for hiding this comment

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

Question on the switch from snakes to camels. Is that something that should be done for all outputs? Or because of k8s? I'm not quite clear on why you made the switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for consistency.

}
err = cmd.Wait()
if err != nil {
prettyCmd := fmt.Sprintf("%s %s", cmd.Path, strings.Join(cmd.Args, " "))
Copy link
Member

Choose a reason for hiding this comment

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

I think we are missing a if m.Debug and a print of the pretty command?

Copy link
Member

Choose a reason for hiding this comment

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

oh wait I just realized that the mixins don't do that. Ignore me! 😊


func TestMixin_InstallStep(t *testing.T) {

manifestDirectory := "/cnab/app/manifesto"
Copy link
Member

Choose a reason for hiding this comment

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

is this a typo? I thought the directory was /cnab/app/manifests/?

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 was, however it's gone now!

return data, errors.Wrap(err, "could not read payload from STDIN")
}

func (m *Mixin) ValidatePayload(b []byte) error {
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to call this in getPayloadData or something so that we validate by default? Or hold off for a while?

"github.com/xeipuuv/gojsonschema"
)

const defaultManifestPath = "/cnab/app/manifests/kubernetes"
Copy link
Member

Choose a reason for hiding this comment

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

Is the plan for this that someone could do this below and it would automatically look in this location?

install:
  - kubernetes

I don't want to assume, but if my guess is right can you provide me a bit more context about that decision?

},
"namespace": {
"type": "string",
"minLength": 0
Copy link
Member

Choose a reason for hiding this comment

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

Is there a difference (jsonschema speaking) between specifying minLength = 0 and leaving it off entirely?

Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

ok all done, mega PR reviewed! Nothing big found, just minor comments.

install:
- kubernetes:
description: "Install Hello World App"
manifests:
Copy link
Member

Choose a reason for hiding this comment

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

Is this test file correct? It doesn't seem to match the name because there are manifests specified.

}

// UnInstall will delete anything created during the install or upgrade step
func (m *Mixin) UnInstall() error {
Copy link
Member

Choose a reason for hiding this comment

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

typo: UnInstall -> Uninstall


func TestMixin_UninstallStep(t *testing.T) {

manifestDirectory := "/cnab/app/manifesto"
Copy link
Member

Choose a reason for hiding this comment

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

Again, not sure if this is a typo or a joke? 😀

@@ -23,7 +23,7 @@ func TestMain(m *testing.M) {

func TestMixin_InstallStep(t *testing.T) {

manifestDirectory := "/cnab/app/manifesto"
manifestDirectory := "/cnab/app/manifests"
Copy link
Member

Choose a reason for hiding this comment

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

I'm relieved we don't have a manifesto anymore. 😅

"default":"true"
},
"record": {
"type": "boolean",
"type": ["boolean","null"],
Copy link
Member

Choose a reason for hiding this comment

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

what does it mean for the type to be bool or null?

This PR adds a Kubernetes mixin. It updates the design doc a little to reflect a couple of
param changes across the three verbs and harmonizes things using camelCase naming per the
[style guide](https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format) from
the GOOG.

Closes getporter#82
@jeremyrickard jeremyrickard force-pushed the kubing-all-those-netes branch from 22a7e40 to f4a8eb2 Compare March 19, 2019 16:53
@jeremyrickard jeremyrickard force-pushed the kubing-all-those-netes branch from f4a8eb2 to 3cb85bf Compare March 19, 2019 18:07
@carolynvs carolynvs merged commit 1bf86a1 into getporter:master Mar 19, 2019
@ghost ghost removed the review label Mar 19, 2019
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.

2 participants