Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
remove pre-fill validation in deploy (#3112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon authored and jackfrancis committed May 31, 2018
1 parent a1fe789 commit 1bd96cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func (dc *deployCmd) load(cmd *cobra.Command, args []string) error {
},
}

dc.containerService, dc.apiVersion, err = apiloader.LoadContainerServiceFromFile(dc.apimodelPath, true, false, nil)
// do not validate when initially loading the apimodel, validation is done later after autofilling values
dc.containerService, dc.apiVersion, err = apiloader.LoadContainerServiceFromFile(dc.apimodelPath, false, false, nil)
if err != nil {
return fmt.Errorf(fmt.Sprintf("error parsing the api model: %s", err.Error()))
}
Expand All @@ -161,7 +162,7 @@ func (dc *deployCmd) load(cmd *cobra.Command, args []string) error {
// autofillApimodel calls log.Fatal() directly and does not return errors
autofillApimodel(dc)

_, _, err = revalidateApimodel(apiloader, dc.containerService, dc.apiVersion)
_, _, err = validateApimodel(apiloader, dc.containerService, dc.apiVersion)
if err != nil {
return fmt.Errorf(fmt.Sprintf("Failed to validate the apimodel after populating values: %s", err))
}
Expand Down Expand Up @@ -290,7 +291,7 @@ func autofillApimodel(dc *deployCmd) {
}
}

func revalidateApimodel(apiloader *api.Apiloader, containerService *api.ContainerService, apiVersion string) (*api.ContainerService, string, error) {
func validateApimodel(apiloader *api.Apiloader, containerService *api.ContainerService, apiVersion string) (*api.ContainerService, string, error) {
// This isn't terribly elegant, but it's the easiest way to go for now w/o duplicating a bunch of code
rawVersionedAPIModel, err := apiloader.SerializeContainerService(containerService, apiVersion)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func testAutodeployCredentialHandling(t *testing.T, useManagedIdentity bool, cli
// cleanup, since auto-populations creates dirs and saves the SSH private key that it might create
defer os.RemoveAll(deployCmd.outputDirectory)

cs, _, err = revalidateApimodel(apiloader, cs, ver)
cs, _, err = validateApimodel(apiloader, cs, ver)
if err != nil {
log.Fatalf("unexpected error validating apimodel after populating defaults: %s", err)
}
Expand Down

0 comments on commit 1bd96cb

Please sign in to comment.