Skip to content

[WIP]Add support of GitHub as deployment option#1121

Closed
metacpp wants to merge 8 commits into
masterfrom
github_scm
Closed

[WIP]Add support of GitHub as deployment option#1121
metacpp wants to merge 8 commits into
masterfrom
github_scm

Conversation

@metacpp

@metacpp metacpp commented Apr 14, 2018

Copy link
Copy Markdown
Contributor

Still work in progress

Support GitHub as deployment option for azure web app, the workflow will be:

  1. Generate Personal Access Token (read permission in both org and repo) to authorize Web App to access repo.
  2. Set SCM Type as GitHub.
  3. Set URL of repo and branch.

Will add example usage and tests in this PR very soon.

metacpp added 2 commits April 12, 2018 23:17
1. Add update operation for source_control and external_scm_credential.
2. Refactor the code logic of expand and flatten functions.
@metacpp

metacpp commented Apr 14, 2018

Copy link
Copy Markdown
Contributor Author

This PR is used to resolve #1104 , which is opened by @istairbn

@tombuildsstuff tombuildsstuff modified the milestones: 1.4.0, Soon Apr 16, 2018

@tombuildsstuff tombuildsstuff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hey @metacpp

I've taken a look through and left some comments in-line - before proceeding any further (e.g. tests/docs etc) with this PR we should focus on working out how the schema needs to look, in particular I don't believe we need the external_scm_credentials block at all since it can be in-lined into the VCS URI?

Thanks!


"source_control": {
Type: schema.TypeList,
Optional: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

neither of these fields can currently be specified by the user, so there's no need to make this optional at the moment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In GitHub scenario, you need to specify the repo URL and branch name for Azure Web App to consume. It's not the same scenario as LocalGit, which will automatically generate the SCM URL hosted on Azure web app. I will update the example usage for GitHub scenario, then you will know what's the workflow.

Comment thread azurerm/resource_arm_app_service.go Outdated
},
},

"external_scm_credential": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't believe we don't need a separate block for this - as mentioned in this comment it can be part of the Repository URI in the source_control block, which will cover all cases. As such - can we remove this?

@metacpp metacpp Apr 16, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to allow end-user to set personal access token which will authorize Azure web app to access repo and org information through API way. In other words, this is the token required by Azure to integrate with any 3rd party deployment options.

We may have a better naming here, what's your suggestion ?

Comment thread azurerm/resource_arm_app_service.go Outdated
"name": {
Type: schema.TypeString,
Computed: true,
Default: "GitHub",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in cases such as this (where this is within an Optional sub-object) - we can make this Required. We should also remove the Default value and Computed here, since it needs to be user specified

}

func flattenAppServiceSiteCredential(input *web.UserProperties) []interface{} {
func flattenAppServiceSiteCredential(input *web.User) []interface{} {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should be pulling from the UserProperties object since the non-Properties object isn't actually valid in Azure (e.g. it doesn't actually match the schema and can be nil in older configurations)

@metacpp metacpp Apr 16, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

User is using embedding with UserProperties, you can directly access any field in User object.

return scmRet
}

func flattenAppServiceSourceControl(input *web.SiteSourceControl) []interface{} {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should be pulling from the SiteSourceControlProperties object since the non-Properties object isn't actually valid in Azure (e.g. it doesn't actually match the schema and can be nil in older configurations)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Internal Go SDK is using SiteSourceControl as returned type and SiteSourceControlProperties is embedded class, which means that you can access all the fields in SiteSourceControl. It's meaningless to do any kind of de-referencing before flattening.

I don't understand what's your concern here, maybe a more concrete example ?

@tombuildsstuff tombuildsstuff Apr 17, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

at this point in time, from memory that representation has changed in the past such that the top level can be nil vs the properties object being populated - that's not how it's represented in the JSON Response so we should match that where possible (which we do throughout the provider)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no any API return SiteSourceControlProperties, instead, it's SiteSourceControl.
If SiteSourceControl is nil, then you will not be able to get SiteSourceControlProperties, since they're the same object but different layer.

@metacpp

metacpp commented Apr 16, 2018

Copy link
Copy Markdown
Contributor Author

@tombuildsstuff external_scm_credential is personal access token used by azure behind the scene to access org and repo information. It's not like the azure its own repo, there's no chance for any CI pipeline to directly access the repo hosted on GitHub. It's completely different scenario.

@metacpp metacpp requested a review from JunyiYi April 16, 2018 20:47
@metacpp metacpp self-assigned this Apr 18, 2018
@metacpp metacpp added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label May 2, 2018
@metacpp

metacpp commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

This PR does have dependencies on #2910 and #1661.

@metacpp

metacpp commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

And for the personal token type, we have weak dependency on #2946

@metacpp metacpp modified the milestones: Soon, 1.7.0 Jun 10, 2018
@katbyte katbyte modified the milestones: 1.7.0, Soon Jun 12, 2018
@tombuildsstuff

Copy link
Copy Markdown
Contributor

@metacpp what's the status of this PR - it's been a WIP for a while and has merge conflicts?

@tombuildsstuff

Copy link
Copy Markdown
Contributor

@metacpp since we've not heard back from you here (and there's merge conflicts) - I'm going to close this PR for the moment; please feel free to re-open it if this is being actively worked on.

Thanks!

@tombuildsstuff tombuildsstuff modified the milestones: Soon, Being Sorted Oct 25, 2018
@tombuildsstuff tombuildsstuff deleted the github_scm branch October 27, 2018 20:00
@ghost

ghost commented Mar 6, 2019

Copy link
Copy Markdown

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
@ghost ghost removed the waiting-response label Mar 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement service/app-service upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants