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

[lint-provider-family]: Allow the family labels on config packages #124

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions cmd/linter/lint-provider-family/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
streamFile = "package.yaml"
labelFamily = "pkg.crossplane.io/provider-family"
annotationAuthConfig = "auth.upbound.io/config"
constraintXPVersion = ">=v1.12.1-0"
)

var (
Expand Down Expand Up @@ -112,8 +113,8 @@ func lint(config *ssopLinterConfig) error { //nolint:gocyclo // sequential flow
repoName = familyConfigPackageName
}

packageURL := fmt.Sprintf(packageURLFormatTagged, repoName, *config.providerVersion)
if _, ok := metaMap[group]; !ok {
packageURL := fmt.Sprintf(packageURLFormatTagged, repoName, *config.providerVersion)
xpkg, err := getPackageMetadata(context.TODO(), packageURL)
if err != nil {
return errors.Wrapf(err, "failed to get package metadata for provider package: %s", packageURL)
Expand Down Expand Up @@ -161,17 +162,18 @@ func lint(config *ssopLinterConfig) error { //nolint:gocyclo // sequential flow
break
}
}
if foundLabel && repoName == familyConfigPackageName {
log.Fatalln("Family label found on family config package: ", familyConfigPackageName)
}
if !foundLabel && repoName != familyConfigPackageName {
if !foundLabel {
log.Fatalln("Family label not found: ", e.Name())
}

// check dependency to family config package
if group != *config.providerName && (len(m.Spec.DependsOn) != 1 || m.Spec.DependsOn[0].Provider == nil || *m.Spec.DependsOn[0].Provider != familyConfigPackageRef) {
log.Fatalln("Missing dependency to family config package: ", e.Name())
}
// check the version constraint on Crossplane version
if m.Spec.Crossplane == nil || m.Spec.Crossplane.Version != constraintXPVersion {
log.Fatalf("Package metadata must declare a Crossplane version constraint to %q: %s\n", constraintXPVersion, packageURL)
}
break
}
if !foundMeta {
Expand Down