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
39 changes: 39 additions & 0 deletions .github/workflows/check-crc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: check-crc

on:
schedule:
- cron: "0 8 * * *"

jobs:
check-crc-repo:
runs-on: ubuntu-latest
env:
TOOL_REPO: crc-org/crc
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check Out Code
uses: actions/checkout@v2
- name: Get latest CRC version
run: |
echo "REPO_CRC_VERSION=$(cat src/tools.json | jq -r .crc.crcVersion)" >> $GITHUB_ENV
LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,name,url)
echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV
echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV
echo "LATEST_OPENSHIFT_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .name | cut -d'-' -f2)" >> $GITHUB_ENV
- name: Find existing PR for CRC version
run: |
echo "PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state all --search "update crc ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length)" >> $GITHUB_ENV
- name: Update src/tools.json with latest crc version
if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_CRC_VERSION) && (env.PR_EXISTS == 0) }}
run: |
jq --indent 4 '.crc.crcVersion = "${{ env.LATEST_TOOL_RELEASE }}"' src/tools.json | jq --indent 4 '.crc.openshiftVersion = "^${{ env.LATEST_OPENSHIFT_RELEASE }}"' > src/tools.json.new
mv src/tools.json.new src/tools.json
- name: Create pull request
if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_CRC_VERSION) && (env.PR_EXISTS == 0) }}
run: |
git config --global user.email "openshifttools-bot@users.noreply.github.com"
git config --global user.name "openshifttools-bot"
git checkout -b "crc-${{ env.LATEST_TOOL_RELEASE }}"
git commit -am "Update crc to ${{ env.LATEST_TOOL_RELEASE }}"
git push origin "crc-${{ env.LATEST_TOOL_RELEASE }}"
gh pr create --title "Update crc to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}"
7 changes: 7 additions & 0 deletions src/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,12 @@
"cmdFileName": "helm-linux-amd64"
}
}
},
"crc": {
"description": "crc openshift container",
"vendor": "Red Hat, Inc.",
"name": "crc",
"crcVersion": "2.10.1",
"openshiftVersion": "4.11.7"
}
}
7 changes: 6 additions & 1 deletion src/webview/cluster/app/cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ const vscodeApi = window.vscodeApi;
export default function Header() {
const classes = useStyles();
const [showWizard, setShowWizard] = React.useState('');
const [crcLatest, setCrcLatest] = React.useState('');
const [crcOpenShift, setCrcOpenShift] = React.useState('');

window.onmessage = (event: any) => {
if (['crc', 'sandbox'].includes(event.data.param)) {
setShowWizard(event.data.param);
} else if (event.data.action === 'openCrcAddClusterPage') {
setCrcLatest(event.data.crc);
setCrcOpenShift(event.data.openShiftCRC);
}
}

Expand Down Expand Up @@ -159,7 +164,7 @@ export default function Header() {
<Typography variant='body2' component='p'>
Red Hat OpenShift Local brings a minimal OpenShift 4 cluster to your local computer.<br></br>You can use this guided workflow to create OpenShift cluster locally. Cluster take approximately 15 minutes to provision.
</Typography>
<AddClusterView vscode={vscodeApi} />
<AddClusterView vscode={vscodeApi} crc={crcLatest} openshiftCrc={crcOpenShift}/>
</Card>
</div>
)}
Expand Down
16 changes: 7 additions & 9 deletions src/webview/cluster/app/clusterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { makeStyles, withStyles } from '@mui/styles';
import * as React from 'react';
import * as ClusterViewStyles from './clusterView.style';

import { ClusterViewProps } from '../../common/propertyTypes';
const prettyBytes = require('pretty-bytes');

