This repository has been archived by the owner on Aug 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved azure.ParseOutputs to actions.ParseOutputs
- Loading branch information
Showing
3 changed files
with
39 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright (c) 2020 white duck Gesellschaft für Softwareentwicklung mbH | ||
This code is licensed under MIT license (see LICENSE for details) | ||
*/ | ||
package actions | ||
|
||
import "github.com/mitchellh/mapstructure" | ||
|
||
// Output represents a single output of an ARM template | ||
type Output struct { | ||
Type string `json:"type"` | ||
Value string `json:"value"` | ||
} | ||
|
||
// ParseOutputs takes the raw outputs from the azure.DemploymentExtended object | ||
// and converts it to a string Output map | ||
func ParseOutputs(raw interface{}) (map[string]Output, error) { | ||
if raw == nil { | ||
return map[string]Output{}, nil | ||
} | ||
|
||
var outputs map[string]Output | ||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ | ||
Result: &outputs, | ||
TagName: "json", | ||
}) | ||
if err != nil { | ||
return map[string]Output{}, err | ||
} | ||
|
||
err = decoder.Decode(raw) | ||
if err != nil { | ||
return map[string]Output{}, err | ||
} | ||
|
||
return outputs, nil | ||
} |