-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
639 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,77 @@ | ||
#!/bin/bash | ||
|
||
MYDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
TOOLDIR="$MYDIR/generate-provider-resource-mapping" | ||
MYNAME="$(basename "${BASH_SOURCE[0]}")" | ||
ROOTDIR="$MYDIR/../.." | ||
|
||
die() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
usage() { | ||
cat << EOF | ||
Usage: ./run.sh [options] | ||
Options: | ||
-h|--help show this message | ||
Arguments: | ||
provider_dir The path to the AzureRM provider repo | ||
EOF | ||
} | ||
|
||
main() { | ||
while :; do | ||
case $1 in | ||
-h|--help) | ||
usage | ||
exit 1 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
local expect_n_arg | ||
expect_n_arg=1 | ||
[[ $# = "$expect_n_arg" ]] || die "wrong arguments (expected: $expect_n_arg, got: $#)" | ||
|
||
provider_dir=$1 | ||
|
||
[[ -d $provider_dir ]] || die "no such directory: $provider_dir" | ||
|
||
pushd $provider_dir > /dev/null | ||
pkgs=(./internal/sdk ./internal/services/*) | ||
popd > /dev/null | ||
out=$(go run "$TOOLDIR" -dir "$provider_dir" "${pkgs[@]}") || die "failed to run the tool" | ||
cat << EOF > "$ROOTDIR/mapping/mapping.go" | ||
// Code generated by generate-provider-resource-mapping/run.sh; DO NOT EDIT. | ||
package schema | ||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
) | ||
var ProviderResourceMapping = map[string]string{} | ||
func init() { | ||
b := []byte(\`$out\`) | ||
if err := json.Unmarshal(b, &ProviderResourceMapping); err != nil { | ||
fmt.Fprintf(os.Stderr, "unmarshalling the provider resource mapping: %s", err) | ||
os.Exit(1) | ||
} | ||
} | ||
EOF | ||
} | ||
|
||
main "$@" |
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
Large diffs are not rendered by default.
Oops, something went wrong.