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

Add support for up ctp provider install and up ctp configuration install #261

Merged
merged 9 commits into from
Sep 28, 2022

Conversation

hasheddan
Copy link
Contributor

@hasheddan hasheddan commented Sep 27, 2022

Description of your changes

Adds configuration and provider install commands to the ctp group. The
same struct is used for both commands, but variable interpolation is
used to parameterize based on the subtree from which the command is
invoked.

Signed-off-by: hasheddan georgedanielmangum@gmail.com

Fixes #159

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

Verified successful install of providers and configurations, as well as updates to functionality in up upbound commands.

πŸ€– (up) kind create cluster
Creating cluster "kind" ...
 βœ“ Ensuring node image (kindest/node:v1.21.1) πŸ–Ό
 βœ“ Preparing nodes πŸ“¦  
 βœ“ Writing configuration πŸ“œ 
 βœ“ Starting control-plane πŸ•ΉοΈ 
 βœ“ Installing CNI πŸ”Œ 
 βœ“ Installing StorageClass πŸ’Ύ 
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community πŸ™‚
πŸ€– (up) up uxp install
UXP 1.9.1-up.1 installed
πŸ€– (up) up ctp provider -h
Usage: up controlplane (ctp) provider <command>

Manage Providers.

Flags:
  -h, --help                         Show context-sensitive help.
  -v, --version                      Print version and exit.
  -q, --quiet                        Suppress all output.
      --pretty                       Pretty print output.

      --domain=https://upbound.io    Root Upbound domain ($UP_DOMAIN).
      --profile=STRING               Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING               Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify     [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).

Commands:
  controlplane (ctp) provider install    Install a Provider.
πŸ€– (up) up ctp configuraiton -h
up: error: unexpected argument configuraiton, did you mean "configuration"?
πŸ€– (up) up ctp configuration -h
Usage: up controlplane (ctp) configuration <command>

Manage Configurations.

Flags:
  -h, --help                         Show context-sensitive help.
  -v, --version                      Print version and exit.
  -q, --quiet                        Suppress all output.
      --pretty                       Pretty print output.

      --domain=https://upbound.io    Root Upbound domain ($UP_DOMAIN).
      --profile=STRING               Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING               Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify     [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).

Commands:
  controlplane (ctp) configuration install    Install a Configuration.
πŸ€– (up) up ctp provider install -h
Usage: up controlplane (ctp) provider install <package>

Install a Provider.

Arguments:
  <package>    Reference to the Provider.

Flags:
  -h, --help                                             Show context-sensitive help.
  -v, --version                                          Print version and exit.
  -q, --quiet                                            Suppress all output.
      --pretty                                           Pretty print output.

      --domain=https://upbound.io                        Root Upbound domain ($UP_DOMAIN).
      --profile=STRING                                   Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING                                   Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify                         [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).

      --kubeconfig=STRING                                Override default kubeconfig path.
      --name=STRING                                      Name of Provider.
      --package-pull-secrets=PACKAGE-PULL-SECRETS,...    List of secrets used to pull Provider.
  -w, --wait=DURATION                                    Wait duration for successful Provider installation.
πŸ€– (up) up ctp configuration install -h
Usage: up controlplane (ctp) configuration install <package>

Install a Configuration.

Arguments:
  <package>    Reference to the Configuration.

Flags:
  -h, --help                                             Show context-sensitive help.
  -v, --version                                          Print version and exit.
  -q, --quiet                                            Suppress all output.
      --pretty                                           Pretty print output.

      --domain=https://upbound.io                        Root Upbound domain ($UP_DOMAIN).
      --profile=STRING                                   Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING                                   Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify                         [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).

      --kubeconfig=STRING                                Override default kubeconfig path.
      --name=STRING                                      Name of Configuration.
      --package-pull-secrets=PACKAGE-PULL-SECRETS,...    List of secrets used to pull Configuration.
  -w, --wait=DURATION                                    Wait duration for successful Configuration installation.
πŸ€– (up) up ctp provider install upbound/provider-aws:v0.15.0 --package-pull-secrets=pull-sec -w 30s --pretty
  √   upbound-provider-aws installed and healthy                                                                                                                                                               
