Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

shipperctl: introduce shipperctl chart render #374

Merged
merged 7 commits into from
Jan 21, 2021

Conversation

hihilla
Copy link
Contributor

@hihilla hihilla commented Nov 26, 2020

Continuing @juliogreff 's work on shipperctl chart render from pr #215

It's useful to know what kind of objects shipper is rendering before
they reach the api server. For debugging issues with YAML
serializing/deserializing, for instance.

For that, you can now run
shipperctl chart render app --filename application.yaml or
shipperctl chart render app --appName foobar or
shipperctl chart render relelase foobar-deadbeef-0

and shipperctl will print a whole bundle of YAML to stdout, with each object separatedby a ---.

$ shipperctl chart render
render Helm Charts for an Application or Release

Usage:
  shipperctl chart render [command]

Available Commands:
  app         render Shipper Charts for an Application
  release     render Shipper Charts for a Release

Flags:
  -h, --help   help for render

Global Flags:
      --kubeconfig string                   the path to the Kubernetes configuration file (default "~/.kube/config")
      --management-cluster-context string   The name of the context to use to communicate with the management cluster. defaults to the current one
  -n, --namespace string                    The namespace where the app lives

Use "shipperctl chart render [command] --help" for more information about a command.

$ shipperctl chart render release -h
render Shipper Charts for a Release

Usage:
  shipperctl chart render release bikerental-7abf46d4-0 [flags]

Flags:
  -h, --help   help for release

Global Flags:
      --kubeconfig string                   the path to the Kubernetes configuration file (default "~/.kube/config")
      --management-cluster-context string   The name of the context to use to communicate with the management cluster. defaults to the current one
  -n, --namespace string                    The namespace where the app lives

$ shipperctl chart render app -h
render Shipper Charts for an Application

Usage:
  shipperctl chart render app [flags]

Flags:
      --appName string               The name of an existing application to render chart for
      --filename applicastion.yaml   An application manifest in the current context to render chart for (e.g. applicastion.yaml)
  -h, --help                         help for app

Global Flags:
      --kubeconfig string                   the path to the Kubernetes configuration file (default "~/.kube/config")
      --management-cluster-context string   The name of the context to use to communicate with the management cluster. defaults to the current one
  -n, --namespace string                    The namespace where the app lives

juliogreff and others added 4 commits January 19, 2021 17:31
Without this, `make build/shipperctl.darwin-amd64` wouldn't rebuild
shipperctl even if files in `cmd/shipperctl/cmd/` changed.
It's useful to know what kind of objects shipper is rendering before
they reach the api server. For debugging issues with YAML
serializing/deserializing, for instance.

For that, you can now run `shipperctl chart render --app foobar` or
`shipperctl chart render --relelase foobar-deadbeef-0`, and shipperctl
will print a whole bundle of YAML to stdout, with each object separated
by a `---`.

This is currently only useful for applications that already exist, as
you can't manually pass standalone chart spec or values. We'll
eventually support that once we figure out a non-awkard interface for
doing that.

from commit 96980a3 by Julio Greff
@hihilla hihilla force-pushed the hillaxjgreff/shipperctl-chart-render branch from 1822f96 to 3829e9f Compare January 19, 2021 16:31
@hihilla hihilla force-pushed the hillaxjgreff/shipperctl-chart-render branch from b173af7 to 5ceac1b Compare January 20, 2021 11:25
@hihilla hihilla changed the title WIP: shipperctl: introduce shipperctl chart render shipperctl: introduce shipperctl chart render Jan 20, 2021
@hihilla hihilla marked this pull request as ready for review January 20, 2021 12:04
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
cmd/shipperctl/main.go Outdated Show resolved Hide resolved
}
},
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure, but I wonder if there is a better way to not have these variables global?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see it's consistent with the rest of the commands, but I was a bit confused by this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initial command was getting an appName, pulled it from the cluster and used the chart from it.
I wanted it to be possible to git a yaml of an application that does not exist in the cluster yet.
So with this command you can either give an app name or an application manifest (yaml file name)
The meaning of the variables is in their description in lines 40-41.
Other Go command line code is specifying the flags in a different location so there is no need for global variables. I opted for consistency, but I tend to agree that these global variables are not the best choice. I can start with these commands and have another PR to refactor the rest of shipperctl commands. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, I think it makes sense to keep it like that for now. Would you consider this as a potential refactoring for the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course! I wanted to do it by now but didn't have the time.
Go's way of doing CLIs is not so gracious, but I have seen some examples of nice ones when I was looking into this (shipperctl decommission shenanigans)

}
var application shipper.Application
if appName != "" {
applicationP, err := shipperClient.ShipperV1alpha1().Applications(namespace).Get(appName, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

what does applicationP stands for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pointer to an application object

Copy link
Contributor

Choose a reason for hiding this comment

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

I found the name a bit confusing.

Could we do:

application, err = *shipperClient.ShipperV1alpha1().Applications(namespace).Get(appName, metav1.GetOptions{})

or use applicationPointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using * doesn't work because the return type of .Get() is (*Application, error)
So I renamed

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh of course 🤦

@hihilla hihilla force-pushed the hillaxjgreff/shipperctl-chart-render branch from e46bba3 to 304abe4 Compare January 21, 2021 12:23
@hihilla hihilla merged commit 460b4d7 into master Jan 21, 2021
@hihilla hihilla deleted the hillaxjgreff/shipperctl-chart-render branch January 21, 2021 13:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants