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

Round out --use scenario (add "use" sub-command, add local file, add .bacpac / .mdf & .ldf / compressed file support) #319

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0e6223f
Round out --use scenario
stuartpa Apr 6, 2023
f0b9f3b
Adding unit test coverage
stuartpa Apr 6, 2023
0a8ac1c
Saving changes
stuartpa Apr 26, 2023
964fcb8
Saving changes
stuartpa Apr 27, 2023
8579e37
Saving changes
stuartpa Apr 28, 2023
44d82f0
Saving changes
stuartpa Apr 28, 2023
a47d898
Saving changes
stuartpa May 3, 2023
a6b0d83
Saving changes
stuartpa May 3, 2023
abff8b6
Saving changes
stuartpa May 5, 2023
e70df94
Merge branch 'main' into stuartpa/sqlcmd-urls
stuartpa May 22, 2023
99a9267
Merge main
stuartpa May 31, 2023
4b895c1
Skip test to get signed build
stuartpa Jun 7, 2023
888a487
Enable build for Linux
stuartpa Jun 7, 2023
1ce062a
Create destFolder for local file
stuartpa Jun 8, 2023
cdd40f2
Add support Azure Storage SAS URLs)
stuartpa Jun 8, 2023
8b8ef64
Add-ons initial
stuartpa Dec 23, 2023
9e745c0
Saving changes
stuartpa Dec 24, 2023
a1ca145
Merge conflicts
stuartpa Dec 26, 2023
7cf2691
Merged add-ons
stuartpa Dec 26, 2023
ec08c06
Merged add-ons
stuartpa Dec 26, 2023
1b5a4c3
Add-on fleet-manager
stuartpa Dec 29, 2023
7c78a44
Add-on fleet-manager
stuartpa Dec 29, 2023
d42b514
sqlcmd create --use https://*.git working
stuartpa Jan 10, 2024
9209cad
sqlcmd deploy
stuartpa Feb 1, 2024
5233a42
Added .sqlcmd/sqlcmd.yaml support
stuartpa Feb 7, 2024
d9b0993
Added .sqlcmd/sqlcmd.yaml support
stuartpa Feb 7, 2024
7525053
Add azd as a tool
stuartpa Feb 10, 2024
9282eaa
adding mac support
stuartpa Feb 11, 2024
12c2f73
Tested Mac support
Feb 12, 2024
cb34e92
Merge branch 'stuartpa/sqlcmd-urls' of https://github.com/microsoft/g…
Feb 12, 2024
e95442a
Mac support
stuartpa Feb 12, 2024
7c4472f
Fix Mac issue
Feb 12, 2024
e1a6bdb
Remove customer go-sqlcmddb
stuartpa Feb 13, 2024
d4a205e
Remove customer go-sqlcmddb
stuartpa Feb 13, 2024
7ffd5e9
Add linux stubs
stuartpa Feb 14, 2024
f26a522
Add linux stubs
stuartpa Feb 14, 2024
91584e4
Fix panic when ads not installed
stuartpa Feb 22, 2024
d6531a1
Upgrade to go 1.20 required
stuartpa Feb 22, 2024
b708505
Upgrade to go 1.20 required
stuartpa Feb 22, 2024
17093e9
Fix issue with keyvault not being excluded on non windows os
stuartpa Feb 22, 2024
2cc4c97
Remove TEMP output if azd init not run
stuartpa Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: '1.20'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.20
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: '1.20'
- name: Run tests against Linux SQL
run: |
go version
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/include-install-go-tools.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
- task: GoTool@0
inputs:
version: '1.18'
version: '1.20'
- task: Go@0
displayName: 'Go: get dependencies'
inputs:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Use `sqlcmd` to create SQL Server and Azure SQL Edge instances using a local con
To create a local SQL Server instance with the AdventureWorksLT database restored, query it, and connect to it using Azure Data Studio, run:

```
sqlcmd create mssql --accept-eula --using https://aka.ms/AdventureWorksLT.bak
sqlcmd create mssql --accept-eula --use https://aka.ms/AdventureWorksLT.bak
sqlcmd query "SELECT DB_NAME()"
sqlcmd open ads
```
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines/build-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parameters:
steps:
- task: GoTool@0
inputs:
version: '1.18'
version: '1.20'
goBin: $(Build.SourcesDirectory)

- task: Go@0
Expand Down
8 changes: 6 additions & 2 deletions cmd/modern/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/microsoft/go-sqlcmd/internal/output"
"github.com/microsoft/go-sqlcmd/internal/output/verbosity"
"github.com/microsoft/go-sqlcmd/internal/pal"
"github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer"
"github.com/microsoft/go-sqlcmd/pkg/sqlcmd"
"github.com/spf13/cobra"
"path"
Expand Down Expand Up @@ -95,9 +96,7 @@ func initializeEnvVars() {
os.Setenv("SQLCMDPASSWORD", password)
}
}

}

}

