Example #1
0
 def test_update_release(self, _0, _1, mock_release_service_stub):
     mock_release_service_stub.UpdateRelease.return_value = True
     mock_release_service_stub.GetReleaseStatus.return_value = dotify(
         {'namespace': 'testing'})
     t = tiller.Tiller('test').update_release('foo', '', install=True)
     tiller.Tiller._logger.warn.assert_called()
     self.assertTrue(t)
Example #2
0
 def test_update_release(self, _0, _1, mock_release_service_stub):
     mock_release_service_stub.UpdateRelease.return_value = True
     mock_release_service_stub.GetReleaseStatus.return_value = dotify(
         {"namespace": "testing"}
     )
     t = tiller.Tiller("test").update_release("foo", "", install=True)
     tiller.Tiller._logger.warn.assert_called()
     self.assertTrue(t)
Example #3
0
 def test_chart_cleanup_no_releases(self, _0, mock_list, mock_uninstall):
     mock_list.return_value = [dotify({"name": "test-baz"})]
     tiller.Tiller("test").chart_cleanup(
         "test",
         [{"chart": {"release_name": "foo"}}, {"chart": {"release_name": "bar"}},],
     )
     tiller.Tiller._logger.debug.assert_called()
     mock_uninstall.assert_called_once_with("test-baz")
    def __init__(self, opts, sites, parsername='', config_data={}):
        if HasPyhelm:
            super.__init__(opts, sites, parsername)
            self._host = config_data.get('host', 'localhost')
            self._port = config_data.get('port', '8069')
            self._resource_name = config_data.get('resource_name', '')
            self._chart = config_data.get('chart', {})
            self._values = config_data.get('values', {})
            self._namespace = config_data.get('namespace', 'default')

            self._tserver = tiller.Tiller(self.host, self.port)
Example #5
0
 def test_list_releases(self, _0, mock_release_service_stub):
     mock_release_service_stub.return_value.ListReleases.return_value = [
         dotify({
             'next': '',
             'releases': ['foo']
         })
     ]
     r = tiller.Tiller('test').list_releases()
     mock_release_service_stub.return_value.ListReleases.assert_called()
     self.assertEquals(len(r), 1)
     self.assertEquals(r[0], 'foo')
Example #6
0
 def test_list_charts(self, _0, mock_list_releases):
     mock_list_releases.return_value = [
         dotify({
             'name': 'foo',
             'version': '0.1.0',
             'chart': 'bar',
             'config': {
                 'raw': 'foo: bar'
             }
         })
     ]
     charts = tiller.Tiller('test').list_charts()
     self.assertEquals(len(charts), 1)
     self.assertEquals(charts[0], ('foo', '0.1.0', 'bar', 'foo: bar'))
Example #7
0
 def test_list_charts(self, _0, mock_list_releases):
     mock_list_releases.return_value = [
         dotify(
             {
                 "name": "foo",
                 "version": "0.1.0",
                 "chart": "bar",
                 "config": {"raw": "foo: bar"},
             }
         )
     ]
     charts = tiller.Tiller("test").list_charts()
     self.assertEqual(len(charts), 1)
     self.assertEqual(charts[0], ("foo", "0.1.0", "bar", "foo: bar"))
Example #8
0
 def test_chart_cleanup_no_releases(self, _0, mock_list, mock_uninstall):
     mock_list.return_value = [dotify({'name': 'test-baz'})]
     tiller.Tiller('test').chart_cleanup('test', [
         {
             'chart': {
                 'release_name': 'foo'
             }
         },
         {
             'chart': {
                 'release_name': 'bar'
             }
         },
     ])
     tiller.Tiller._logger.debug.assert_called()
     mock_uninstall.assert_called_once_with('test-baz')
Example #9
0
 def test_list_releases_with_namespace(
     self, _0, mock_list_release_request, mock_release_service_stub
 ):
     mock_release_service_stub.return_value.ListReleases.return_value = [
         dotify({"next": "", "releases": ["foo"]})
     ]
     r = tiller.Tiller("test").list_releases(namespace="test")
     mock_list_release_request.assert_called_with(
         limit=tiller.RELEASE_LIMIT,
         offset=None,
         filter="",
         namespace="test",
         status_codes=[],
     )
     mock_release_service_stub.return_value.ListReleases.assert_called()
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0], "foo")
Example #10
0
 def test_list_releases_with_namespace(self, _0, mock_list_release_request,
                                       mock_release_service_stub):
     mock_release_service_stub.return_value.ListReleases.return_value = [
         dotify({
             'next': '',
             'releases': ['foo']
         })
     ]
     r = tiller.Tiller('test').list_releases(namespace="test")
     mock_list_release_request.assert_called_with(
         limit=tiller.RELEASE_LIMIT,
         offset=None,
         namespace="test",
         status_codes=[])
     mock_release_service_stub.return_value.ListReleases.assert_called()
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0], 'foo')
Example #11
0
 def test_list_releases_with_status_codes(
     self, _0, mock_list_release_request, mock_release_service_stub
 ):
     mock_release_service_stub.return_value.ListReleases.return_value = [
         dotify({"next": "", "releases": ["foo"]})
     ]
     r = tiller.Tiller("test").list_releases(status_codes=["DEPLOYED", "FAILED"])
     # See status code enum definition in hapi/status_pb2.py
     mock_list_release_request.assert_called_with(
         limit=tiller.RELEASE_LIMIT,
         offset=None,
         filter="",
         namespace="",
         status_codes=[1, 4],
     )
     mock_release_service_stub.return_value.ListReleases.assert_called()
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0], "foo")
Example #12
0
 def test_list_releases_with_status_codes(self, _0,
                                          mock_list_release_request,
                                          mock_release_service_stub):
     mock_release_service_stub.return_value.ListReleases.return_value = [
         dotify({
             'next': '',
             'releases': ['foo']
         })
     ]
     r = tiller.Tiller('test').list_releases(
         status_codes=["DEPLOYED", "FAILED"])
     # See status code enum definition in hapi/status_pb2.py
     mock_list_release_request.assert_called_with(
         limit=tiller.RELEASE_LIMIT,
         offset=None,
         namespace="",
         status_codes=[1, 4])
     mock_release_service_stub.return_value.ListReleases.assert_called()
     self.assertEqual(len(r), 1)
     self.assertEqual(r[0], 'foo')
Example #13
0
def main():
    """The main function."""
    module = AnsibleModule(
        argument_spec=dict(
            host=dict(type='str', default='localhost'),
            port=dict(type='int', default=44134),
            name=dict(type='str', default=''),
            chart=dict(type='dict'),
            state=dict(
                choices=['absent', 'purged', 'present'],
                default='present'
            ),
            # Install options
            values=dict(type='dict'),
            namespace=dict(type='str', default='default'),

            # Uninstall options
            disable_hooks=dict(type='bool', default=False),
        ),
        supports_check_mode=True)

    if not HAS_PYHELM:
        module.fail_json(msg="Could not import the pyhelm python module. "
                         "Please install `pyhelm` package.")

    host = module.params['host']
    port = module.params['port']
    state = module.params['state']
    tserver = tiller.Tiller(host, port)

    if state == 'present':
        rst = install(module, tserver)

    if state in 'absent':
        rst = delete(module, tserver)

    if state in 'purged':
        rst = delete(module, tserver, True)

    module.exit_json(**rst)
Example #14
0
def main():
    """The main function."""
    module = AnsibleModule(
        argument_spec=dict(
            host=dict(type='str', default='localhost'),
            port=dict(type='int', default=44134),
            name=dict(type='str', default=''),
            chart=dict(type='dict'),
            state=dict(
                choices=['absent', 'purged', 'present'],
                default='present'
            ),
            # Install options
            values=dict(type='dict'),
            namespace=dict(type='str', default='default'),

            # Uninstall options
            disable_hooks=dict(type='bool', default=False),
        ),
        supports_check_mode=True)

    if HELM_IMPORT_ERR:
        module.fail_json(msg=missing_required_lib('pyhelm'), exception=HELM_IMPORT_ERR)

    host = module.params['host']
    port = module.params['port']
    state = module.params['state']
    tserver = tiller.Tiller(host, port)

    if state == 'present':
        rst = install(module, tserver)

    if state in 'absent':
        rst = delete(module, tserver)

    if state in 'purged':
        rst = delete(module, tserver, True)

    module.exit_json(**rst)
Example #15
0
 def test_get_release_content(self, _0, mock_release_service_stub):
     mock_release_service_stub.GetReleaseContent.return_value = True
     t = tiller.Tiller('test').get_release_content('foo')
     self.assertTrue(t)
Example #16
0
 def test_uninstall_release(self, _0, mock_release_service_stub):
     mock_release_service_stub.UninstallRelease.return_value = True
     t = tiller.Tiller('test').uninstall_release('foo')
     self.assertTrue(t)
Example #17
0
 def test_list_releases(self, _0, mock_release_service_stub):
     mock_release_service_stub.ListReleases.return_value = iter([])
     tiller.Tiller('test').list_releases()
Example #18
0
 def test_tiller_status(self, _0):
     t1 = tiller.Tiller('')
     self.assertFalse(t1.tiller_status())
     t2 = tiller.Tiller('test')
     self.assertTrue(t2.tiller_status())
Example #19
0
 def test_get_channel(self, mock_grpc):
     tiller.Tiller('test')
     mock_grpc.insecure_channel.assert_called()
Example #20
0
 def test_get_channel_secure(self, mock_grpc):
     mock_tls = mock.MagicMock(name="tls_config", spec=tls.TlsConfig)
     tiller.Tiller("test", tls_config=mock_tls)
     mock_grpc.secure_channel.assert_called()
Example #21
0
 def test_get_release_status(self, _0, mock_release_service_stub):
     mock_release_service_stub.GetReleaseStatus.return_value = True
     t = tiller.Tiller("test").get_release_status("foo")
     self.assertTrue(t)
Example #22
0
 def test_install_release(self, _0, _1, mock_release_service_stub):
     mock_release_service_stub.InstallRelease.return_value = True
     t = tiller.Tiller("test").install_release("foo", "test")
     self.assertTrue(t)