Skip to content

Commit

Permalink
[CLI] - Revision Verification (#909)
Browse files Browse the repository at this point in the history
Updating the output just to use double quotes around the names
  • Loading branch information
gambol99 authored Jul 14, 2023
1 parent 4a9c34c commit c12f305
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/tnctl/convert/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func NewRevisionCommand(factory cmd.Factory) *cobra.Command {
flags := ccm.Flags()
flags.BoolVar(&o.IncludeCheckov, "include-checkov", true, "Include checkov in the output")
flags.BoolVar(&o.IncludeProvider, "include-provider", true, "Include provider in the output")
flags.BoolVar(&o.IncludeTerraform, "include-terraform", true, "Include terraform in the output")
flags.StringVarP(&o.Directory, "path", "p", ".", "The path to write the files to")
flags.StringVarP(&o.File, "file", "f", "", "The path to the file containing the revision")
flags.StringVarP(&o.Namespace, "namespace", "n", "", "The namespace of the revision")
Expand Down
12 changes: 8 additions & 4 deletions pkg/cmd/tnctl/verify/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,17 +666,21 @@ func (o *RevisionCommand) checkValueFromReferences(revision *terraformv1alpha1.R
}

for _, x := range revision.Spec.Configuration.ValueFrom {
if x.Context == nil {
switch {
case o.Contexts == nil:
v.Warning("Revision references a context: %q, key: %q, but none available to check against", *x.Context, x.Key)

continue
}

txt, found := o.Contexts.GetItem(*x.Context)
if !found {
v.Failed("Revision references a context %s which does not exist", *x.Context)
v.Failed("Revision references a context %q which does not exist", *x.Context)
} else {
v.Passed("Revision references a context %s which exists", txt.Name)
v.Passed("Revision references a context %q, key %q which exists", txt.Name, x.Key)

if _, found := txt.Spec.Variables[x.Key]; !found {
v.Failed("Revision references a key %q in Context %q which does not exist", x.Key, *x.Context)
v.Failed("Revision references key %q, in Context %q which does not exist", x.Key, *x.Context)
}
}
}
Expand Down

0 comments on commit c12f305

Please sign in to comment.