Skip to content

Commit

Permalink
Add fallback schema location for CustomResourceDefinition Kinds (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeNsaaH authored Sep 14, 2023
1 parent 69e0ef5 commit a9adf64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func getSchemaLocations() []string {
r := repo.Repo{CloneURL: schemasLocation}
err = r.CloneRepoLocal(ctx, tmpSchemasLocalDir)
if err != nil {
telemetry.SetError(span, err, "failed to clone schemas repository")
log.Err(err).Msg("failed to clone schemas repository")
telemetry.SetError(span, err, fmt.Sprintf("failed to clone schemas repository %s", schemasLocation))
log.Err(err).Msgf("failed to clone schemas repository %s", schemasLocation)
return
}

log.Debug().Str("schemas-repo", schemasLocation).Msg("Cloned schemas Repo to /tmp/schemas")
log.Debug().Str("schemas-repo", schemasLocation).Msgf("Cloned schemas Repo %s to /tmp/schemas", schemasLocation)
localSchemasLocation = tmpSchemasLocalDir

err = os.RemoveAll(oldLocalSchemasLocation)
Expand All @@ -80,6 +80,7 @@ func getSchemaLocations() []string {
refreshSchemasOnce.Do(func() {
c := cron.New()
c.AddFunc("@daily", func() {
log.Info().Msg("resetting schemas lock to allow refresh")
getSchemasOnce = *new(sync.Once)
})
c.Start()
Expand All @@ -89,7 +90,8 @@ func getSchemaLocations() []string {

return []string{
localSchemasLocation + `/{{ .NormalizedKubernetesVersion }}/{{ .ResourceKind }}{{ .KindSuffix }}.json`,
"https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
"default",
"https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/vcs_clients/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
appFormat = `<details><summary>
## ArgoCD Application Checks:` + "`%s` %s" +
`
`
</summary>
%s
</details>
Expand Down Expand Up @@ -79,7 +79,7 @@ func (m *Message) buildComment(ctx context.Context) string {
defer span.End()

var names []string
for _, name := range m.Apps {
for name := range m.Apps {
names = append(names, name)
}
sort.Strings(names)
Expand Down

0 comments on commit a9adf64

Please sign in to comment.