Skip to content

New command to list the custom packages#466

Merged
cmoulliard merged 21 commits intocnoe-io:mainfrom
ch007m:list-packages
Jan 23, 2025
Merged

New command to list the custom packages#466
cmoulliard merged 21 commits intocnoe-io:mainfrom
ch007m:list-packages

Conversation

@cmoulliard
Copy link
Copy Markdown
Contributor

@cmoulliard
Copy link
Copy Markdown
Contributor Author

cmoulliard commented Dec 24, 2024

Example of what the code produce now

Custom packages added

❯ idp create --color --recreate --name dummy --port 9443 \
   -p https://github.com/cnoe-io/stacks//basic/package1 \
   -p https://github.com/cnoe-io/stacks//basic/package2

What the command idp get packages prints

// A custom package
❯ ./idpbuilder get packages -p app-my-app
CUSTOM PACKAGE NAME   IDP NAMESPACE      GIT REPOSITORY                                                                      STATUS
app-my-app            idpbuilder-dummy   https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-my-app-manifests   true

// All the custom packages
~/code/cnoe/fork-idpbuilder on list-packages •
❯ ./idpbuilder get packages
CUSTOM PACKAGE NAME   IDP NAMESPACE      GIT REPOSITORY                                                                      STATUS
app-guestbook         idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          true
app-my-app            idpbuilder-dummy   https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-my-app-manifests   true
app2-guestbook2       idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          true

~/code/cnoe/fork-idpbuilder on list-packages •

Copy link
Copy Markdown
Collaborator

@nabuskey nabuskey left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we merge all structs in separate files into one file? Is the entity package for types? If so, we should name the package as types instead of entity.

Copy link
Copy Markdown
Contributor Author

@cmoulliard cmoulliard Jan 2, 2025

Choose a reason for hiding this comment

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

If so, we should name the package as types instead of entity.

types is a better name. I will rename. Fixed: 6415f7b

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we merge all structs in separate files into one file?

Why do you want to merge them into one file ? This is easier to figure out what it exists if you have one file/type under the folder name types

@cmoulliard
Copy link
Copy Markdown
Contributor Author

Can we add additional printer columns for the package type?

Yes but what do you want to print under this new column ?

@cmoulliard
Copy link
Copy Markdown
Contributor Author

cmoulliard commented Jan 2, 2025

Question: Should we also add the column of the Argocd repo as we also have those for git or gitea repo ?
See: 0cd0d7d

❯ ./idpbuilder get packages
CUSTOM PACKAGE NAME   IDP NAMESPACE      GIT REPOSITORY                                                                      ARGOCD REPOSITORY                                                      STATUS
app-guestbook         idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          https://argocd.cnoe.localtest.me:9443/applications/argocd/guestbook    true
app-my-app            idpbuilder-dummy   https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-my-app-manifests   https://argocd.cnoe.localtest.me:9443/applications/argocd/my-app       true
app2-guestbook2       idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          https://argocd.cnoe.localtest.me:9443/applications/argocd/guestbook2   true

cmoulliard and others added 8 commits January 2, 2025 12:26
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
…mPackages

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Co-authored-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Co-authored-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Copy link
Copy Markdown
Collaborator

@nabuskey nabuskey left a comment

Choose a reason for hiding this comment

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

Let's merge all files under the types directory. I don't think we should have a file for each struct. It's very Java like right now.😅

