Skip to content

Commit

Permalink
adds custom provision format to avoid issue STDOUT flow of provisioni…
Browse files Browse the repository at this point in the history
…ng. Adds machine Identity values to STDOUT version
  • Loading branch information
luispresuelVenafi committed May 23, 2024
1 parent 7489f00 commit af43037
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/vcert/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ type commandFlags struct {
keystoreCertName string
provisionOutputFile string
provisionPickupID string
provisionFormat string
}
2 changes: 1 addition & 1 deletion cmd/vcert/cmdCloudKeystores.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func doCommandProvisionCloudKeystore(c *cli.Context) error {
result.MachineIdentityId = metadata.GetMachineIdentityMetadata().GetID()
result.MachineIdentityActionType = metadata.GetMachineIdentityMetadata().GetActionType()

err = result.Flush(flags.format)
err = result.Flush(flags.provisionFormat)

if err != nil {
return fmt.Errorf("failed to output the results: %s", err)
Expand Down
8 changes: 7 additions & 1 deletion cmd/vcert/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,12 @@ var (
Destination: &flags.provisionPickupID,
}

flagProvisionFormat = &cli.StringFlag{
Name: "format",
Usage: "The format of the operation output: text or JSON. Defaults to text.",
Destination: &flags.provisionFormat,
}

commonFlags = []cli.Flag{flagInsecure, flagVerbose, flagNoPrompt}
keyFlags = []cli.Flag{flagKeyType, flagKeySize, flagKeyCurve, flagKeyFile, flagKeyPassword}
sansFlags = []cli.Flag{flagDNSSans, flagEmailSans, flagIPSans, flagURISans, flagUPNSans}
Expand Down Expand Up @@ -900,7 +906,7 @@ var (
flagProviderName,
flagKeystoreName,
flagKeystoreID,
flagFormat,
flagProvisionFormat,
flagProvisionOutputFile, // TODO: implement this flag
)

Expand Down
4 changes: 4 additions & 0 deletions cmd/vcert/result_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ func (r *ProvisioningResult) Format(format string) (string, error) {
result += fmt.Sprintf("gcpId %s\n", r.GcpID)
result += fmt.Sprintf("gcpName %s\n", r.GcpName)
}
if r.MachineIdentityId != "" {
result += fmt.Sprintf("machineIdentityId %s\n", r.MachineIdentityId)
result += fmt.Sprintf("machineIdentityActionType %s\n", r.MachineIdentityActionType)
}
}
return result, nil
}
2 changes: 1 addition & 1 deletion cmd/vcert/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func validateProvisionFlags(commandName string) error {
return err
}

if flags.format != "" && flags.format != "json" {
if flags.provisionFormat != "" && flags.provisionFormat != "json" {
return fmt.Errorf("unexpected output format: %s", flags.format)
}

Expand Down

0 comments on commit af43037

Please sign in to comment.