Skip to content
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
2 changes: 1 addition & 1 deletion libs/cypress/fixtures/repositories/initialRepositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const repoList: Repository[] = [
},
spec: {
url: 'https://github.com/flightctl/flightctl-demos',
type: RepoSpecType.GIT,
type: RepoSpecType.RepoSpecTypeGit,
},
status: {
conditions: [
Expand Down
3 changes: 1 addition & 2 deletions libs/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export { FleetRolloutStartedDetails } from './models/FleetRolloutStartedDetails'
export type { FleetRolloutStatus } from './models/FleetRolloutStatus';
export type { FleetSpec } from './models/FleetSpec';
export type { FleetStatus } from './models/FleetStatus';
export type { GenericRepoSpec } from './models/GenericRepoSpec';
export type { GitConfigProviderSpec } from './models/GitConfigProviderSpec';
export type { GitHubIntrospectionSpec } from './models/GitHubIntrospectionSpec';
export type { GitRepoSpec } from './models/GitRepoSpec';
export type { HookAction } from './models/HookAction';
export type { HookActionRun } from './models/HookActionRun';
export type { HookCondition } from './models/HookCondition';
Expand Down Expand Up @@ -180,7 +180,6 @@ export type { RolloutDeviceSelection } from './models/RolloutDeviceSelection';
export type { RolloutPolicy } from './models/RolloutPolicy';
export { RolloutStrategy } from './models/RolloutStrategy';
export type { SshConfig } from './models/SshConfig';
export type { SshRepoSpec } from './models/SshRepoSpec';
export type { Status } from './models/Status';
export { SystemdActiveStateType } from './models/SystemdActiveStateType';
export { SystemdEnableStateType } from './models/SystemdEnableStateType';
Expand Down
13 changes: 0 additions & 13 deletions libs/types/models/GenericRepoSpec.ts

This file was deleted.

22 changes: 22 additions & 0 deletions libs/types/models/GitRepoSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { HttpConfig } from './HttpConfig';
import type { SshConfig } from './SshConfig';
/**
* Git repository specification. Supports no auth (public repos), HTTP/HTTPS auth, or SSH auth.
*/
export type GitRepoSpec = {
/**
* The Git repository URL to clone from.
*/
url: string;
/**
* The repository type discriminator.
*/
type: 'git';
httpConfig?: HttpConfig;
sshConfig?: SshConfig;
};

13 changes: 9 additions & 4 deletions libs/types/models/HttpRepoSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
/* tslint:disable */
/* eslint-disable */
import type { HttpConfig } from './HttpConfig';
import type { RepoSpecType } from './RepoSpecType';
/**
* HTTP endpoint specification for fetching configuration.
*/
export type HttpRepoSpec = {
/**
* The HTTP URL to call or clone from.
* The HTTP URL to call.
*/
url: string;
type: RepoSpecType;
httpConfig: HttpConfig;
/**
* The repository type discriminator.
*/
type: 'http';
httpConfig?: HttpConfig;
/**
* URL suffix used only for validating access to the repository. Users might use the URL field as a root URL to be used by config sources adding suffixes. This will help with the validation of the http endpoint.
*/
Expand Down
6 changes: 4 additions & 2 deletions libs/types/models/OciRepoSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/* tslint:disable */
/* eslint-disable */
import type { OciAuth } from './OciAuth';
import type { RepoSpecType } from './RepoSpecType';
/**
* OCI container registry specification.
*/
Expand All @@ -16,7 +15,10 @@ export type OciRepoSpec = {
* URL scheme for connecting to the registry.
*/
scheme?: OciRepoSpec.scheme;
type: RepoSpecType;
/**
* The repository type discriminator.
*/
type: 'oci';
/**
* Access mode for the registry: "Read" for read-only (pull), "ReadWrite" for read-write (pull and push).
*/
Expand Down
6 changes: 3 additions & 3 deletions libs/types/models/RepoSpecType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* RepoSpecType is the type of the repository.
*/
export enum RepoSpecType {
GIT = 'git',
HTTP = 'http',
OCI = 'oci',
RepoSpecTypeGit = 'git',
RepoSpecTypeHttp = 'http',
RepoSpecTypeOci = 'oci',
}
5 changes: 2 additions & 3 deletions libs/types/models/RepositorySpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { GenericRepoSpec } from './GenericRepoSpec';
import type { GitRepoSpec } from './GitRepoSpec';
import type { HttpRepoSpec } from './HttpRepoSpec';
import type { OciRepoSpec } from './OciRepoSpec';
import type { SshRepoSpec } from './SshRepoSpec';
/**
* RepositorySpec describes a configuration repository.
*/
export type RepositorySpec = (GenericRepoSpec | HttpRepoSpec | SshRepoSpec | OciRepoSpec);
export type RepositorySpec = (GitRepoSpec | HttpRepoSpec | OciRepoSpec);

15 changes: 0 additions & 15 deletions libs/types/models/SshRepoSpec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useFormikContext } from 'formik';
import { FormGroup } from '@patternfly/react-core';
import { Trans } from 'react-i18next';

import { GenericRepoSpec, HttpRepoSpec, RepoSpecType, Repository } from '@flightctl/types';
import { GitRepoSpec, HttpRepoSpec, RepoSpecType, Repository } from '@flightctl/types';
import { DeviceSpecConfigFormValues, GitConfigTemplate, HttpConfigTemplate } from '../../../../types/deviceSpec';
import { useTranslation } from '../../../../hooks/useTranslation';
import TextField from '../../../form/TextField';
Expand Down Expand Up @@ -127,7 +127,7 @@ const ConfigWithRepositoryTemplateForm = ({

const ct = values.configTemplates[index] as HttpConfigTemplate | GitConfigTemplate;
const selectedRepo = repositories.find((repo) => repo.metadata.name === ct.repository);
const repoSpec = selectedRepo?.spec as GenericRepoSpec | HttpRepoSpec | undefined;
const repoSpec = selectedRepo?.spec as GitRepoSpec | HttpRepoSpec | undefined;

return (
<>
Expand All @@ -140,10 +140,10 @@ const ConfigWithRepositoryTemplateForm = ({
repoRefetch={repoRefetch}
isRequired
/>
{repoType === RepoSpecType.GIT && (
{repoType === RepoSpecType.RepoSpecTypeGit && (
<GitConfigForm template={ct as GitConfigTemplate} index={index} isReadOnly={isReadOnly} />
)}
{repoType === RepoSpecType.HTTP && (
{repoType === RepoSpecType.RepoSpecTypeHttp && (
<HttpConfigForm
template={ct as HttpConfigTemplate}
index={index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ConfigSection = ({
{type === ConfigType.INLINE && <ConfigInlineTemplateForm index={index} isReadOnly={isReadOnly} />}
{(type === ConfigType.GIT || type === ConfigType.HTTP) && (
<ConfigWithRepositoryTemplateForm
repoType={type === ConfigType.HTTP ? RepoSpecType.HTTP : RepoSpecType.GIT}
repoType={type === ConfigType.HTTP ? RepoSpecType.RepoSpecTypeHttp : RepoSpecType.RepoSpecTypeGit}
index={index}
isReadOnly={isReadOnly}
canCreateRepo={canCreateRepo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ImportFleetWizard = () => {
endpoint: 'repositories',
});

const gitRepositories = (repoList?.items || []).filter((repo) => repo.spec.type === RepoSpecType.GIT);
const gitRepositories = (repoList?.items || []).filter((repo) => repo.spec.type === RepoSpecType.RepoSpecTypeGit);

let body: React.ReactNode;

Expand All @@ -93,7 +93,7 @@ const ImportFleetWizard = () => {
} else {
const repoInitValues = getInitValues({
options: {
allowedRepoTypes: [RepoSpecType.GIT],
allowedRepoTypes: [RepoSpecType.RepoSpecTypeGit],
showRepoTypes: false,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormGroup, FormSection, Grid, Radio } from '@patternfly/react-core';
import { FormikErrors, useFormikContext } from 'formik';
import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';

import { GenericRepoSpec, Repository } from '@flightctl/types';
import { GitRepoSpec, Repository } from '@flightctl/types';
import { ImportFleetFormValues } from '../types';

import { RepositoryForm } from '../../../Repository/CreateRepository/CreateRepositoryForm';
Expand Down Expand Up @@ -36,7 +36,7 @@ const ExistingRepoForm = ({ repositories }: { repositories: Repository[] }) => {
const { values } = useFormikContext<ImportFleetFormValues>();

const currentRepo = repositories.find((r) => r.metadata.name === values.existingRepo);
const repoSpec = currentRepo?.spec as GenericRepoSpec | undefined; // Only git repositories can be used for importing fleets;
const repoSpec = currentRepo?.spec as GitRepoSpec | undefined; // Only git repositories can be used for importing fleets;
return (
<>
<FormGroup label={t('Repository')} fieldId="repository">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const OutputImageStep = () => {
<RepositorySelect
name="destination.repository"
repositories={ociRegistries}
repoType={RepoSpecType.OCI}
repoType={RepoSpecType.RepoSpecTypeOci}
canCreateRepo={canCreateRepo}
repoRefetch={refetch}
label={t('Target repository')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const SourceImageStep = () => {
name="source.repository"
label={t('Source repository')}
repositories={ociRegistries}
repoType={RepoSpecType.OCI}
repoType={RepoSpecType.RepoSpecTypeOci}
canCreateRepo={canCreateRepo}
repoRefetch={refetch}
isRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const OciRegistriesContext = React.createContext<OciRegistriesContextType | unde

export const OciRegistriesContextProvider = ({ children }: React.PropsWithChildren) => {
const [repoList, isLoading, error, refetch] = useFetchPeriodically<RepositoryList>({
endpoint: `repositories?fieldSelector=spec.type=${RepoSpecType.OCI}`,
endpoint: `repositories?fieldSelector=spec.type=${RepoSpecType.RepoSpecTypeOci}`,
});

const ociRegistries = React.useMemo(() => repoList?.items || [], [repoList]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import './CreateRepositoryForm.css';
const AdvancedSection = () => {
const { t } = useTranslation();
const { values } = useFormikContext<RepositoryFormValues>();
const showConfigTypeRadios = values.repoType === RepoSpecType.GIT;
const isOciRepo = values.repoType === RepoSpecType.OCI;
const showConfigTypeRadios = values.repoType === RepoSpecType.RepoSpecTypeGit;
const isOciRepo = values.repoType === RepoSpecType.RepoSpecTypeOci;

if (isOciRepo) {
return (
Expand Down Expand Up @@ -104,7 +104,7 @@ const AdvancedSection = () => {
)}
{values.configType === 'http' && (
<Grid hasGutter className={showConfigTypeRadios ? 'fctl-create-repo__adv-section--nested' : ''}>
{values.repoType === RepoSpecType.HTTP && (
{values.repoType === RepoSpecType.RepoSpecTypeHttp && (
<FormSection>
<FormGroupWithHelperText
label={t('Validation suffix')}
Expand Down Expand Up @@ -152,7 +152,7 @@ const AdvancedSection = () => {
isDisabled={values.httpConfig?.skipServerVerification}
/>
</FormGroup>
{values.repoType === RepoSpecType.HTTP && (
{values.repoType === RepoSpecType.RepoSpecTypeHttp && (
<FormGroupWithHelperText content={t('JWT authentication token for the HTTP service')} label={t('Token')}>
<TextField name="httpConfig.token" aria-label={t('Token')} />
</FormGroupWithHelperText>
Expand Down Expand Up @@ -188,21 +188,21 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => {
const isRepoTypeChangeDisabled = values.allowedRepoTypes?.length === 1;

const doChangeRepoType = (toType: RepoSpecType) => {
if (toType === RepoSpecType.GIT) {
void setFieldValue('repoType', RepoSpecType.GIT);
if (toType === RepoSpecType.RepoSpecTypeGit) {
void setFieldValue('repoType', RepoSpecType.RepoSpecTypeGit);
void setFieldValue('httpConfig.token', undefined);
void setFieldValue('canUseResourceSyncs', true);
}

if (toType === RepoSpecType.HTTP) {
void setFieldValue('repoType', RepoSpecType.HTTP);
if (toType === RepoSpecType.RepoSpecTypeHttp) {
void setFieldValue('repoType', RepoSpecType.RepoSpecTypeHttp);
void setFieldValue('configType', 'http');
void setFieldValue('useResourceSyncs', false);
void setFieldValue('canUseResourceSyncs', false);
}

if (toType === RepoSpecType.OCI) {
void setFieldValue('repoType', RepoSpecType.OCI);
if (toType === RepoSpecType.RepoSpecTypeOci) {
void setFieldValue('repoType', RepoSpecType.RepoSpecTypeOci);
void setFieldValue('useResourceSyncs', false);
void setFieldValue('canUseResourceSyncs', false);
if (!values.ociConfig) {
Expand Down Expand Up @@ -233,7 +233,7 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => {
id="git-repo-radio"
name="repoType"
label={t('Use Git repository')}
checkedValue={RepoSpecType.GIT}
checkedValue={RepoSpecType.RepoSpecTypeGit}
onChangeCustom={onRepoTypeChange}
noDefaultOnChange
isDisabled={isRepoTypeChangeDisabled}
Expand All @@ -244,7 +244,7 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => {
id="http-repo-radio"
name="repoType"
label={t('Use HTTP service')}
checkedValue={RepoSpecType.HTTP}
checkedValue={RepoSpecType.RepoSpecTypeHttp}
onChangeCustom={onRepoTypeChange}
noDefaultOnChange
isDisabled={isRepoTypeChangeDisabled}
Expand All @@ -255,7 +255,7 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => {
id="oci-repo-radio"
name="repoType"
label={t('Use OCI registry')}
checkedValue={RepoSpecType.OCI}
checkedValue={RepoSpecType.RepoSpecTypeOci}
onChangeCustom={onRepoTypeChange}
noDefaultOnChange
isDisabled={isRepoTypeChangeDisabled}
Expand Down Expand Up @@ -299,7 +299,7 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => {
export const RepositoryForm = ({ isEdit }: { isEdit?: boolean }) => {
const { t } = useTranslation();
const { values } = useFormikContext<RepositoryFormValues>();
const isOciRepo = values.repoType === RepoSpecType.OCI;
const isOciRepo = values.repoType === RepoSpecType.RepoSpecTypeOci;

return (
<>
Expand Down Expand Up @@ -393,7 +393,7 @@ const CreateRepositoryFormContent = ({ isEdit, isReadOnly, onClose, children }:
const { checkPermissions } = usePermissionsContext();
const [canCreateRS] = checkPermissions([{ kind: RESOURCE.RESOURCE_SYNC, verb: VERB.CREATE }]);

const showResourceSyncs = values.canUseResourceSyncs && values.repoType === RepoSpecType.GIT;
const showResourceSyncs = values.canUseResourceSyncs && values.repoType === RepoSpecType.RepoSpecTypeGit;
return (
<FlightCtlForm className="fctl-create-repo">
<fieldset disabled={isReadOnly}>
Expand Down
Loading