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

feat(pci-kubernetes): kubernetes OIDC add optional fields #14523

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Eric-ciccotti
Copy link
Contributor

@Eric-ciccotti Eric-ciccotti commented Dec 10, 2024

Question Answer
Branch? develop
Bug fix? no
New feature? yes
Breaking change? no
Tickets Fix #TAPC-34
License BSD 3-Clause
  • Try to keep pull requests small so they can be easily reviewed.
  • Commits are signed-off
  • Only FR translations have been updated
  • Branch is up-to-date with target branch
  • Lint has passed locally
  • Standalone app was ran and tested locally
  • Ticket reference is mentioned in linked commits (internal only)
  • Breaking change is mentioned in relevant commits

Description

This PR add optional fields for kubernetes OIDC provider

Related

@Eric-ciccotti Eric-ciccotti requested review from a team as code owners December 10, 2024 15:37
@Eric-ciccotti Eric-ciccotti changed the base branch from master to develop December 10, 2024 15:38
@Eric-ciccotti Eric-ciccotti added the draft work in progress label Dec 10, 2024
"pci_projects_project_kubernetes_details_service_update_oidc_provider_action_update": "Modifier",
"pci_projects_project_kubernetes_details_service_update_oidc_provider_action_cancel": "Annuler",
"pci_projects_project_kubernetes_details_service_update_oidc_provider_field_url": "Provider URL (Obligatoire)",
"pci_projects_project_kubernetes_details_service_update_oidc_provider_field_url_extra": "Saisissez ici l'URL de discovery de votre fournisseur, sans path. L'URL doit pointer vers le niveau précédent .well-known/openid-configuration . Vous devez utiliser une URL débutant par https://",

Choose a reason for hiding this comment

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

Suggested change
"pci_projects_project_kubernetes_details_service_update_oidc_provider_field_url_extra": "Saisissez ici l'URL de discovery de votre fournisseur, sans path. L'URL doit pointer vers le niveau précédent .well-known/openid-configuration . Vous devez utiliser une URL débutant par https://",
"pci_projects_project_kubernetes_details_service_update_oidc_provider_field_url_extra": "Saisissez ici l'URL de discovery de votre fournisseur, sans path. L'URL doit pointer vers le niveau précédent .well-known/openid-configuration . Vous devez utiliser une URL commençant par https://",

"pci_projects_project_kubernetes_details_service_hide_optional": "Voir moins d’options",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_ca_content_error": "Le champ caContent doit être une chaîne valide en Base64.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_error": "Le champ requiredClaim doit être au format 'clé=valeur'.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : valeur1, valeur2.",

Choose a reason for hiding this comment

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

Suggested change
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : valeur1, valeur2.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_caption": "Ajoutez plusieurs valeurs en les séparant par des virgules, par exemple : group1, group2",

"pci_projects_project_kubernetes_details_service_oidc_provider_field_ca_content_error": "Le champ caContent doit être une chaîne valide en Base64.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_error": "Le champ requiredClaim doit être au format 'clé=valeur'.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : valeur1, valeur2.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : clé1=valeur1, clé2=valeur2.",

Choose a reason for hiding this comment

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

Suggested change
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : clé1=valeur1, clé2=valeur2.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_caption": "Ajoutez plusieurs valeurs en les séparant par des virgules, par exemple : role=admin, environment=production",

"pci_projects_project_kubernetes_details_service_show_optional": "Configuration optionnelle",
"pci_projects_project_kubernetes_details_service_hide_optional": "Voir moins d’options",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_ca_content_error": "Le champ caContent doit être une chaîne valide en Base64.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_error": "Le champ requiredClaim doit être au format 'clé=valeur'.",

Choose a reason for hiding this comment

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

Add a error case if customer doesn't use "," as separator.

Le champ requiredClaim doit contenir une liste de valeurs séparées par des virgules, par exemple :role=admin, environment=production

"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_error": "Le champ requiredClaim doit être au format 'clé=valeur'.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : valeur1, valeur2.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_required_claim_caption": "Ajouter plusieurs valeurs séparées par des virgules, exemple : clé1=valeur1, clé2=valeur2.",
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_error": "Le champ groupsClaim doit contenir une liste de valeurs séparées par des virgules."

