Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a (hidden, for now) show command for tooling use #616

Merged
merged 10 commits into from
Sep 21, 2022

Conversation

ellismg
Copy link
Member

@ellismg ellismg commented Sep 8, 2022

This change adds a new hidden command, show, which must be run with --output json to do anything. When run like this, azd show collects information about the project and presents it in a way suitable for consumption by tooling.

We include information about each service, including the language type and path to the project as well as the target resource in Azure that will be deployed to, if we can determine it (if you haven't yet run azd provision or there is some other transient error, this information will be missing from the resulting JSON).

An example (before provisioning):

C:\dd\azure\azure-dev\cli\azd\test\samples\webapp>azd show --output json
{
  "services": {
    "web": {
      "project": {
        "path": "C:\\dd\\azure\\azure-dev\\cli\\azd\\test\\samples\\webapp\\src\\dotnet\\webapp.csproj",
        "type": "dotnet"
      }
    }
  }
}

After:

C:\dd\azure\azure-dev\cli\azd\test\samples\webapp>azd show --output json
{
  "services": {
    "web": {
      "project": {
        "path": "C:\\dd\\azure\\azure-dev\\cli\\azd\\test\\samples\\webapp\\src\\dotnet\\webapp.csproj",
        "type": "dotnet"
      },
      "target": {
        "resourceIds": ["/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/rg-matell-tst-shw/providers/Microsoft.Web/sites/app-t4e7rfh6jsb5u"]
      }
    }
  }
}

@vijayrkn and @abpiskunov, I made some slight changes to the format we were discussing in #241 but this should contain all the information you need. Is this going to be suitable or do you prefer services to be an array instead of a map, with a name property? This felt slightly more jq-able, so I went with that, but not wed to the output format.

@ellismg ellismg self-assigned this Sep 8, 2022
@ellismg ellismg modified the milestones: Release 0.3, Release 0.2 Sep 8, 2022
@ellismg ellismg force-pushed the ellismg/add-hidden-show branch 3 times, most recently from d7eb333 to c630250 Compare September 9, 2022 20:47
@ellismg ellismg marked this pull request as ready for review September 9, 2022 23:23
Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Command looks good but have some questions around implementation.

cli/azd/pkg/project/project_config.go Outdated Show resolved Hide resolved
@azure-sdk
Copy link
Collaborator

Azure Dev CLI Install Instructions

Install scripts

MacOS/Linux

May elevate using sudo on some platforms and configurations

bash:

curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/install-azd.sh | bash -s -- --base-url https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616 --version '' --verbose

pwsh:

Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/uninstall-azd.ps1' -OutFile uninstall-azd.ps1; ./uninstall-azd.ps1
Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/install-azd.ps1' -OutFile install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616' -Version '' -Verbose

Windows

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/uninstall-azd.ps1' > uninstall-azd.ps1; ./uninstall-azd.ps1;"
powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/616' -Version '' -Verbose;"

Standalone Binary

Container

docker run -it azdevcliextacr.azurecr.io/azure-dev:pr-616

@ellismg
Copy link
Member Author

ellismg commented Sep 15, 2022

@abpiskunov, could you confirm that the output here has all the information you need to unblock the VS work?

@abpiskunov
Copy link
Collaborator

we can work with that format - yes.

@ellismg
Copy link
Member Author

ellismg commented Sep 16, 2022

@wbreza Please take a look again when you have a moment - would love to have this in the next release to make it easier for VS to consume.

cli/azd/cmd/show.go Outdated Show resolved Hide resolved
Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Added a few non-blocking additional comments. I think this is fine for now but we'll need to continue work on splitting out some expectations on our Project vs ProjectConfig so it is easier to move these type of framework or service target concerns back into their respective components.

cli/azd/cmd/show.go Outdated Show resolved Hide resolved
cli/azd/pkg/project/service.go Show resolved Hide resolved
cli/azd/cmd/show.go Outdated Show resolved Hide resolved
cli/azd/cmd/show.go Outdated Show resolved Hide resolved
This makes the set of values smaller and doesn't use the word
"language" which can be sort of confusing when it's set to something
like "dotnet".

As part of this, we normalize the output so that `type` is always one
of `dotnet`, `python` or `node` to make consumers lives easier.
Consumers like Visual Studio need to understand the project file that
is assocated with a dotnet service, not just the path to the directory
the service lives in.

Initially, this logic was in it the project reader (which builds a
ProjectConfig), but that felt like the wrong location for the
logic. We can't add this logic to `ProjectConfig::GetProject` because
that call fails when the infrastructure for an appliaction has not
been provisioned, and we want `azd show` to work even in that case.

Longer term we should look into something that allows `GetProject` to
work evern when infrastructure is not created, and at that point move
this logic there, but for now we have this as a specific
implementation detail of the show command.
@vhvb1989
Copy link
Member

/check-enforcer override

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.

None yet

8 participants