Skip to content

Commit

Permalink
after review
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1queee committed Jan 23, 2024
1 parent fa1f8e8 commit 7c71148
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 142 deletions.
1 change: 0 additions & 1 deletion pkg/validate/sourceurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func NewSourceURL(client client.Client, build *build.Build) *SourceURLRef {
// that the spec.source.url exists. This validation only applies
// to endpoints that do not require authentication.
func (s SourceURLRef) ValidatePath(ctx context.Context) error {
// TODO: double check this new code
if s.Build.Spec.Source.Type == build.GitType {
gitSource := s.Build.Spec.Source.GitSource
if gitSource.CloneSecret == nil && gitSource.URL != "" {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/v1beta1/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func amendBuild(identifier string, b *buildv1beta1.Build) {

// retrieveBuildAndBuildRun will retrieve the build and buildRun
func retrieveBuildAndBuildRun(testBuild *utils.TestBuild, namespace string, buildRunName string) (*buildv1beta1.Build, *buildv1beta1.BuildRun, error) {
// TODO: double check the following function content.
buildRun, err := testBuild.LookupBuildRun(types.NamespacedName{Name: buildRunName, Namespace: namespace})
if err != nil {
Logf("Failed to get BuildRun %q: %s", buildRunName, err)
Expand Down
141 changes: 0 additions & 141 deletions test/integration/build_to_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,147 +278,6 @@ var _ = Describe("Integration tests Build and referenced Secrets", func() {
})
})

// Context("when a build reference a secret with annotations for the spec builder", func() {
// It("should validate the Build after secret deletion", func() {

// // populate Build related vars
// buildName := BUILD + tb.Namespace
// buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(
// buildName,
// STRATEGY+tb.Namespace,
// []byte(test.BuildWithBuilderRefSecret),
// )
// Expect(err).To(BeNil())

// sampleSecret := tb.Catalog.SecretWithAnnotation(buildObject.Spec.Builder.Credentials.Name, buildObject.Namespace)

// Expect(tb.CreateSecret(sampleSecret)).To(BeNil())

// Expect(tb.CreateBuild(buildObject)).To(BeNil())

// // wait until the Build finish the validation
// buildObject, err := tb.GetBuildTillValidation(buildName)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionTrue))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SucceedStatus))

// // delete a secret
// Expect(tb.DeleteSecret(buildObject.Spec.Builder.Credentials.Name)).To(BeNil())

// // assert that the validation happened one more time
// buildObject, err = tb.GetBuildTillRegistration(buildName, corev1.ConditionFalse)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionFalse))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SpecBuilderSecretRefNotFound))
// Expect(*buildObject.Status.Message).To(Equal(fmt.Sprintf("referenced secret %s not found", buildObject.Spec.Builder.Credentials.Name)))
// })

// It("should validate when a missing secret is recreated", func() {
// // populate Build related vars
// buildName := BUILD + tb.Namespace
// buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(
// buildName,
// STRATEGY+tb.Namespace,
// []byte(test.BuildWithBuilderRefSecret),
// )
// Expect(err).To(BeNil())

// Expect(tb.CreateBuild(buildObject)).To(BeNil())

// // wait until the Build finish the validation
// buildObject, err := tb.GetBuildTillValidation(buildName)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionFalse))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SpecBuilderSecretRefNotFound))
// Expect(*buildObject.Status.Message).To(Equal(fmt.Sprintf("referenced secret %s not found", buildObject.Spec.Builder.Credentials.Name)))

// sampleSecret := tb.Catalog.SecretWithAnnotation(buildObject.Spec.Builder.Credentials.Name, buildObject.Namespace)

// // generate resources
// Expect(tb.CreateSecret(sampleSecret)).To(BeNil())

// // assert that the validation happened one more time
// buildObject, err = tb.GetBuildTillRegistration(buildName, corev1.ConditionTrue)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionTrue))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SucceedStatus))
// })
// })

// Context("when a build reference multiple secrets with annotations for a build instance", func() {
// It("should validate the Build after secret deletion", func() {

// // populate Build related vars
// buildName := BUILD + tb.Namespace
// buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(
// buildName,
// STRATEGY+tb.Namespace,
// []byte(test.BuildWithMultipleRefSecrets),
// )
// Expect(err).To(BeNil())

// specSourceSecret := tb.Catalog.SecretWithAnnotation(*buildObject.Spec.Source.GitSource.CloneSecret, buildObject.Namespace)
// specBuilderSecret := tb.Catalog.SecretWithAnnotation(buildObject.Spec.Builder.Credentials.Name, buildObject.Namespace)

// Expect(tb.CreateSecret(specSourceSecret)).To(BeNil())
// Expect(tb.CreateSecret(specBuilderSecret)).To(BeNil())

// Expect(tb.CreateBuild(buildObject)).To(BeNil())

// // wait until the Build finish the validation
// buildObject, err := tb.GetBuildTillValidation(buildName)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionTrue))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SucceedStatus))

// // delete a secret
// Expect(tb.DeleteSecret(specSourceSecret.Name)).To(BeNil())
// Expect(tb.DeleteSecret(specBuilderSecret.Name)).To(BeNil())

// buildObject, err = tb.GetBuildTillMessageContainsSubstring(buildName, "missing secrets are")
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionFalse))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.MultipleSecretRefNotFound))
// Expect(*buildObject.Status.Message).To(ContainSubstring(specSourceSecret.Name))
// Expect(*buildObject.Status.Message).To(ContainSubstring(specBuilderSecret.Name))

// })

// It("should validate when a missing secret is recreated", func() {
// // populate Build related vars
// buildName := BUILD + tb.Namespace
// buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(
// buildName,
// STRATEGY+tb.Namespace,
// []byte(test.BuildWithMultipleRefSecrets),
// )
// Expect(err).To(BeNil())

// Expect(tb.CreateBuild(buildObject)).To(BeNil())

// // wait until the Build finish the validation
// buildObject, err := tb.GetBuildTillValidation(buildName)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionFalse))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.MultipleSecretRefNotFound))
// Expect(*buildObject.Status.Message).To(ContainSubstring("missing secrets are"))
// Expect(*buildObject.Status.Message).To(ContainSubstring(buildObject.Spec.Source.Credentials.Name))
// Expect(*buildObject.Status.Message).To(ContainSubstring(buildObject.Spec.Builder.Credentials.Name))

// specSourceSecret := tb.Catalog.SecretWithAnnotation(buildObject.Spec.Source.Credentials.Name, buildObject.Namespace)
// specBuilderSecret := tb.Catalog.SecretWithAnnotation(buildObject.Spec.Builder.Credentials.Name, buildObject.Namespace)

// // generate resources
// Expect(tb.CreateSecret(specSourceSecret)).To(BeNil())
// Expect(tb.CreateSecret(specBuilderSecret)).To(BeNil())

// // assert that the validation happened one more time
// buildObject, err = tb.GetBuildTillRegistration(buildName, corev1.ConditionTrue)
// Expect(err).To(BeNil())
// Expect(*buildObject.Status.Registered).To(Equal(corev1.ConditionTrue))
// Expect(*buildObject.Status.Reason).To(Equal(v1beta1.SucceedStatus))
// })
// })
Context("when multiple builds reference a secret with annotations for the spec.source", func() {
It("should validate the Builds after secret deletion", func() {

Expand Down

0 comments on commit 7c71148

Please sign in to comment.