From 680e93e5d3f6d58605e050599e966e323e29f167 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 14 Jun 2023 15:10:28 +0300 Subject: [PATCH 1/2] [lint-provider-family]: Reallow the family labels on config packages Signed-off-by: Alper Rifat Ulucinar --- cmd/linter/lint-provider-family/main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/linter/lint-provider-family/main.go b/cmd/linter/lint-provider-family/main.go index 8e1209d..a7a7ef9 100644 --- a/cmd/linter/lint-provider-family/main.go +++ b/cmd/linter/lint-provider-family/main.go @@ -161,10 +161,7 @@ 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()) } From 0a9efd104c500d0c2e913dd3cfde09df3dd2dee9 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 14 Jun 2023 15:48:31 +0300 Subject: [PATCH 2/2] Check the Crossplane version constraint on the family provider package metadata Signed-off-by: Alper Rifat Ulucinar --- cmd/linter/lint-provider-family/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/linter/lint-provider-family/main.go b/cmd/linter/lint-provider-family/main.go index a7a7ef9..99449d7 100644 --- a/cmd/linter/lint-provider-family/main.go +++ b/cmd/linter/lint-provider-family/main.go @@ -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 ( @@ -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) @@ -169,6 +170,10 @@ func lint(config *ssopLinterConfig) error { //nolint:gocyclo // sequential flow 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 {