Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
namkyu1999 authored Oct 9, 2024
2 parents ad85837 + e1f0d64 commit da9a0d8
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 11 deletions.
3 changes: 2 additions & 1 deletion chaoscenter/graphql/server/pkg/chaoshub/ops/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils"

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
Expand Down Expand Up @@ -284,7 +285,7 @@ func (c ChaosHubConfig) generateAuthMethod() (transport.AuthMethod, error) {
var auth transport.AuthMethod
if c.AuthType == model.AuthTypeToken {
auth = &http.BasicAuth{
Username: "litmus", // this can be anything except an empty string
Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket
Password: *c.Token,
}
} else if c.AuthType == model.AuthTypeBasic {
Expand Down
4 changes: 3 additions & 1 deletion chaoscenter/graphql/server/pkg/gitops/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"strings"
"time"

"github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils"

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
Expand Down Expand Up @@ -184,7 +186,7 @@ func (c GitConfig) getAuthMethod() (transport.AuthMethod, error) {

case model.AuthTypeToken:
return &http.BasicAuth{
Username: "litmus", // this can be anything except an empty string
Username: utils.Config.GitUsername, // must be a non-empty string or 'x-token-auth' for Bitbucket
Password: *c.Token,
}, nil

Expand Down
1 change: 1 addition & 0 deletions chaoscenter/graphql/server/utils/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Configuration struct {
GrpcPort string `split_words:"true" default:"8000"`
InfraCompatibleVersions string `required:"true" split_words:"true"`
DefaultHubGitURL string `required:"true" default:"https://github.com/litmuschaos/chaos-charts"`
GitUsername string `required:"true" split_words:"true" default:"litmus"`
DefaultHubBranchName string `required:"true" split_words:"true"`
CustomChaosHubPath string `split_words:"true" default:"/tmp/"`
DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export default function blankCanvasTemplate(

switch (infrastructureType) {
case InfrastructureType.KUBERNETES:
return kubernetesBlankCanvasTemplate(experimentName, experiment?.chaosInfrastructure?.namespace);
return kubernetesBlankCanvasTemplate(
experimentName,
experiment?.chaosInfrastructure?.namespace,
undefined,
experiment?.imageRegistry,
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ const ExperimentDashboardV2Table = ({
);
case ExperimentRunStatus.QUEUED:
return (
<RunExperimentButton
buttonProps={{ disabled: true }}
<StopExperimentButton
experimentID={data.experimentID}
refetchExperiments={refetchExperiments}
infrastructureType={InfrastructureType.KUBERNETES}
/>
);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const MenuCell = ({
onError: error => showError(error.message)
});

const lastExperimentRunStatus = data.recentExecutions[0]?.experimentRunStatus;
const isDeleteButtonEnabled = !data.recentExecutions.some(
execution => execution?.experimentRunStatus === ExperimentRunStatus.RUNNING
);

// <!-- confirmation dialog boxes -->
const confirmationDialogProps = {
Expand Down Expand Up @@ -108,10 +110,7 @@ export const MenuCell = ({
icon="main-trash"
text={getString('deleteExperiment')}
onClick={openDeleteDialog}
disabled={
lastExperimentRunStatus === ExperimentRunStatus.RUNNING ||
lastExperimentRunStatus === ExperimentRunStatus.QUEUED
}
disabled={isDeleteButtonEnabled == false}
permission={PermissionGroup.OWNER}
/>
</Menu>
Expand Down
27 changes: 26 additions & 1 deletion chaoscenter/web/src/views/StudioOverview/StudioOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { ChaosInfrastructureReferenceFieldProps, StudioErrorState, StudioTabs }
import experimentYamlService from 'services/experiment';
import KubernetesChaosInfrastructureReferenceFieldController from '@controllers/KubernetesChaosInfrastructureReferenceField';
import { InfrastructureType } from '@api/entities';
import { getImageRegistry } from '@api/core/ImageRegistry';
import { getScope } from '@utils';
import css from './StudioOverview.module.scss';

interface StudioOverviewViewProps {
Expand Down Expand Up @@ -52,6 +54,20 @@ export default function StudioOverviewView({

const [currentExperiment, setCurrentExperiment] = React.useState<ExperimentMetadata | undefined>();

const scope = getScope();

// Fetch the image registry data using Apollo's useQuery hook
const { data: getImageRegistryData, loading: imageRegistryLoading } = getImageRegistry({
projectID: scope.projectID,
});

const imageRegistry = getImageRegistryData?.getImageRegistry?{
name: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRegistryName,
repo: getImageRegistryData.getImageRegistry.imageRegistryInfo.imageRepoName,
secret: getImageRegistryData.getImageRegistry.imageRegistryInfo.secretName,
}
: undefined;

React.useEffect(() => {
experimentHandler?.getExperiment(experimentKey).then(experiment => {
delete experiment?.manifest;
Expand Down Expand Up @@ -85,6 +101,9 @@ export default function StudioOverviewView({
})
})}
onSubmit={values => {

values.imageRegistry = imageRegistry

if (values.chaosInfrastructure.namespace === undefined) {
delete values.chaosInfrastructure.namespace;
}
Expand Down Expand Up @@ -144,7 +163,13 @@ export default function StudioOverviewView({
text={getString('cancel')}
onClick={openDiscardDialog}
/>
<Button type="submit" intent="primary" text={getString('next')} rightIcon="chevron-right" />
<Button
type="submit"
intent="primary"
text={getString('next')}
rightIcon="chevron-right"
disabled={imageRegistryLoading}
/>
</Layout.Horizontal>
</Form>
</Layout.Vertical>
Expand Down

0 comments on commit da9a0d8

Please sign in to comment.