πŸ€– (up) k get pkg
NAME                                              INSTALLED   HEALTHY   PACKAGE                                        AGE
provider.pkg.crossplane.io/upbound-provider-aws   True        True      xpkg.upbound.io/upbound/provider-aws:v0.15.0   33s
πŸ€– (up) up ctp configuration install upbound/platform-ref-aws:v0.2.3
upbound-platform-ref-aws installed
πŸ€– (up) k get pkg
NAME                                                 INSTALLED   HEALTHY   PACKAGE                                                                 AGE
provider.pkg.crossplane.io/crossplane-provider-aws   True        Unknown   registry.upbound.io/crossplane/provider-aws:v0.32.0-rc.0.47.gd90a07b6   7s
provider.pkg.crossplane.io/upbound-provider-aws      True        True      xpkg.upbound.io/upbound/provider-aws:v0.15.0                            101s

NAME                                                       INSTALLED   HEALTHY   PACKAGE                                           AGE
configuration.pkg.crossplane.io/upbound-platform-ref-aws   True        Unknown   xpkg.upbound.io/upbound/platform-ref-aws:v0.2.3   10s

Moves the dynamic watch logic to the kube package such that it can be
used across commands.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Creates an upterm package that contains pterm styling used across
commands.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Updates upbound subcommands to consume functionality from the shared
dynamic watcher and pterm styles package.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds a package resource to the resources package to make accessing
common conditions simpler.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds a pkg command group, which currently only includes an install
command, but can be used for both providers and configurations when
included by parent command.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds configuration and provider install commands to the ctp group. The
same struct is used for both commands, but variable interpolation is
used to parameterize based on the subtree from which the command is
invoked.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds support for --package-pull-secrets to allow specifying pull secrets
on package installation.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
// NOTE(hasheddan): kong automatically cleans paths tagged with existingfile.
Kubeconfig string `type:"existingfile" help:"Override default kubeconfig path."`
Name string `help:"Name of ${package_type}."`
PackagePullSecrets []string `help:"List of secrets used to pull ${package_type}."`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a user-facing help string? If I was the user, I'd ask if the list is space-delimited, comma-delimited, or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlainRoy kong mostly handles this for us by displaying comma-separated, but open to feedback on the formatting (we can override pretty much everything):

--package-pull-secrets=PACKAGE-PULL-SECRETS,...    List of secrets used to pull Provider

If we do want to override this, we should do it across the board, which I'll likely break into a separate chunk of work πŸ‘πŸ»

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that it shows an example with a comma, I'm happy. I might be tempted to change "List" to "Comma-separated list", but I really don't feel strongly since the example makes it clear.

@@ -0,0 +1,76 @@
// Copyright 2021 Upbound Inc
Copy link
Contributor

Choose a reason for hiding this comment

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

2021?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! These are auto-generated from a template, time to bump this :)

Updates header template to 2022.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Copy link
Member

@tnthornton tnthornton 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 doing this @hasheddan! Just some non-blocking comments and a nit. Feel free to act on those if you wish πŸ‘.

Comment on lines +56 to +57
Configuration pkg.Cmd `cmd:"" set:"package_type=Configuration" help:"Manage Configurations."`
Provider pkg.Cmd `cmd:"" set:"package_type=Provider" help:"Manage Providers."`
Copy link
Member

Choose a reason for hiding this comment

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

[non-blocking]: Is this the first place we using multi-word variables in the Kong declarations? The snake case stands out to me. It looks like the other place we have a multi-word variable is controlplane which is all lowercase. I'm assuming snakecase is used for legibility (πŸ‘ ), curious if there was a active choice to go that path over camelcase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tnthornton this actually is just internal machinery for variable interpolation, it is never surfaced to the end user πŸ‘πŸ»

)

type Package struct {
unstructured.Unstructured
Copy link
Member

Choose a reason for hiding this comment

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

Definitely not the first time we've used this pattern (across repos) πŸ˜„. Before too long it might be worth considering moving these resource operations to a shared place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely agree on that πŸ‘πŸ» Thought about doing a larger refactor here, but decided to keep it for now until we feel a bit more pain around it

Comment on lines 46 to 49
RaisedPrefix = pterm.Prefix{
Style: &pterm.Style{pterm.FgLightMagenta},
Text: " πŸ™Œ",
}
Copy link
Member

Choose a reason for hiding this comment

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

nit - thoughts on keeping the prefixes together? i.e. this was separated from the EyesPrefix and it's not clear why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally makes sense, didn't realize I had separated them πŸ‘πŸ»

Organizes printer prefixes to live next to each other.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
@hasheddan hasheddan merged commit fde467c into upbound:main Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add up xpkg install command
3 participants