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

Add fallback schema location for CustomResourceDefinition Kinds #60

Merged
merged 1 commit into from
Sep 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
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