Skip to content

Commit

Permalink
Added hack to fix issue with porter storage plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeEvansLarah committed Oct 8, 2020
1 parent 0074c82 commit df3a1c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your-package-list-here>
# && apt-get -y install --no-install-recommends <your-package-list-here>

RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
8 changes: 7 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
18 changes: 18 additions & 0 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit df3a1c1

Please sign in to comment.