Skip to content

Conversation

@kraihn
Copy link

@kraihn kraihn commented Nov 14, 2019

This pull request adds support for Azure Blob Storage. Access is provided by an environment variables of the account's Access Token, or an SAS Token within the source URL.

Fixes #33
Replaces #56

@kraihn kraihn changed the title Azure Blob Storage support [WIP] Azure Blob Storage support Nov 14, 2019
@icecog
Copy link

icecog commented Jan 8, 2020

Hey @kraihn,
This would be awesome to get access to, any chance this pull request can be fixed?

@kraihn kraihn changed the title [WIP] Azure Blob Storage support Azure Blob Storage support Feb 7, 2020
@kraihn kraihn force-pushed the azure-blob branch 3 times, most recently from 689e52c to 807710e Compare February 7, 2020 16:28
@kraihn
Copy link
Author

kraihn commented Feb 19, 2020

Can you taken another look @davewongillies?

@kraihn
Copy link
Author

kraihn commented Mar 10, 2020

@azr, can you take a look at my PR? I noticed you've merge a few other PRs recently.

@azr
Copy link
Contributor

azr commented Mar 10, 2020

Hey @kraihn, thanks for opening this ! I think this is a very valuable PR but I'm having conflicting thoughts because of #193. One thing I had in mind would be to split the dependencies into submodules so say:

.
├── cmd
│   └── go-getter
│       ├── go.mod
│       └── go.mod
├── azure
│     ├── getter.go
│     ├── go.mod
│     └── go.mod
├── go.mod
├── go.sum

So that users can decide what they want to do ?

Another thing to note here is that there's now a v2 branch with some breaking changes and if you wanted to apply my suggestion then we'd need to merge this on it, because I don't want to break anything in master, and the full scope of this is going to be a breaking change.

@svennela
Copy link

svennela commented Apr 7, 2020

This is amazing. when will it be available on the main branch? 

pmcatominey and others added 4 commits April 16, 2020 09:48
Adds a Detector and getter for Azure Blob Storage with dependencies on:
github.com/Azure/go-autorest/autorest/azure
github.com/Azure/azure-storage-go

An access key is required for the SDK Client, public blobs should be able to
make use of the http Getter anyway.
@kraihn
Copy link
Author

kraihn commented Apr 16, 2020

Hey @kraihn, thanks for opening this ! I think this is a very valuable PR but I'm having conflicting thoughts because of #193. One thing I had in mind would be to split the dependencies into submodules so say:

.
├── cmd
│   └── go-getter
│       ├── go.mod
│       └── go.mod
├── azure
│     ├── getter.go
│     ├── go.mod
│     └── go.mod
├── go.mod
├── go.sum

So that users can decide what they want to do ?

Another thing to note here is that there's now a v2 branch with some breaking changes and if you wanted to apply my suggestion then we'd need to merge this on it, because I don't want to break anything in master, and the full scope of this is going to be a breaking change.

Hey @azr, I don't write Go for my day job, so any submodule splitting would be out of my comfort zone. This doesn't look to me as though it's breaking anything in master. How long until v2 will be complete? Do you want me to wait for that, or can we merge this into the current version to keep moving?

Comment on lines +25 to +110
//// Parse URL
//accountName, baseURL, containerName, blobPath, accessKey, err := g.parseUrl(u)
//if err != nil {
// return 0, err
//}
//
//client, err := g.getBobClient(accountName, baseURL, accessKey)
//if err != nil {
// return 0, err
//}
//
//container := client.GetContainerReference(containerName)
//
//containerReference := storage.GetContainerReference(containerName)
//blobReference := containerReference.GetBlobReference(c.keyName)
//options := &storage.GetBlobOptions{}
//
//// List the object(s) at the given prefix
//params := storage.ListBlobsParameters{
// Prefix: blobPath,
//}
//resp, err := container.ListBlobs(params)
//if err != nil {
// return 0, err
//}
//
//for _, b := range resp.Blobs {
// // Use file mode on exact match.
// if b.Name == blobPath {
// return ClientModeFile, nil
// }
//
// // Use dir mode if child keys are found.
// if strings.HasPrefix(b.Name, blobPath+"/") {
// return ClientModeDir, nil
// }
//}
//
//// There was no match, so just return file mode. The download is going
//// to fail but we will let Azure return the proper error later.
//return ClientModeFile, nil
//ClientModeFile := nil

