Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
use secret while creating resources
Browse files Browse the repository at this point in the history
  • Loading branch information
debsmita1 committed Jul 3, 2019
1 parent 916e8ed commit 27b7d51
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import {
} from '@console/internal/components/secrets/create-secret';
import { createModalLauncher } from '@console/internal/components/factory/modal';

interface CreateSourceSecretModalProps {
export interface CreateSourceSecretModalProps {
cancel: (e: MouseEvent) => void;
close: () => void;
onSave?: (name: string) => void;
namespace: string;
}

const CreateSourceSecretForm = withSecretForm(SourceSecretForm, true);

const CreateSourceSecretModal: React.FC<CreateSourceSecretModalProps> = ({
close,
namespace,
onSave,
}) => {
const CreateSourceSecretForm = withSecretForm(SourceSecretForm, true);
const handleSave = (name: string) => {
close();
onSave(name);
Expand All @@ -39,3 +40,5 @@ const CreateSourceSecretModal: React.FC<CreateSourceSecretModalProps> = ({
export const sourceSecretModalLauncher = createModalLauncher<CreateSourceSecretModalProps>(
CreateSourceSecretModal,
);

export default CreateSourceSecretModal;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sourceSecretModalLauncher } from './CreateSourceSecretModal';

const CREATE_SOURCE_SECRET = 'create-source-secret';

interface SourceSecretSelectorProps {
export interface SourceSecretSelectorProps {
namespace: string;
helpText: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const createBuildConfig = (
name,
project: { name: namespace },
application: { name: application },
git: { url: repository, ref = 'master', dir: contextDir },
git: { url: repository, ref = 'master', dir: contextDir, secret: secretName },
image: { tag: selectedTag },
build: { env, triggers },
labels: userLabels,
Expand Down Expand Up @@ -95,6 +95,13 @@ export const createBuildConfig = (
},
};

if (secretName) {
const param = 'sourceSecret';
buildConfig.spec.source[param] = {
name: secretName,
};
}

return k8sCreate(BuildConfigModel, buildConfig, dryRun ? dryRunOpt : {});
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/public/components/secrets/create-secret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const generateSecret = () => {
};

// withSecretForm returns SubForm which is a Higher Order Component for all the types of secret forms.
export const withSecretForm = (SubForm, modal?:boolean) => class SecretFormComponent extends React.Component<BaseEditSecretProps_, BaseEditSecretState_> {
export const withSecretForm = (SubForm, modal?: boolean) => class SecretFormComponent extends React.Component<BaseEditSecretProps_, BaseEditSecretState_> {
constructor(props) {
super(props);
const existingSecret = _.pick(props.obj, ['metadata', 'type']);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ type BaseEditSecretProps_ = {
saveButtonText?: string;
explanation: string;
onCancel?: () => void;
onSave?:(name: string) => void;
onSave?: (name: string) => void;
};

type BasicAuthSubformProps = {
Expand Down

0 comments on commit 27b7d51

Please sign in to comment.