chore: work around some of the secret validation
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -6,14 +6,14 @@ metadata:
|
||||
spec:
|
||||
parameters:
|
||||
- title: Do something
|
||||
required:
|
||||
- myKey
|
||||
properties:
|
||||
myKey:
|
||||
title: My key
|
||||
description: asd
|
||||
type: string
|
||||
ui:field: Secret
|
||||
ui:options:
|
||||
required: true
|
||||
steps: []
|
||||
type: service
|
||||
|
||||
@@ -27,6 +27,7 @@ export const Secret = (props: ScaffolderRJSFFieldProps) => {
|
||||
rawErrors,
|
||||
disabled,
|
||||
errors,
|
||||
onChange,
|
||||
required,
|
||||
} = props;
|
||||
|
||||
@@ -42,7 +43,18 @@ export const Secret = (props: ScaffolderRJSFFieldProps) => {
|
||||
<Input
|
||||
id={title}
|
||||
aria-describedby={title}
|
||||
onChange={e => setSecrets({ [name]: e.target?.value })}
|
||||
onChange={e => {
|
||||
// TODO(blam): this is a bit of a hack. We need to to probably figure out
|
||||
// how to provide our own validator that can filter out the secrets from the
|
||||
// jsonschema, or merge the secrets with the formData for validation?
|
||||
// Makes the review step a little cleaner with this though.
|
||||
onChange(
|
||||
Array(e.target?.value.length ?? 0)
|
||||
.fill('*')
|
||||
.join(''),
|
||||
);
|
||||
setSecrets({ [name]: e.target?.value });
|
||||
}}
|
||||
type="password"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
@@ -14,4 +14,3 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
export * from './Secret';
|
||||
export * from './validation';
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { CustomFieldValidator } from '@backstage/plugin-scaffolder-react';
|
||||
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const secretFieldValidation: CustomFieldValidator<string> = (
|
||||
value,
|
||||
errors,
|
||||
{ uiSchema },
|
||||
) => {
|
||||
console.log(uiSchema);
|
||||
if (uiSchema['ui:options'].required && !value) {
|
||||
errors.addError('Required');
|
||||
}
|
||||
};
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
MyGroupsPicker,
|
||||
MyGroupsPickerSchema,
|
||||
} from '../components/fields/MyGroupsPicker/MyGroupsPicker';
|
||||
import { Secret, secretFieldValidation } from '../components';
|
||||
import { Secret } from '../components';
|
||||
|
||||
export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
|
||||
{
|
||||
@@ -86,6 +86,5 @@ export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
|
||||
{
|
||||
component: Secret,
|
||||
name: 'Secret',
|
||||
validation: secretFieldValidation,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user