Skip to content

Commit 0ec7d18

Browse files
committed
Add a cobra PostRunE to save output artifacts within the APIsdirectory
1 parent 4965245 commit 0ec7d18

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

cmd/ack-generate/command/apis.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
generate "github.com/aws-controllers-k8s/code-generator/pkg/generate"
2525
ackgenerate "github.com/aws-controllers-k8s/code-generator/pkg/generate/ack"
26+
ackoutput "github.com/aws-controllers-k8s/code-generator/pkg/generate/output"
2627
"github.com/aws-controllers-k8s/code-generator/pkg/model"
2728
)
2829

@@ -42,9 +43,10 @@ var (
4243

4344
// apiCmd is the command that generates service API types
4445
var apisCmd = &cobra.Command{
45-
Use: "apis <service>",
46-
Short: "Generate Kubernetes API type definitions for an AWS service API",
47-
RunE: generateAPIs,
46+
Use: "apis <service>",
47+
Short: "Generate Kubernetes API type definitions for an AWS service API",
48+
RunE: generateAPIs,
49+
PostRunE: saveGeneratedArtifactMetadata,
4850
}
4951

5052
func init() {
@@ -54,6 +56,19 @@ func init() {
5456
rootCmd.AddCommand(apisCmd)
5557
}
5658

59+
// saveGeneratedArtifactMetadata saves the parameters used to generate APIs and checksum
60+
// of the generated code.
61+
func saveGeneratedArtifactMetadata(cmd *cobra.Command, args []string) error {
62+
err := ackoutput.CreateArtifact(
63+
optGenVersion,
64+
filepath.Join(optOutputPath, "apis"),
65+
ackoutput.UpdateReasonAPIGeneration,
66+
optAWSSDKGoVersion,
67+
optGeneratorConfigPath,
68+
)
69+
return err
70+
}
71+
5772
// generateAPIs generates the Go files for each resource in the AWS service
5873
// API.
5974
func generateAPIs(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)