From df3a1c17614e0f72386154d81740449b90c29c8f Mon Sep 17 00:00:00 2001 From: MikeLarah Date: Thu, 8 Oct 2020 16:36:45 +0000 Subject: [PATCH] Added hack to fix issue with porter storage plugin --- .devcontainer/Dockerfile | 4 +++- docker/Dockerfile | 8 +++++++- pkg/run/run.go | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8b5d59b..0b58dbc 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -62,4 +62,6 @@ ENV GO111MODULE=auto # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends \ No newline at end of file +# && apt-get -y install --no-install-recommends + +RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 34777a9..2b32424 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,7 +18,13 @@ ENV TOOLHOME="/usr/local/bin" ENV PORTER_HOME="${TOOLHOME}/.porter" ENV PATH=$PATH:$PORTER_HOME -RUN apk add --update curl coreutils libc6-compat && rm -rf /var/cache/apk/* +# TODO: remove 'make bash py-pip' when porter storage issue is fixed +RUN apk add --update make bash py-pip curl coreutils libc6-compat && rm -rf /var/cache/apk/* + +# Install az cli (TODO: remove when porter storage issue is fixed) +RUN apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python3-dev \ + && pip install azure-cli \ + && apk del --purge build # Install porter RUN mkdir -p $PORTER_HOME \ diff --git a/pkg/run/run.go b/pkg/run/run.go index 2cb225e..861c2c6 100644 --- a/pkg/run/run.go +++ b/pkg/run/run.go @@ -35,6 +35,9 @@ type parameterSet struct { //Run runs Porter with the Azure driver, using environment variables func Run() error { + // Hack to get around issue with Porter not liking an empty blob container without a schema file in + uploadSchema() + config, err := getConfig() if err != nil { log.Fatalf("%s\n", err) @@ -58,6 +61,21 @@ func Run() error { return nil } +func uploadSchema() { + tempDir, _ := ioutil.TempDir("", "cnabarmdriver") + schemaFilePath := path.Join(tempDir, "schema") + schemaFile := `{"claims":"cnab-claim-1.0.0-DRAFT+b5ed2f3","credentials":"cnab-credentialsets-1.0.0-DRAFT+b6c701f","parameters":"cnab-parametersets-1.0.0-DRAFT+TODO"}` + ioutil.WriteFile(schemaFilePath, []byte(schemaFile), 0644) + cmd := exec.Command("az", "storage", "blob", "upload", "--connection-string", os.Getenv("AZURE_STORAGE_CONNECTION_STRING"), "--container-name", "porter", "--name", "schema", "--file", schemaFilePath) + log.Println(cmd.String()) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + log.Fatalf("porter command failed with %s\n", err) + } +} + func buildPorterCommandParams(cnabInstallationName string, cnabAction string, cnabBundleTag string) []string { credsPath, err := generateCredsFile(cnabInstallationName) if err != nil {