From 45d4f5de85c6a8dd5667d3f0395d6c1f6b22962f Mon Sep 17 00:00:00 2001 From: Blake R <85771645+blakeromano@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:19:44 -0700 Subject: [PATCH 1/2] Add Package Flag and Mark Package-Dir as Deprecated Signed-off-by: Blake R <85771645+blakeromano@users.noreply.github.com> --- pkg/cmd/create/root.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index ecf71465..8a84e75d 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -24,7 +24,9 @@ var ( kubeVersion string extraPortsMapping string kindConfigPath string + // TODO: Remove extraPackagesDirs after 0.6.0 release extraPackagesDirs []string + extraPackages []string packageCustomizationFiles []string noExit bool protocol string @@ -56,7 +58,10 @@ func init() { CreateCmd.PersistentFlags().StringVar(&protocol, "protocol", "https", "Protocol to use to access web UIs. http or https.") CreateCmd.PersistentFlags().StringVar(&port, "port", "8443", "Port number under which idpBuilder tools are accessible.") CreateCmd.PersistentFlags().BoolVar(&pathRouting, "use-path-routing", false, "When set to true, web UIs are exposed under single domain name.") + // TODO: Remove package-dir and deprecation notice after 0.6.0 release CreateCmd.Flags().StringSliceVarP(&extraPackagesDirs, "package-dir", "p", []string{}, "Paths to directories containing custom packages") + CreateCmd.Flags().MarkDeprecated("package-dir", "use --package instead") + CreateCmd.Flags().StringSliceVar(&extraPackages, "package", []string{}, "Paths to locations containing custom packages") CreateCmd.Flags().StringSliceVarP(&packageCustomizationFiles, "package-custom-file", "c", []string{}, "Name of the package and the path to file to customize the package with. e.g. argocd:/tmp/argocd.yaml") // idpbuilder related flags CreateCmd.Flags().BoolVarP(&noExit, "no-exit", "n", true, "When set, idpbuilder will not exit after all packages are synced. Useful for continuously syncing local directories.") @@ -86,6 +91,7 @@ func create(cmd *cobra.Command, args []string) error { var absDirPaths []string var remotePaths []string + // TODO: Remove this block after deprecation if len(extraPackagesDirs) > 0 { r, l, pErr := helpers.ParsePackageStrings(extraPackagesDirs) if pErr != nil { @@ -95,6 +101,15 @@ func create(cmd *cobra.Command, args []string) error { remotePaths = r } + if len(extraPackages) > 0 { + r, l, pErr := helpers.ParsePackageStrings(extraPackages) + if pErr != nil { + return pErr + } + absDirPaths = l + remotePaths = r + } + o := make(map[string]v1alpha1.PackageCustomization) for i := range packageCustomizationFiles { c, pErr := getPackageCustomFile(packageCustomizationFiles[i]) From d3bc909b2e85ef7a29757aacc6d5ec2071d23c6c Mon Sep 17 00:00:00 2001 From: Blake R <85771645+blakeromano@users.noreply.github.com> Date: Tue, 18 Jun 2024 07:44:48 -0700 Subject: [PATCH 2/2] Update documentation and make -p go to --package Signed-off-by: Blake R <85771645+blakeromano@users.noreply.github.com> --- README.md | 6 +++--- docs/pluggable-packages.md | 4 ++-- pkg/cmd/create/root.go | 4 ++-- tests/e2e/docker/docker_test.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 264a78a5..44cc2ad9 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Run the following commands for available flags and subcommands: ### Custom Packages -Idpbuilder supports specifying custom packages using the flag `--package-dir` flag. +Idpbuilder supports specifying custom packages using the flag `--package` flag. This flag expects a directory (local or remote) containing ArgoCD application files and / or ArgoCD application set files. In case of a remote directory, it must be a directory in a git repository, and the URL format must be a [kustomize remote URL format](https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md). @@ -164,7 +164,7 @@ Let's take a look at [this example](https://github.com/cnoe-io/stacks/tree/main/ To deploy these packages, run the following command. ``` -idpbuilder create -p https://github.com/cnoe-io/stacks//basic/package1 -p https://github.com/cnoe-io/stacks//basic/package2 +idpbuilder create --package https://github.com/cnoe-io/stacks//basic/package1 --package https://github.com/cnoe-io/stacks//basic/package2 ``` @@ -175,7 +175,7 @@ Alternatively, you can use the local directory format. git clone https://github.com/cnoe-io/stacks.git cd stacks # run idpbuilder against the local directory -idpbuilder create --package-dir basic/package1 --package-dir basic/package2 +idpbuilder create --package basic/package1 --package basic/package2 ``` diff --git a/docs/pluggable-packages.md b/docs/pluggable-packages.md index a99f68e1..82a43558 100644 --- a/docs/pluggable-packages.md +++ b/docs/pluggable-packages.md @@ -88,7 +88,7 @@ Users are expected to run the `helm template` command to generate manifests. ### Runtime Git server content generation As mentioned earlier, Git server contents are generated at compile time and cannot be changed at run time. -To solve this, Git content should be created at run time by introducing a new flag, `--package-dir`, to idpbuilder. This flag takes a directory that contains ArgoCD Applications. +To solve this, Git content should be created at run time by introducing a new flag, `--package`, to idpbuilder. This flag takes a directory that contains ArgoCD Applications. If this flag is not specified, use the embedded FS to provide the "default experience" where it uses the manifests provided at compile time to bootstrap and add predetermined packages to the cluster. Because Helm and Kustomize can reference remote repositories, this approach introduces a use case where secrets must be passed to the cluster from local machine. Kubernetes resource YAML files are often stored on a private Git server and require credentials to access. For ArgoCD to access the Git server, the credentials must be passed to ArgoCD as Kubernetes Secrets. @@ -267,7 +267,7 @@ Given the complexity involved with this approach, the first iteration should foc ###### ArgoCD Application handling -Consider a case where idpbuilder is given the flag `--package-dir ./packages`, and the `packages` directory contains a yaml file for a ArgoCD application. +Consider a case where idpbuilder is given the flag `--package ./packages`, and the `packages` directory contains a yaml file for a ArgoCD application. ```yaml apiVersion: argoproj.io/v1alpha1 diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index 8a84e75d..8936b169 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -59,9 +59,9 @@ func init() { CreateCmd.PersistentFlags().StringVar(&port, "port", "8443", "Port number under which idpBuilder tools are accessible.") CreateCmd.PersistentFlags().BoolVar(&pathRouting, "use-path-routing", false, "When set to true, web UIs are exposed under single domain name.") // TODO: Remove package-dir and deprecation notice after 0.6.0 release - CreateCmd.Flags().StringSliceVarP(&extraPackagesDirs, "package-dir", "p", []string{}, "Paths to directories containing custom packages") + CreateCmd.Flags().StringSliceVar(&extraPackagesDirs, "package-dir", []string{}, "Paths to directories containing custom packages") CreateCmd.Flags().MarkDeprecated("package-dir", "use --package instead") - CreateCmd.Flags().StringSliceVar(&extraPackages, "package", []string{}, "Paths to locations containing custom packages") + CreateCmd.Flags().StringSliceVarP(&extraPackages, "package", "p", []string{}, "Paths to locations containing custom packages") CreateCmd.Flags().StringSliceVarP(&packageCustomizationFiles, "package-custom-file", "c", []string{}, "Name of the package and the path to file to customize the package with. e.g. argocd:/tmp/argocd.yaml") // idpbuilder related flags CreateCmd.Flags().BoolVarP(&noExit, "no-exit", "n", true, "When set, idpbuilder will not exit after all packages are synced. Useful for continuously syncing local directories.") diff --git a/tests/e2e/docker/docker_test.go b/tests/e2e/docker/docker_test.go index 71199a84..e0159934 100644 --- a/tests/e2e/docker/docker_test.go +++ b/tests/e2e/docker/docker_test.go @@ -118,7 +118,7 @@ func testCustomPkg(t *testing.T) { defer cancel() defer CleanUpDocker(t) - cmdString := "create -p ../../../pkg/controllers/custompackage/test/resources/customPackages/testDir" + cmdString := "create --package ../../../pkg/controllers/custompackage/test/resources/customPackages/testDir" t.Log(fmt.Sprintf("running %s", cmdString)) cmd := exec.CommandContext(ctx, e2e.IdpbuilderBinaryLocation, strings.Split(cmdString, " ")...)