Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## `v14.1.1`

- Fixing timestamp marshalling bug in the `storage` package.
- Updating `profileBuilder` to clear-output folders when it is run by `go generate`.
- Tweaking Swagger -> SDK config to use "latest" instead of "nightly" and be tied to a particular version of autorest.go.

## `v14.1.0`

### Changes
Expand Down
2 changes: 1 addition & 1 deletion profiles/2017-03-09/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package v20170309

//go:generate go run ../../tools/profileBuilder/main.go list --input ./definition.go --name 2017-03-09
//go:generate go run ../../tools/profileBuilder/main.go list --clear-output --input ./definition.txt --name 2017-03-09
2 changes: 1 addition & 1 deletion profiles/latest/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package latest

//go:generate go run ../../tools/profileBuilder/main.go latest --name latest
//go:generate go run ../../tools/profileBuilder/main.go list --clear-output --name latest --input ./stableApis.txt
2 changes: 1 addition & 1 deletion profiles/preview/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package preview

//go:generate go run ../../tools/profileBuilder/main.go latest --name preview --preview
//go:generate go run ../../tools/profileBuilder/main.go latest --clear-output --name preview --preview
8 changes: 4 additions & 4 deletions swagger_to_sdk_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
"dep ensure",
"go install",
"cd ../..",
"go generate",
"go generate ./profiles/...",
"gofmt -w ./services/",
"gofmt -w ./profiles/"
],
"autorest_options": {
"use": "@microsoft.azure/autorest.go@preview",
"use": "@microsoft.azure/autorest.go@~2",
"go": "",
"verbose": "",
"sdkrel:go-sdk-folder": ".",
"multiapi": "",
"package-version": "nightly",
"user-agent": "Azure-SDK-For-Go/nightly services"
"package-version": "latest",
"user-agent": "Azure-SDK-For-Go/latest services"
},
"version": "0.2.0"
}
Expand Down
9 changes: 9 additions & 0 deletions tools/profileBuilder/cmd/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io/ioutil"
"log"
"os"
"path"

"github.com/Azure/azure-sdk-for-go/tools/profileBuilder/model"
"github.com/marstr/randname"
Expand Down Expand Up @@ -73,6 +74,14 @@ By default, this command ignores API versions that are in preview.`,
outputLog.Println("Using preview versions.")
}

deleteLoc := path.Join(latestFlags.GetString(outputLocationLongName), latestFlags.GetString(nameLongName))
if viper.GetBool("clear-output") {
if err := model.DeleteChildDirs(deleteLoc); err != nil {
errLog.Print("Fatal! Unable to clear output-folder:", err)
return
}
}

model.BuildProfile(
packageStrategy,
latestFlags.GetString(nameLongName),
Expand Down
11 changes: 10 additions & 1 deletion tools/profileBuilder/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io/ioutil"
"log"
"os"
"path"

"github.com/Azure/azure-sdk-for-go/tools/profileBuilder/model"
"github.com/marstr/randname"
Expand Down Expand Up @@ -69,10 +70,18 @@ $> ../model/testdata/smallProfile.txt > profileBuilder list --name small_profile
} else if fileHandle, err := os.Open(listFlags.GetString(inputLongName)); err == nil {
input = fileHandle
} else {
errLog.Printf("Unable to open file %q", listFlags.GetString(inputLongName))
errLog.Printf("Fatal! Unable to open file %q", listFlags.GetString(inputLongName))
return
}

deleteLoc := path.Join(listFlags.GetString(outputLocationLongName), listFlags.GetString(nameLongName))
if viper.GetBool("clear-output") {
if err := model.DeleteChildDirs(deleteLoc); err != nil {
errLog.Print("Fatal! Unable to clear output-folder:", err)
return
}
}

model.BuildProfile(
&model.ListStrategy{Reader: input},
listFlags.GetString(nameLongName),
Expand Down
3 changes: 3 additions & 0 deletions tools/profileBuilder/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ func init() {
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.profileBuilder.yaml)")

rootCmd.PersistentFlags().BoolP("clear-output", "c", false, "Removes any directories in the output-folder before writing a profile.")
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Use stderr to log verbose output.")

viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
viper.BindPFlag("clear-output", rootCmd.PersistentFlags().Lookup("clear-output"))
}

// initConfig reads in config file and ENV variables if set.
Expand Down
48 changes: 48 additions & 0 deletions tools/profileBuilder/model/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// +build go1.9

// Copyright 2018 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package model

import (
"io/ioutil"
"os"
"path"
"strings"
)

// DeleteChildDirs deletes all child directories of the directory specified by
// `path`.
// If it fails to delete a child, it halts execution and returns an err immediately.
func DeleteChildDirs(dir string) (err error) {
var children []os.FileInfo

children, err = ioutil.ReadDir(dir)
if err != nil {
return
}

for _, child := range children {
if child.IsDir() {
childPath := strings.Replace(path.Join(dir, child.Name()), `\`, `/`, -1)
err = os.RemoveAll(childPath)
if err != nil {
return
}
}
}

return
}
2 changes: 1 addition & 1 deletion version/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.