generated from jimschubert/go-cli-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
7183c05
commit 19297a4
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
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
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,50 @@ | ||
package rules | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/jimschubert/docked/model" | ||
"github.com/jimschubert/docked/model/docker/commands" | ||
"github.com/jimschubert/docked/model/validations" | ||
) | ||
|
||
func openContainersAnnotations() validations.Rule { | ||
r := validations.MultiContextRule{ | ||
Name: "oci-labels", | ||
Summary: "Consider using common annotations defined by Open Containers Initiative", | ||
Details: "Open Containers Initiative defines a common set of annotations which expose as labels on containers", | ||
Priority: model.MediumPriority, | ||
Commands: []commands.DockerCommand{commands.Label}, | ||
Evaluator: validations.MultiContextFullEvaluator{ | ||
Fn: func(mcr *validations.MultiContextRule) *validations.ValidationResult { | ||
if mcr == nil || mcr.ContextCache == nil { | ||
return &validations.ValidationResult{ | ||
Result: model.Skipped, | ||
Details: mcr.GetSummary(), | ||
} | ||
} | ||
result := model.Recommendation | ||
validationContexts := make([]validations.ValidationContext, 0) | ||
for _, nodeValidationContext := range *mcr.ContextCache { | ||
if strings.Contains(nodeValidationContext.Node.Original, "org.opencontainers") { | ||
result = model.Success | ||
} else { | ||
nodeValidationContext.Context.HasRecommendations = true | ||
} | ||
validationContexts = append(validationContexts, nodeValidationContext.Context) | ||
} | ||
|
||
return &validations.ValidationResult{ | ||
Result: result, | ||
Details: mcr.GetSummary(), | ||
Contexts: validationContexts, | ||
} | ||
}, | ||
}, | ||
} | ||
return &r | ||
} | ||
|
||
func init() { | ||
AddRule(openContainersAnnotations()) | ||
} |
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,3 @@ | ||
FROM scratch | ||
LABEL org.opencontainers.image.authors="me@example.com" | ||
LABEL org.opencontainers.image.licenses="Apache 2.0" |