foreman_puppet 3.0.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d9af296430c3c3ffb44c6744eea7aa8f18cd2cd6b195c73f27f356fb68af1b1
4
- data.tar.gz: 6d75360d29551bacfcc3de197d402bbca296d7662b6b16bc9ebbfbfdb2b201de
3
+ metadata.gz: 7761d1dddaf8e696fe6b367953ec5618ae906d369b56fe5b75dbfacb56c46b63
4
+ data.tar.gz: 0ec6e1ba0db133d84b23b64d69b776671edf68ce26fff816d1b733e8e6ca685b
5
5
  SHA512:
6
- metadata.gz: bc212cd1425120f47123df2f388c560a76676b84c19394cbfb1ef86a7d889bd6e433e1166a222cfa6501a4cbccebfb9d69ead01028db7915d7a57e963e08e7cf
7
- data.tar.gz: 955978e6e835750771a828e0fbc2d44362014e83adfe052c2c4ccaf6258c9ba4e6074d626b2f3403f3756d82c1da9e72c695cfb272e49b521409e4c12fad138f
6
+ metadata.gz: 7114fbf6e9bd9743e7a5a61ccd1e5a83461e9ccbeb69b03173197be66cbca67a7269c108939c7d6b37624bee0bff21ea68d4a7126f7c9f706cee9be59dc4fdb7
7
+ data.tar.gz: 6e66ddc14019c5c92c1ec53dd9fe00565e739ed0b61bc425c589594ce1542a3ad47d41b430b37957a4de995583e1bcbdc04c5191ac54b7da5452bb63f9ddc731
@@ -1,7 +1,7 @@
1
1
  Foreman::Plugin.register :foreman_puppet do
2
- requires_foreman '>= 3.0.0'
2
+ requires_foreman '>= 3.3.0'
3
3
  # Add Global JS file for extending foreman-core components and routes
4
- register_global_js_file 'fills'
4
+ register_global_js_file 'global'
5
5
 
6
6
  settings do
7
7
  category(:facts, N_('Facts')) do
@@ -1,3 +1,3 @@
1
1
  module ForemanPuppet
2
- VERSION = '3.0.6'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
data/package.json CHANGED
@@ -21,17 +21,17 @@
21
21
  "url": "http://projects.theforeman.org/projects/foreman_puppet/issues"
22
22
  },