// From the Azure portal, get your storage account name and key and set environment variables.
//accountName, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT"), os.Getenv("AZURE_STORAGE_ACCESS_KEY")
//if len(accountName) == 0 || len(accountKey) == 0 {
// log.Fatal("Either the AZURE_STORAGE_ACCOUNT or AZURE_STORAGE_ACCESS_KEY environment variable is not set")
//}
//
//// Create a default request pipeline using your storage account name and account key.
//credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
//if err != nil {
// log.Fatal("Invalid credentials with error: " + err.Error())
//}
//p := azblob.NewPipeline(credential, azblob.PipelineOptions{})
//
//// Create a random string for the quick start container
//containerName := fmt.Sprintf("quickstart-%s", randomString())
//
//// From the Azure portal, get your storage account blob service URL endpoint.
//URL, _ := url.Parse(
// fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName))
//
//// Create a ContainerURL object that wraps the container URL and a request
//// pipeline to make requests.
//containerURL := azblob.NewContainerURL(*URL, p)
//
//// Create the container
//fmt.Printf("Creating a container named %s\n", containerName)
//ctx := context.Background() // This example uses a never-expiring context
//_, err = containerURL.Create(ctx, azblob.Metadata{}, azblob.PublicAccessNone)
//handleErrors(err)
//
//
//
//
//// Here's how to download the blob
//downloadResponse, err := blobURL.Download(ctx, 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false)
//
//// NOTE: automatically retries are performed if the connection fails
//bodyStream := downloadResponse.Body(azblob.RetryReaderOptions{MaxRetryRequests: 20})
//
//// read the body into a buffer
//downloadedData := bytes.Buffer{}
//_, err = downloadedData.ReadFrom(bodyStream)
//handleErrors(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this commented code ? Is this a Work In Progress ? ( Ditto throughout )

Copy link
Contributor

@azr azr Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because the blog getter doesn't allow to download folders ?

"strings"
"log"
"bytes"
//
Copy link
Contributor

@azr azr Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//

@azr
Copy link
Contributor

azr commented Jun 17, 2020

@kraihn, sorry for the lag here, I have been heavily focusing on a Packer release. I think the best option here is to merge this one in master and then we'll take it from there to move it to the v2 branch. Do you want to continue working on this ?

@omerbensaadon
Copy link

This is blocking some work on our Cloud Service Broker project (https://github.com/pivotal/cloud-service-broker), we would sincerely appreciate you accepting this PR into master!

@kraihn
Copy link
Author

kraihn commented Jul 21, 2020

@azr, I would love to see this merged in, but I don’t have the time to continue working on it.

@omerbensaadon
Copy link

@azr we are happy to support work on this in anyway we can on @kraihn's departure...

CC: @svennela @erniebilling

@sylviamoss
Copy link

sylviamoss commented Aug 5, 2020

@omerbensaadon is there anything you need to keep working on this? I can try to help you with that.

For now, it seems that is missing the code for dealing with directories if that's something possible to do with the blob getter. You can see @azr review to understand better where the code is supposed to be.
The overall structure and organization regarding the go-getter core are correct. Other than that, I think is only missing some small code improvements and making sure the blob getter logic is also correct. I believe you have the necessary to test this, right?

@omerbensaadon
Copy link

@sylviamoss thank you for the clarification! We'll get this work prioritized right away!

@azr
Copy link
Contributor

azr commented Aug 17, 2020

Hello @omerbensaadon, really cool ! Is everything working out here, do you need some help ?

@omerbensaadon
Copy link

omerbensaadon commented Aug 18, 2020

@azr thanks for the bump... this is on the roadmap, will be worked sometime in the next few weeks.

Sorry for the confusion, still new to some of this context, hopefully didn't annoy you too much! 😝

@azr
Copy link
Contributor

azr commented Aug 19, 2020

Got it, not annoyed at all on the contrary, I'm pretty happy you want to take care of this 🙂 ! Thanks for your time ! We're always here if you need more help.

@mdeggies mdeggies changed the base branch from master to main October 23, 2020 00:54
@etiennejournet
Copy link

Hi guys ! What is the status of that ? What's the remaining work to be done ?

@djsly
Copy link

djsly commented Aug 5, 2021

@omerbensaadon just to get clarification, I'm guessing pivotal isn't looking at supporting this PR anymore ?

@lockdrew
Copy link

Hi All,

Just wondering if anyone is working on this any more? My team would love to use this to store our modules.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@fmuntean
Copy link

fmuntean commented Jul 1, 2022

Hi All,

Just wondering if anyone is working on this any more? My team would love to use this to store our modules.

Same here! Is anyone still working on adding this support ?

@guidooliveira
Copy link

Is there anything outstanding for this to be approved? I can try to help if necessary.

@larsmaes-sogeti
Copy link

How can I help with this? @azr @davewongillies @kraihn

@larsmaes larsmaes mentioned this pull request Nov 6, 2022
@nrjohnstone
Copy link

wanting to be able to pull modules from blob storage as well....any progress on this?

@crw crw mentioned this pull request Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Azure Blob Storage Support