-
Notifications
You must be signed in to change notification settings - Fork 667
Bug 1748219: Detect baremetal platform #2558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
jtomasek:detect-baremetal-platform
Sep 5, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './common'; | ||
| export * from './machine'; | ||
| export * from './infrastructure'; |
5 changes: 5 additions & 0 deletions
5
frontend/packages/console-shared/src/selectors/infrastructure.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import * as _ from 'lodash'; | ||
| import { K8sResourceKind } from '@console/internal/module/k8s'; | ||
|
|
||
| export const getInfrastructurePlatform = (infrastructure: K8sResourceKind): string => | ||
| _.get(infrastructure, 'status.platform'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import { Dispatch } from 'react-redux'; | ||
| import * as _ from 'lodash-es'; | ||
| import { ActionType as Action, action } from 'typesafe-actions'; | ||
|
|
||
| import { OperatorGroupModel, PackageManifestModel, SelfSubjectAccessReviewModel } from '../models'; | ||
| import { k8sBasePath, ClusterVersionKind, k8sCreate } from '../module/k8s'; | ||
| import { getInfrastructurePlatform } from '@console/shared/src/selectors'; | ||
| import { OperatorGroupModel, PackageManifestModel, SelfSubjectAccessReviewModel, InfrastructureModel } from '../models'; | ||
| import { k8sBasePath, ClusterVersionKind, k8sCreate, k8sGet, K8sResourceKind } from '../module/k8s'; | ||
| import { receivedResources } from './k8s'; | ||
| import { coFetchJSON } from '../co-fetch'; | ||
| import { MonitoringRoutes } from '../reducers/monitoring'; | ||
|
|
@@ -49,6 +49,16 @@ const detectOpenShift = dispatch => coFetchJSON(openshiftPath) | |
| : handleError(err, FLAGS.OPENSHIFT, dispatch, detectOpenShift) | ||
| ); | ||
|
|
||
| const detectBaremetalPlatform = dispatch => | ||
| k8sGet(InfrastructureModel, 'cluster') | ||
| .then( | ||
| (infra: K8sResourceKind) => dispatch(setFlag(FLAGS.BAREMETAL, getInfrastructurePlatform(infra) === 'BareMetal')), | ||
| err => { | ||
| _.get(err, 'response.status') === 404 | ||
| ? dispatch(setFlag(FLAGS.BAREMETAL, false)) | ||
| : handleError(err, FLAGS.BAREMETAL, dispatch, detectBaremetalPlatform); | ||
| }); | ||
|
|
||
| const clusterVersionPath = `${k8sBasePath}/apis/config.openshift.io/v1/clusterversions/version`; | ||
| const detectClusterVersion = dispatch => coFetchJSON(clusterVersionPath) | ||
| .then( | ||
|
|
@@ -212,6 +222,8 @@ const ssarCheckActions = ssarChecks.map(({flag, resourceAttributes, after}) => { | |
|
|
||
| export const detectFeatures = () => (dispatch: Dispatch) => [ | ||
| detectOpenShift, | ||
| // TODO(vojtech): move this flag definition to metal3-plugin via ActionFeatureFlag extension | ||
| detectBaremetalPlatform, | ||
|
||
| detectCanCreateProject, | ||
| detectMonitoringURLs, | ||
| detectClusterVersion, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,16 @@ | ||
| import * as _ from 'lodash'; | ||
| import { Extension } from '@console/plugin-sdk'; | ||
| import { FlagsObject } from '@console/internal/reducers/features'; | ||
|
|
||
| export const getFlagsForExtensions = (extensions: Extension<{required: string}>[]): string[] => | ||
| extensions.map(e => e.properties.required).filter((value, index, self) => self.indexOf(value) === index); | ||
| type DashboardExtension = Extension<{ required: string | string[] }>; | ||
|
|
||
| export const getFlagsForExtensions = (extensions: DashboardExtension[]): string[] => | ||
| extensions.reduce( | ||
| (requiredFlags, e) => _.uniq([...requiredFlags, ..._.castArray(e.properties.required)]), | ||
| [] as string[], | ||
| ); | ||
|
|
||
| export const isDashboardExtensionInUse = (e: DashboardExtension, flags: FlagsObject) => { | ||
| const requiredFlags = _.castArray(e.properties.required); | ||
| return _.every(requiredFlags, (f) => flags[f]); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to just go with
required: string[]IMO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, nevermind. For 4.3 we will have proper plugin gating and using
string | string[]will result in smaller changeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer
string | string[]here to minimize changes in specific plugins.