func generatePackageTable(packagesTable []types.Package) metav1.Table {
table := &metav1.Table{}
table.ColumnDefinitions = []metav1.TableColumnDefinition{
{Name: "Custom package name", Type: "string"},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I liked "name" more. Custom package is already implied when you run the command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: 9bbd4d5

@nabuskey
Copy link
Copy Markdown
Collaborator

nabuskey commented Jan 2, 2025

Question: Should we also add the column of the Argocd repo as we also have those for git or gitea repo ?

See: 0cd0d7d


❯ ./idpbuilder get packages

CUSTOM PACKAGE NAME   IDP NAMESPACE      GIT REPOSITORY                                                                      ARGOCD REPOSITORY                                                      STATUS

app-guestbook         idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          https://argocd.cnoe.localtest.me:9443/applications/argocd/guestbook    true

app-my-app            idpbuilder-dummy   https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-my-app-manifests   https://argocd.cnoe.localtest.me:9443/applications/argocd/my-app       true

app2-guestbook2       idpbuilder-dummy   https://github.com/cnoe-io/stacks/tree/main/basic/package2                          https://argocd.cnoe.localtest.me:9443/applications/argocd/guestbook2   true

You mean ArgoCD application URL or git repositories used by ArgoCD applications?

@cmoulliard
Copy link
Copy Markdown
Contributor Author

Let's merge all files under the types directory. I don't think we should have a file for each struct. It's very Java like right now.😅

Indeed but that simplify the readability of the code and Java language rocks from this point of view :-)

@cmoulliard
Copy link
Copy Markdown
Contributor Author

You mean ArgoCD application URL or git repositories used by ArgoCD applications?

Argocd URL on our IDP to access the application straight from the Argocd UI

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
@nabuskey
Copy link
Copy Markdown
Collaborator

nabuskey commented Jan 3, 2025

Let's merge all files under the types directory. I don't think we should have a file for each struct. It's very Java like right now.😅

Indeed but that simplify the readability of the code and Java language rocks from this point of view :-)

Yeah I'd rather keep it uniform within this project. If you look at how we define related types for this project, we do that in a single file like here: https://github.com/cnoe-io/idpbuilder/blob/main/api/v1alpha1/custom_package_types.go

So let's merge them into a single file.

@nabuskey
Copy link
Copy Markdown
Collaborator

nabuskey commented Jan 3, 2025

You mean ArgoCD application URL or git repositories used by ArgoCD applications?

Argocd URL on our IDP to access the application straight from the Argocd UI

I see, then we should change the name of the column. It's currently named ARGOCD REPOSITORY. It should be ARGOCD URL yea?

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
@cmoulliard
Copy link
Copy Markdown
Contributor Author

So let's merge them into a single file.

Done: 593b727

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
@cmoulliard
Copy link
Copy Markdown
Contributor Author

I see, then we should change the name of the column. It's currently named ARGOCD REPOSITORY. It should be ARGOCD URL yea?

Fixed: da6e72b

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
@cmoulliard cmoulliard requested a review from nabuskey January 8, 2025 08:01
…and port

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Comment on lines +18 to +22
var (
ClusterProtocol string // http or https scheme
ClusterPort string // 8443 or user's port defined when the cluster is created
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we get away without using these? How come we can't use GiteaBaseUrl and ArgocdBaseUrl as-is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No as we need such global vars to generate the proper URLs of ArgoCD or Gitea. Such variables are collected when the cluster is created. Without such vars it will be needed to fetch them using the kubernetes CR.

k get localbuilds.idpbuilder.cnoe.io/dummy -oyaml
apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: Localbuild
metadata:
  name: dummy
spec:
  buildCustomization:
    host: cnoe.localtest.me
    ingressHost: cnoe.localtest.me
    port: "9443"
    protocol: https
    selfSignedCert: |
      -----BEGIN CERTIFICATE-----
      MIIBsDCCA...EVSNlep0EtTdKee
      Sg0OoQ==
      -----END CERTIFICATE-----
  packageConfigs:
    argoPackageConfigs:
      enabled: true
    embeddedArgoApplicationsPackageConfigs:
      enabled: true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see. Can we not get it from the CR then? If custom packages exist, then the localbuild object must also exist correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we not get it from the CR then? If custom packages exist, then the localbuild object must also exist correct?

We can get it using go code doing this "kubectl get cr/localbuilds.idpbuilder.cnoe.io" but this is a bit boiler plate as we got such values when we execute the command "idp create" ....

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's one call to the API server yea? i think that's fine. In Go, there's a lot of boilerplate like this 😆

Copy link
Copy Markdown
Contributor Author

@cmoulliard cmoulliard Jan 16, 2025

Choose a reason for hiding this comment

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

Fixed and did some reorg to avoid cycling import issue: 01a0b22
@nabuskey

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
…LocalBuild

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
@cmoulliard cmoulliard requested a review from nabuskey January 16, 2025 14:59
Copy link
Copy Markdown
Contributor

@punkwalker punkwalker left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@punkwalker
Copy link
Copy Markdown
Contributor

/e2e

@cmoulliard cmoulliard merged commit 3b21af9 into cnoe-io:main Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants