Exemple #1
0
        public void Should_Ignore_Entity_With_Ignore_Attribute()
        {
            var crds = CrdGenerator.GenerateCrds(Assembly.GetExecutingAssembly()).ToList();

            crds.Should().NotContain(crd => crd.Spec.Names.Kind == "TestIgnoredEntity");
            crds.Should().Contain(crd => crd.Spec.Names.Kind == "TestSpecEntity");
        }
Exemple #2
0
        public async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            var error = false;
            var crds  = CrdGenerator.GenerateCrds(_resourceTypeService).ToList();
            await app.Out.WriteLineAsync($"Found {crds.Count} CRD's.");

            if (!Force && !Prompt.GetYesNo("Should the uninstall proceed?", false, ConsoleColor.Red))
            {
                return(ExitCodes.Error);
            }

            await app.Out.WriteLineAsync(
                $@"Starting uninstall from the cluster with url ""{_client.ApiClient.BaseUri}"".");

            foreach (var crd in crds)
            {
                await app.Out.WriteLineAsync(
                    $@"Uninstall ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"" from the cluster");

                try
                {
                    try
                    {
                        await _client.Delete(crd);
                    }
                    catch (HttpOperationException e) when(e.Response.StatusCode == HttpStatusCode.NotFound)
                    {
                        await _client.Delete((V1beta1CustomResourceDefinition)crd);
                    }
                }
                catch (HttpOperationException e)
                {
                    await app.Out.WriteLineAsync(
                        $@"There was a http (api) error while uninstalling ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"".");

                    await app.Out.WriteLineAsync(e.Message);

                    await app.Out.WriteLineAsync(e.Response.Content);

                    error = true;
                }
                catch (Exception e)
                {
                    await app.Out.WriteLineAsync(
                        $@"There was an error while uninstalling ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"".");

                    await app.Out.WriteLineAsync(e.Message);

                    error = true;
                }
            }

            return(error ? ExitCodes.Error : ExitCodes.Success);
        }
Exemple #3
0
        public async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            var error = false;
            var crds  = CrdGenerator.GenerateCrds().ToList();
            await app.Out.WriteLineAsync($"Found {crds.Count} CRD's.");

            await app.Out.WriteLineAsync($@"Starting install into cluster with url ""{_client.ApiClient.BaseUri}"".");

            foreach (var crd in crds)
            {
                await app.Out.WriteLineAsync(
                    $@"Install ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"" into the cluster");

                try
                {
                    try
                    {
                        await _client.Save(crd);
                    }
                    catch (HttpOperationException e) when(e.Response.StatusCode == HttpStatusCode.NotFound)
                    {
                        await _client.Save((V1beta1CustomResourceDefinition)crd);
                    }
                }
                catch (HttpOperationException e)
                {
                    await app.Out.WriteLineAsync(
                        $@"There was a http (api) error while installing ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"".");

                    await app.Out.WriteLineAsync(e.Message);

                    await app.Out.WriteLineAsync(e.Response.Content);

                    error = true;
                }
                catch (Exception e)
                {
                    await app.Out.WriteLineAsync(
                        $@"There was an error while installing ""{crd.Spec.Group}/{crd.Spec.Names.Kind}"".");

                    await app.Out.WriteLineAsync(e.Message);

                    error = true;
                }
            }

            return(error ? ExitCodes.Error : ExitCodes.Success);
        }