23
23
  "peerDependencies": {
24
- "@theforeman/vendor": "^8.15.0"
24
+ "@theforeman/vendor": "^10.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@babel/core": "^7.7.0",
28
28
  "@sheerun/mutationobserver-shim": "^0.3.3",
29
- "@theforeman/builder": "^8.15.0",
30
- "@theforeman/eslint-plugin-foreman": "^8.15.0",
31
- "@theforeman/find-foreman": "^8.15.0",
32
- "@theforeman/stories": "^8.15.0",
33
- "@theforeman/test": "^8.15.0",
34
- "@theforeman/vendor-dev": "^8.15.0",
29
+ "@theforeman/builder": "^10.1.0",
30
+ "@theforeman/eslint-plugin-foreman": "^10.1.0",
31
+ "@theforeman/find-foreman": "^10.1.0",
32
+ "@theforeman/stories": "^10.1.0",
33
+ "@theforeman/test": "^10.1.0",
34
+ "@theforeman/vendor-dev": "^10.1.0",
35
35
  "babel-eslint": "^10.0.3",
36
36
  "eslint": "^6.7.2",
37
37
  "jed": "^1.1.1",
@@ -75,8 +75,12 @@ module ForemanPuppet
75
75
  post :create, params: { smart_class_parameter_id: lookup_key.id, override_value: override_value }
76
76
  end
77
77
  response = ActiveSupport::JSON.decode(@response.body)
78
- param_not_posted = (override_value.keys.first.to_s == 'match') ? 'Value' : 'Match' # The opposite of override_value is missing
79
- assert_match(/Validation failed: #{param_not_posted} can't be blank/, response['error']['message'])
78
+ if override_value.keys.first.to_s == 'match'
79
+ # The opposite of override_value is missing and should fail
80
+ assert_match(/Validation failed: Value can't be blank/, response['error']['message'])
81
+ else # match is missing
82
+ assert_match(/Failed to save the record/, response['error']['message'])
83
+ end
80
84
  assert_response :error
81
85
  end
82
86
  end
@@ -110,6 +110,12 @@ module ForemanPuppet
110
110
  end
111
111
 
112
112
  describe '#info puppet bits' do
113
+ test 'ENC YAML omits environment if no puppet facet' do
114
+ host = FactoryBot.build_stubbed(:host)
115
+ enc = host.info
116
+ assert_not_includes enc.keys, 'environment'
117
+ end
118
+
113
119
  test 'ENC YAML uses Classification::ClassParam for parameterized output' do
114
120
  skip 'No idea whats wrong here'
115
121
  host = FactoryBot.build_stubbed(:host, :with_environment)
@@ -0,0 +1,11 @@
1
+ import { registerReducer } from 'foremanReact/common/MountingService';
2
+ import reducers from './src/reducers';
3
+ import { registerFills } from './src/Extends/Fills';
4
+ import { registerLegacy } from './legacy';
5
+
6
+ // register reducers
7
+ registerReducer('puppet', reducers);
8
+ // add fills
9
+ registerFills();
10
+ // TODO: the checkForUnavailablePuppetclasses is very nasty
11
+ registerLegacy();
data/webpack/index.js CHANGED
@@ -2,16 +2,9 @@
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
3
  /* eslint-disable import/extensions */
4
4
  import componentRegistry from 'foremanReact/components/componentRegistry';
5
- import { registerReducer } from 'foremanReact/common/MountingService';
6
- import reducers from './src/reducers';
7
5
  import ForemanPuppet from './src/ForemanPuppet';
8
6
  import { WelcomeEnv } from './src/Components/Environments/Welcome';
9
7
 
10
- // register reducers
11
- Object.entries(reducers).forEach(([key, reducer]) =>
12
- registerReducer(key, reducer)
13
- );
14
-
15
8
  // register components for erb mounting
16
9
  componentRegistry.register({ name: 'WelcomeEnv', type: WelcomeEnv });
17
10
  componentRegistry.register({ name: 'ForemanPuppet', type: ForemanPuppet });
data/webpack/legacy.js ADDED
@@ -0,0 +1,31 @@
1
+ import $ from 'jquery';
2
+ import * as classEditor from './src/foreman_class_edit';
3
+ import * as hostForm from './src/foreman_puppet_host_form';
4
+
5
+ export const registerLegacy = () => {
6
+ window.tfm = Object.assign(window.tfm || {}, {
7
+ classEditor,
8
+ puppetEnc: {
9
+ hostForm,
10
+ },
11
+ });
12
+
13
+ // TODO: the checkForUnavailablePuppetclasses is very nasty
14
+ $(document)
15
+ .on('change', '.hostgroup-select', evt => {
16
+ const form = $('form.host-form')[0];
17
+ if (form && form.dataset.id) hostForm.updatePuppetclasses(evt.target);
18
+ })
19
+ .on('change', '.interface_domain', evt => {
20
+ hostForm.reloadPuppetclassParams();
21
+ })
22
+ .on('change', '.host-architecture-os-select', evt => {
23
+ hostForm.reloadPuppetclassParams();
24
+ })
25
+ .on('ContentLoad', evt => {
26
+ hostForm.checkForUnavailablePuppetclasses();
27
+ });
28
+ $(window).on('load', evt => {
29
+ hostForm.checkForUnavailablePuppetclasses();
30
+ });
31
+ };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { translate as __ } from 'foremanReact/common/I18n';
3
+ import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
4
+ import PuppetTab from '../Host/PuppetTab';
5
+
6
+ const fills = [
7
+ {
8
+ slot: 'host-details-page-tabs',
9
+ name: 'Puppet',
10
+ component: props => <PuppetTab {...props} />,
11
+ weight: 500,
12
+ metadata: { title: __('Puppet') },
13
+ },
14
+ ];
15
+
16
+ export const registerFills = () => {
17
+ fills.forEach(({ slot, name, component: Component, weight, metadata }) =>
18
+ addGlobalFill(
19
+ slot,
20
+ name,
21
+ <Component key={`puppet-fill-${name}`} />,
22
+ weight,
23
+ metadata
24
+ )
25
+ );
26
+ };
@@ -0,0 +1,42 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import { Route, Switch, Redirect } from 'react-router-dom';
4
+ import { route } from './helpers';
5
+ import EmptyPage from './SubTabs/EmptyPage';
6
+ import Reports from './SubTabs/Reports';
7
+
8
+ const SecondaryTabRoutes = ({ hostName, hostInfo, status }) => (
9
+ <Switch>
10
+ <Route path={route('reports')}>
11
+ {hostName ? (
12
+ <Reports hostName={hostName} hostInfo={hostInfo} status={status} />
13
+ ) : (
14
+ <EmptyPage header="Reports" />
15
+ )}
16
+ </Route>
17
+ <Route path={route('assigned')}>
18
+ <EmptyPage header="Assigned classes" />
19
+ </Route>
20
+ <Route path={route('smart-classes')}>
21
+ <EmptyPage header="Smart class parameters" />
22
+ </Route>
23
+ <Route path={route('yaml')}>
24
+ <EmptyPage header="YAML" />
25
+ </Route>
26
+ <Redirect to={route('reports')} />
27
+ </Switch>
28
+ );
29
+
30
+ SecondaryTabRoutes.propTypes = {
31
+ hostName: PropTypes.string,
32
+ hostInfo: PropTypes.object,
33
+ status: PropTypes.string,
34
+ };
35
+
36
+ SecondaryTabRoutes.defaultProps = {
37
+ hostName: '',
38
+ hostInfo: {},
39
+ status: undefined,
40
+ };
41
+
42
+ export default SecondaryTabRoutes;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import PFEmptyPage from 'foremanReact/components/common/EmptyState/EmptyStatePattern';
4
+
5
+ const EmptyPage = ({ header }) => (
6
+ <div className="host-details-tab-item">
7
+ <PFEmptyPage
8
+ icon="enterprise"
9
+ header={header}
10
+ description="This is a demo for adding content to the new host page"
11
+ />
12
+ </div>
13
+ );
14
+
15
+ EmptyPage.propTypes = {
16
+ header: PropTypes.string.isRequired,
17
+ };
18
+
19
+ export default EmptyPage;
@@ -0,0 +1,71 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem/CardTemplate';
4
+ import {
5
+ DescriptionList,
6
+ DescriptionListTerm,
7
+ DescriptionListGroup,
8
+ DescriptionListDescription,
9
+ } from '@patternfly/react-core';
10
+ import SkeletonLoader from 'foremanReact/components/common/SkeletonLoader';
11
+ import DefaultLoaderEmptyState from 'foremanReact/components/HostDetails/DetailsCard/DefaultLoaderEmptyState';
12
+ import { STATUS } from 'foremanReact/constants';
13
+ import { translate as __ } from 'foremanReact/common/I18n';
14
+
15
+ const DescriptionCard = ({ proxyName, caProxy, env, status }) => (
16
+ <CardTemplate header={__('Puppet details')} expandable>
17
+ <DescriptionList isCompact>
18
+ <DescriptionListGroup>
19
+ <DescriptionListTerm>{__('Puppet environment')}</DescriptionListTerm>
20
+ <DescriptionListDescription>
21
+ <SkeletonLoader
22
+ emptyState={<DefaultLoaderEmptyState />}
23
+ status={status}
24
+ >
25
+ {env && (
26
+ <a href={`/foreman_puppet/environments/${env}/edit`}>{env}</a>
27
+ )}
28
+ </SkeletonLoader>
29
+ </DescriptionListDescription>
30
+ </DescriptionListGroup>
31
+ <DescriptionListGroup>
32
+ <DescriptionListTerm>{__('Puppet smart proxy')}</DescriptionListTerm>
33
+ <DescriptionListDescription>
34
+ <SkeletonLoader
35
+ emptyState={<DefaultLoaderEmptyState />}
36
+ status={status}
37
+ >
38
+ {proxyName}
39
+ </SkeletonLoader>
40
+ </DescriptionListDescription>
41
+ </DescriptionListGroup>
42
+ <DescriptionListGroup>
43
+ <DescriptionListTerm>{__('Puppet server CA')}</DescriptionListTerm>
44
+ <DescriptionListDescription>
45
+ <SkeletonLoader
46
+ emptyState={<DefaultLoaderEmptyState />}
47
+ status={status}
48
+ >
49
+ {caProxy}
50
+ </SkeletonLoader>
51
+ </DescriptionListDescription>
52
+ </DescriptionListGroup>
53
+ </DescriptionList>
54
+ </CardTemplate>
55
+ );
56
+
57
+ DescriptionCard.propTypes = {
58
+ caProxy: PropTypes.string,
59
+ env: PropTypes.string,
60
+ proxyName: PropTypes.string,
61
+ status: PropTypes.string,
62
+ };
63
+
64
+ DescriptionCard.defaultProps = {
65
+ caProxy: undefined,
66
+ env: undefined,
67
+ proxyName: undefined,
68
+ status: STATUS.PENDING,
69
+ };
70
+
71
+ export default DescriptionCard;
@@ -0,0 +1,45 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import { Grid, GridItem } from '@patternfly/react-core';
4
+ import ReportsTab from 'foremanReact/components/HostDetails/Tabs/ReportsTab';
5
+ import DescriptionCard from './components/DescriptionCard';
6
+ import './styles.scss';
7
+
8
+ const Reports = ({
9
+ hostName,
10
+ status,
11
+ hostInfo: {
12
+ puppet_proxy_name: proxyName,
13
+ puppet_ca_proxy_name: caProxy,
14
+ environment_name: env,
15
+ },
16
+ }) => (
17
+ <div className="report-tab">
18
+ <Grid hasGutter>
19
+ <GridItem span={4}>
20
+ <DescriptionCard
21
+ proxyName={proxyName}
22
+ caProxy={caProxy}
23
+ env={env}
24
+ status={status}
25
+ />
26
+ </GridItem>
27
+ <GridItem span={12}>
28
+ <ReportsTab hostName={hostName} origin="Puppet" />
29
+ </GridItem>
30
+ </Grid>
31
+ </div>
32
+ );
33
+
34
+ Reports.propTypes = {
35
+ hostName: PropTypes.string.isRequired,
36
+ hostInfo: PropTypes.object,
37
+ status: PropTypes.string,
38
+ };
39
+
40
+ Reports.defaultProps = {
41
+ hostInfo: {},
42
+ status: undefined,
43
+ };
44
+
45
+ export default Reports;
@@ -0,0 +1,7 @@
1
+ .report-tab {
2
+ padding: 16px 24px;
3
+
4
+ .pf-c-card {
5
+ height: 100%;
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ import { translate as __ } from 'foremanReact/common/I18n';
2
+
3
+ export const SECONDARY_TABS = [
4
+ { key: 'reports', title: __('Reports') },
5
+ { key: 'assigned', title: __('Assigned classes') },
6
+ { key: 'smart-classes', title: __('Smart class parameters') },
7
+ { key: 'yaml', title: __('YAML') },
8
+ ];
@@ -0,0 +1,3 @@
1
+ export const hashRoute = subpath => `#/Puppet/${subpath}`;
2
+ export const route = subpath => hashRoute(subpath).substring(1);
3
+ export const activeTab = path => path.split('/')[2];
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useHistory } from 'react-router-dom';
4
+ import { Tabs, Tab, TabTitleText } from '@patternfly/react-core';
5
+ import { STATUS } from 'foremanReact/constants';
6
+
7
+ import SecondaryTabRoutes from './Routes';
8
+ import { activeTab } from './helpers';
9
+ import { SECONDARY_TABS } from './constants';
10
+
11
+ const PuppetTab = ({ response, status, location: { pathname } }) => {
12
+ const hashHistory = useHistory();
13
+ return (
14
+ <>
15
+ <Tabs
16
+ className="margin-0-24"
17
+ onSelect={(evt, subTab) => hashHistory.push(subTab)}
18
+ isSecondary
19
+ activeKey={activeTab(pathname)}
20
+ >
21
+ {SECONDARY_TABS.map(({ key, title }) => (
22
+ <Tab
23
+ key={key}
24
+ eventKey={key}
25
+ title={<TabTitleText>{title}</TabTitleText>}
26
+ />
27
+ ))}
28
+ </Tabs>
29
+ <SecondaryTabRoutes
30
+ hostName={response.name}
31
+ hostInfo={response}
32
+ status={status}
33
+ />
34
+ </>
35
+ );
36
+ };
37
+
38
+ PuppetTab.propTypes = {
39
+ response: PropTypes.object,
40
+ status: PropTypes.string,
41
+ location: PropTypes.shape({
42
+ pathname: PropTypes.string,
43
+ }),
44
+ };
45
+ PuppetTab.defaultProps = {
46
+ location: { pathname: '' },
47
+ response: { name: '' },
48
+ status: STATUS.PENDING,
49
+ };
50
+
51
+ export default PuppetTab;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-28 00:00:00.000000000 Z
12
+ date: 2022-05-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Allow assigning Puppet environments and classes to the Foreman Hosts.
15
15
  email:
@@ -332,9 +332,19 @@ files:
332
332
  - webpack/__mocks__/foremanReact/redux/actions/toasts.js
333
333
  - webpack/__mocks__/foremanReact/redux/index.js
334
334
  - webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js
335
- - webpack/fills_index.js
335
+ - webpack/global_index.js
336
336
  - webpack/index.js
337
+ - webpack/legacy.js
337
338
  - webpack/src/Components/Environments/Welcome.js
339
+ - webpack/src/Extends/Fills/index.js
340
+ - webpack/src/Extends/Host/PuppetTab/Routes.js
341
+ - webpack/src/Extends/Host/PuppetTab/SubTabs/EmptyPage.js
342
+ - webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/components/DescriptionCard.js
343
+ - webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/index.js
344
+ - webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/styles.scss
345
+ - webpack/src/Extends/Host/PuppetTab/constants.js
346
+ - webpack/src/Extends/Host/PuppetTab/helpers.js
347
+ - webpack/src/Extends/Host/PuppetTab/index.js
338
348
  - webpack/src/ForemanPuppet.js
339
349
  - webpack/src/Router/__snapshots__/routes.test.js.snap
340
350
  - webpack/src/Router/index.js
@@ -1,30 +0,0 @@
1
- import $ from 'jquery';
2
-
3
- import * as classEditor from './src/foreman_class_edit';
4
- import * as hostForm from './src/foreman_puppet_host_form';
5
-
6
- window.tfm = Object.assign(window.tfm || {}, {
7
- classEditor,
8
- puppetEnc: {
9
- hostForm,
10
- },
11
- });
12
-
13
- // TODO: the checkForUnavailablePuppetclasses is very nasty
14
- $(document)
15
- .on('change', '.hostgroup-select', evt => {
16
- const form = $('form.host-form')[0];
17
- if (form && form.dataset.id) hostForm.updatePuppetclasses(evt.target);
18
- })
19
- .on('change', '.interface_domain', evt => {
20
- hostForm.reloadPuppetclassParams();
21
- })
22
- .on('change', '.host-architecture-os-select', evt => {
23
- hostForm.reloadPuppetclassParams();
24
- })
25
- .on('ContentLoad', evt => {
26
- hostForm.checkForUnavailablePuppetclasses();
27
- });
28
- $(window).on('load', evt => {
29
- hostForm.checkForUnavailablePuppetclasses();
30
- });