Ejemplo n.º 1
0
        string GetFetchScript(string workingDirectory, ScriptSyntax syntax)
        {
            AssemblyEmbeddedResources embeddedResources = new AssemblyEmbeddedResources();
            string contextFile;

            switch (syntax)
            {
            case ScriptSyntax.Bash:
                contextFile = "helmFetch.sh";
                break;

            case ScriptSyntax.PowerShell:
                contextFile = "HelmFetch.ps1";
                break;

            default:
                throw new InvalidOperationException("No kubernetes context wrapper exists for " + syntax);
            }

            var k8sContextScriptFile = Path.Combine(workingDirectory, $"Octopus.{contextFile}");
            var contextScript        = embeddedResources.GetEmbeddedResourceText(Assembly.GetExecutingAssembly(), $"Calamari.Integration.Packages.Download.Scripts.{contextFile}");

            fileSystem.OverwriteFile(k8sContextScriptFile, contextScript);
            return(k8sContextScriptFile);
        }
        string CreateContextScriptFile(string workingDirectory, ScriptSyntax syntax)
        {
            string contextFile;

            switch (syntax)
            {
            case ScriptSyntax.Bash:
                contextFile = "KubectlBashContext.sh";
                break;

            case ScriptSyntax.PowerShell:
                contextFile = "KubectlPowershellContext.ps1";
                break;

            default:
                throw new InvalidOperationException("No kubernetes context wrapper exists for " + syntax);
            }

            var k8sContextScriptFile = Path.Combine(workingDirectory, $"Octopus.{contextFile}");
            var contextScript        = embeddedResources.GetEmbeddedResourceText(Assembly.GetExecutingAssembly(), $"Calamari.Kubernetes.Scripts.{contextFile}");

            fileSystem.OverwriteFile(k8sContextScriptFile, contextScript);
            return(k8sContextScriptFile);
        }