// isFirstArgModernCliSubCommand is TEMPORARY code, to be removed when
Expand Down Expand Up @@ -131,7 +130,12 @@ func initializeCallback() {
TraceHandler: outputter.Tracef,
HintHandler: displayHints,
LineBreak: sqlcmd.SqlcmdEol,
LoggingLevel: verbosity.Level(rootCmd.loggingLevel),
})
mssqlcontainer.Initialize(mssqlcontainer.InitializeOptions{
ErrorHandler: checkErr,
TraceHandler: outputter.Tracef,
})
config.SetFileName(rootCmd.configFilename)
config.Load()
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/modern/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Root struct {
// It also provides usage examples for sqlcmd.
func (c *Root) DefineCommand(...cmdparser.CommandOptions) {
// Example usage steps
steps := []string{"sqlcmd create mssql --accept-eula --using https://aka.ms/AdventureWorksLT.bak"}
steps := []string{"sqlcmd create mssql --accept-eula --use https://aka.ms/AdventureWorksLT.bak"}

if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
steps = append(steps, "sqlcmd open ads")
Expand Down Expand Up @@ -66,10 +66,12 @@ func (c *Root) SubCommands() []cmdparser.Command {

subCommands := []cmdparser.Command{
cmdparser.New[*root.Config](dependencies),
cmdparser.New[*root.Deploy](dependencies),
cmdparser.New[*root.Install](dependencies),
cmdparser.New[*root.Query](dependencies),
cmdparser.New[*root.Start](dependencies),
cmdparser.New[*root.Stop](dependencies),
cmdparser.New[*root.Use](dependencies),
cmdparser.New[*root.Uninstall](dependencies),
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/modern/root/config/connection-strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *ConnectionStrings) run() {
if endpoint.AssetDetails != nil && endpoint.AssetDetails.ContainerDetails != nil {
controller := container.NewController()
if controller.ContainerRunning(endpoint.AssetDetails.ContainerDetails.Id) {
s := sql.New(sql.SqlOptions{})
s := sql.NewSql(sql.SqlOptions{})
s.Connect(endpoint, user, sql.ConnectOptions{Interactive: false})
c.database = s.ScalarString("PRINT DB_NAME()")
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/modern/root/config/current-context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type CurrentContext struct {
func (c *CurrentContext) DefineCommand(...cmdparser.CommandOptions) {
options := cmdparser.CommandOptions{
Use: "current-context",
Short: localizer.Sprintf("Display the current-context"),
Short: localizer.Sprintf("Display the name of the current-context"),
Examples: []cmdparser.ExampleOptions{
{
Description: localizer.Sprintf("Display the current-context"),
Description: localizer.Sprintf("Display the current-context name"),
Steps: []string{
"sqlcmd config current-context"},
},
Expand Down
4 changes: 4 additions & 0 deletions cmd/modern/root/config/delete-context.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (c *DeleteContext) run() {
if config.UserExists(context) {
config.DeleteUser(*context.ContextDetails.User)
}

for _, c := range context.AddOns {
config.DeleteEndpoint(c.Endpoint)
}
}

config.DeleteContext(c.name)
Expand Down
20 changes: 19 additions & 1 deletion cmd/modern/root/config/get-endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type GetEndpoints struct {

name string
detailed bool
value string
}

func (c *GetEndpoints) DefineCommand(...cmdparser.CommandOptions) {
Expand Down Expand Up @@ -47,6 +48,11 @@ func (c *GetEndpoints) DefineCommand(...cmdparser.CommandOptions) {
Bool: &c.detailed,
Name: "detailed",
Usage: localizer.Sprintf("Include endpoint details")})

c.AddFlag(cmdparser.FlagOptions{
String: &c.value,
Name: "value",
Usage: localizer.Sprintf("Value to get, (endpoint, port")})
}

func (c *GetEndpoints) run() {
Expand All @@ -55,7 +61,19 @@ func (c *GetEndpoints) run() {
if c.name != "" {
if config.EndpointExists(c.name) {
context := config.GetEndpoint(c.name)
output.Struct(context)

if c.value == "" {
output.Struct(context)
} else {
if c.value == "address" {
output.Struct(context.Address)
} else if c.value == "port" {
output.Struct(context.Port)
} else {
panic("Invalid value")
}
}

} else {
output.FatalWithHints(
[]string{localizer.Sprintf("To view available endpoints run `%s`", localizer.GetEndpointsCommand)},
Expand Down
Loading
Loading