-
Notifications
You must be signed in to change notification settings - Fork 212
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
Adding THE KUBERNETES MIXIN #228
Conversation
There was a problem hiding this 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 😅
cmd/kubernetes/main.go
Outdated
mixin.In = in | ||
cmd := &cobra.Command{ | ||
Use: "kubernetes", | ||
Long: "kuberetes is a porter 👩🏽✈️ mixin that you can you can use to leverage kubernetes manifests", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() | ||
}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
cmd/kubernetes/uninstall.go
Outdated
func buildUnInstallCommand(mixin *kubernetes.Mixin) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "uninstall", | ||
Short: "Use kubectl to delete manifests from cluster", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
cmd/kubernetes/upgrade.go
Outdated
func buildUpgradeCommand(mixin *kubernetes.Mixin) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "Upgrade", | ||
Short: "Use kubectl to apply manifests to cluster", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to a cluster
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, " ")) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! 😊
pkg/kubernetes/install_test.go
Outdated
|
||
func TestMixin_InstallStep(t *testing.T) { | ||
|
||
manifestDirectory := "/cnab/app/manifesto" |
There was a problem hiding this comment.
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/
?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
pkg/kubernetes/kubernetes.go
Outdated
"github.com/xeipuuv/gojsonschema" | ||
) | ||
|
||
const defaultManifestPath = "/cnab/app/manifests/kubernetes" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this 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: |
There was a problem hiding this comment.
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.
pkg/kubernetes/uninstall.go
Outdated
} | ||
|
||
// UnInstall will delete anything created during the install or upgrade step | ||
func (m *Mixin) UnInstall() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: UnInstall -> Uninstall
pkg/kubernetes/uninstall_test.go
Outdated
|
||
func TestMixin_UninstallStep(t *testing.T) { | ||
|
||
manifestDirectory := "/cnab/app/manifesto" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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
22a7e40
to
f4a8eb2
Compare
f4a8eb2
to
3cb85bf
Compare
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