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 Package Flag and Mark Package-Dir as Deprecated #309

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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

```

Expand All @@ -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

```

Expand Down
4 changes: 2 additions & 2 deletions docs/pluggable-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion pkg/cmd/create/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
CreateCmd.Flags().StringSliceVarP(&extraPackagesDirs, "package-dir", "p", []string{}, "Paths to directories containing custom packages")
// TODO: Remove package-dir and deprecation notice after 0.6.0 release
CreateCmd.Flags().StringSliceVar(&extraPackagesDirs, "package-dir", []string{}, "Paths to directories containing custom packages")
CreateCmd.Flags().MarkDeprecated("package-dir", "use --package instead")
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.")
Expand Down Expand Up @@ -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 {
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ")...)
Expand Down
Loading