const useStyles = makeStyles(ClusterViewStyles.useStyles);
Expand All @@ -50,10 +50,8 @@ function getSteps() {
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default function addClusterView(props) {
export default function addClusterView(props: ClusterViewProps) {
const classes = useStyles();
const crcLatest = '2.10.1';
const crcOpenShift = '4.11.7';
const [fileName, setBinaryPath] = React.useState('');
const [pullSecretPath, setSecret] = React.useState('');
const [cpuSize, setCpuSize] = React.useState(crcDefaults.DefaultCPUs);
Expand Down Expand Up @@ -292,7 +290,7 @@ export default function addClusterView(props) {
if (platform === 'darwin') crcBundle = 'crc-macos-amd64.pkg';
if (platform === 'win32') crcBundle = 'crc-windows-installer.zip';
if (platform === 'linux') crcBundle = 'crc-linux-amd64.tar.xz';
return `${crcDefaults.DefaultCrcUrlBase}/${crcLatest}/${crcBundle}`;
return `${crcDefaults.DefaultCrcUrlBase}/${props.crc}/${crcBundle}`;
}

const RunningStatus = ()=> (
Expand Down Expand Up @@ -457,7 +455,7 @@ export default function addClusterView(props) {
</Avatar>} />
<ListItemText
primary='Download'
secondary={<span>This will download OpenShift Local {crcLatest}</span>}/>
secondary={<span>This will download OpenShift Local {props.crc}</span>}/>
<a href={fetchDownloadBinary()} style={{ textDecoration: 'none'}}>
<Button
component='span'
Expand All @@ -474,7 +472,7 @@ export default function addClusterView(props) {
</Avatar>} />
<ListItemText
primary={<span>Executable Location<sup style={{color: '#BE0000'}}>*</sup></span>}
secondary={<span>Provide the OpenShift Local {crcLatest} executable location</span>} />
secondary={<span>Provide the OpenShift Local {props.crc} executable location</span>} />
<div>
<input
style={{ display: 'none' }}
Expand Down Expand Up @@ -600,7 +598,7 @@ export default function addClusterView(props) {
case 4:
return (
<Typography>
Start the cluster. This will create a minimal OpenShift {crcOpenShift} cluster on your computer.
Start the cluster. This will create a minimal OpenShift {props.openshiftCrc} cluster on your computer.
</Typography>)
default:
return 'Unknown step';
Expand All @@ -611,7 +609,7 @@ export default function addClusterView(props) {
<Paper elevation={3}>
<blockquote className={classes.blockquoteText}>
<Typography variant='body2' component='p' style={{textAlign: 'center'}}>
Install OpenShift {crcOpenShift} on your system using OpenShift Local {crcLatest}.
Install OpenShift {props.openshiftCrc} on your system using OpenShift Local {props.crc}.
</Typography>
</blockquote>
<Stepper activeStep={activeStep} orientation='vertical' children={steps.map((label, index) => (
Expand Down
22 changes: 22 additions & 0 deletions src/webview/cluster/clusterViewLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ export default class ClusterViewLoader {

@vsCommand('openshift.explorer.addCluster.openCrcAddClusterPage')
static async openCrcAddClusterPage() {
const toolsJsonPath = vscode.Uri.file(path.join(ClusterViewLoader.extensionPath, 'src/tools.json'));
let crc: string, crcOpenShift: string;
try {
const content = fs.readFileSync(toolsJsonPath.fsPath, { encoding: 'utf-8' });
const json = JSON.parse(content);
crc = json.crc.crcVersion;
crcOpenShift = json.crc.openshiftVersion;
} catch (err) {
const telemetryEventLoginToSandbox = new ExtCommandTelemetryEvent('openshift.explorer.addCluster.openCrcAddClusterPage');
crc = '',
crcOpenShift = '';
vscode.window.showErrorMessage(err.message);
telemetryEventLoginToSandbox.sendError('Unable to fetch CRC and OpenshiftCRC version');
} finally {
panel.webview.postMessage(
{
action: 'openCrcAddClusterPage',
crc: crc,
openShiftCRC: crcOpenShift
});
}

// fake command to report crc selection through telemetry
}

Expand Down
6 changes: 6 additions & 0 deletions src/webview/common/propertyTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export interface DefaultProps {
analytics?: import('@segment/analytics-next').Analytics;
}

export interface ClusterViewProps extends DefaultProps {
vscode: VscodeAPI;
crc: string;
openshiftCrc: string;
}

export interface StarterProjectDisplayProps extends DefaultProps {
project: StarterProject | any;
}
Expand Down