Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] - Revision Verification #909

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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