Choose a reason for hiding this comment

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

Suggested change
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_error": "Le champ groupsClaim doit contenir une liste de valeurs séparées par des virgules."
"pci_projects_project_kubernetes_details_service_oidc_provider_field_groups_claim_error": "Le champ groupsClaim doit contenir une liste de valeurs séparées par des virgules, par exemple : group1, group2"

});
});
});
// import { describe, it, vi } from 'vitest';
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I see, this file should be removed.

Comment on lines 85 to 93
// Fonction pour vérifier si une chaîne est une chaîne Base64 valide
function isBase64(str: string) {
try {
return btoa(atob(str)) === str;
} catch (err) {
return false;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There are multiple issues here:

  • we shouldn't declare any logical function into a types folder
  • the comment is in French
  • there is no test associated

export const camelToSnake = (camelCase: string): string =>
camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();

export const filterSchemaKeys = (schema, excludeKeys) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing type parameters

Object.keys(schema.shape).filter((key) => !excludeKeys.includes(key));

export const parseCommaSeparated = (
value: string | string[] | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value: string | string[] | undefined,
value?: string | string[],

Comment on lines 141 to 142
.map((item) => item.trim())
.filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is redundant with the function line 136, please make a dedicated function

'upsert-oidc-provider',
'add-oidc-provider',
'update-oidc-provider',
// 'upsert-oidc-provider',
Copy link
Contributor

Choose a reason for hiding this comment

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

To be removed

upsertOidcProvider(data);
const fields = useFormFields();

const onSubmit = (data: TOidcFormValues) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap into a useCallback as upsertOidcProvider depends on a hook call

variant={ODS_BUTTON_VARIANT.ghost}
onClick={onClose}
data-testid={`${mode}-oidc-provider:${mode}OIDCProvider-button_cancel`}
<OsdsText
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a lot of redundancies in these elements, please think to refactor code using high level functions and/or React.CloneELement to prevent from rewriting the same things with different props.

import React, { FormEvent } from 'react';
import { OsdsTextarea } from '@ovhcloud/ods-components/react';

export type TtextAreaFormFieldProps = React.ComponentProps<
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export type TtextAreaFormFieldProps = React.ComponentProps<
export type TTextAreaFormFieldProps = React.ComponentProps<

const useFormFields = () => {
const { t } = useTranslation('oidc-provider');

const fields = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const fields = useMemo(() => {
return useMemo(() => {

@Eric-ciccotti Eric-ciccotti force-pushed the feat/pci-kubernetes_oidc-add-optional-fields_tapc-34 branch 2 times, most recently from f7d4b3e to c5b2e5d Compare December 16, 2024 08:48
@Eric-ciccotti Eric-ciccotti force-pushed the feat/pci-kubernetes_oidc-add-optional-fields_tapc-34 branch from c5b2e5d to 42106df Compare December 16, 2024 13:00
@@ -1,4 +1,3 @@
import { ResponseAPIError } from '@ovh-ux/manager-pci-common';
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this is still used (line 85-86)

@Eric-ciccotti Eric-ciccotti force-pushed the feat/pci-kubernetes_oidc-add-optional-fields_tapc-34 branch 2 times, most recently from 7bac475 to 7839844 Compare December 16, 2024 13:54
JacquesLarique
JacquesLarique previously approved these changes Dec 16, 2024
Eric Ciccotti added 4 commits December 16, 2024 16:01
ref: TAPC-2088
Signed-off-by: Eric Ciccotti <[email protected]>
ref: TAPC-2088
Signed-off-by: Eric Ciccotti <[email protected]>
ref: TAPC-34
Signed-off-by: Eric Ciccotti <[email protected]>
ref: TAPC-34
Signed-off-by: Eric Ciccotti <[email protected]>
@Eric-ciccotti Eric-ciccotti force-pushed the feat/pci-kubernetes_oidc-add-optional-fields_tapc-34 branch from 7839844 to 181e6f8 Compare December 16, 2024 15:01
ref: TAPC-34
Signed-off-by: Eric Ciccotti <[email protected]>
@Eric-ciccotti Eric-ciccotti removed the draft work in progress label Dec 17, 2024
Copy link

sonarcloud bot commented Dec 17, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants