Skip to content

Conversation

@bestefreund
Copy link
Contributor

Adds a new data source google_artifact_registry_maven_artifacts, allowing to retrieve Maven artifacts from an Artifact Registry repository.

Fixes: hashicorp/terraform-provider-google#23911

Release Note Template for Downstream PRs (will be copied)

`google_artifact_registry_maven_artifacts`

@github-actions github-actions bot requested a review from hao-nan-li August 7, 2025 21:52
@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@hao-nan-li, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 7, 2025
@bestefreund bestefreund force-pushed the feature/data_source_google_artifact_registry_maven_artifacts branch 2 times, most recently from e9deafa to feec853 Compare August 10, 2025 18:26
@github-actions
Copy link

@hao-nan-li This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician added service/artifactregistry and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 12, 2025
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 313 insertions(+), 1 deletion(-))
google-beta provider: Diff ( 4 files changed, 313 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccDataSourceArtifactRegistryMavenArtifacts_basic

Tests analytics

Total tests: 37
Passed tests: 35
Skipped tests: 2
Affected tests: 0

Click here to see the affected service packages
  • artifactregistry

🟢 All tests passed!

View the build log

// At the moment there are no public Maven artifacts available in Artifact Registry.
// This test is skipped to avoid unnecessary failures.
// As soon as there are public artifacts available, this test can be enabled by removing the skip and adjusting the configuration accordingly.
t.Skip("No public Maven artifacts available in Artifact Registry")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you upload a log of the test even if there's no maven artifact fetched?

Copy link
Contributor Author

@bestefreund bestefreund Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the output from the go-test:

make testacc TEST="./google/services/artifactregistry" TESTARGS="-run=TestAccDataSourceArtifactRegistryMavenArtifacts_"

TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/artifactregistry -v -run=TestAccDataSourceArtifactRegistryMavenArtifacts_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccDataSourceArtifactRegistryMavenArtifacts_basic
=== PAUSE TestAccDataSourceArtifactRegistryMavenArtifacts_basic
=== CONT  TestAccDataSourceArtifactRegistryMavenArtifacts_basic
    data_source_artifact_registry_maven_artifacts_test.go:32: No public Maven artifacts available in Artifact Registry
--- SKIP: TestAccDataSourceArtifactRegistryMavenArtifacts_basic (0.00s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/artifactregistry 0.026s

Here, you can find a snipped which, I've used for testing the data source manually after generating the provider binary from this branch and logged in with gcloud:

# Init configuration
PROJECT_ID="example-project"
REGION="europe-west3"
REPO_NAME="example-maven-repo"
GROUP_ID="com.example"
ARTIFACT_ID="my-artifact"

# Set project id in provider configuration
export GOOGLE_PROJECT="${PROJECT_ID}"

# Generate repository path
repo="${REGION}-maven.pkg.dev/${PROJECT_ID}/${REPO_NAME}"

# Create repository
gcloud artifacts repositories create "${REPO_NAME}" \
  --quiet \
  --project="${PROJECT_ID}" \
  --location="${REGION}" \
  --repository-format="maven" \
  --description="example maven repo"

# Create Maven project directory and change into it
WORKDIR="maven-example"
mkdir "${WORKDIR}"
cd "${WORKDIR}" || exit

# Create minimal Maven project (pom.xml + source)
mkdir -p "src/main/java/com/example"

# Generate simple Java class
cat > src/main/java/com/example/Main.java << EOF
package ${GROUP_ID};

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello from Maven package!");
    }
}
EOF

# Deploy 3 versions of the Maven artifact
for i in $(seq 1 3); do
  # Generate pom.xml for current version
  cat > pom.xml << EOF
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>${GROUP_ID}</groupId>
  <artifactId>${ARTIFACT_ID}</artifactId>
  <version>0.0.${i}</version>

  <distributionManagement>
    <snapshotRepository>
      <id>artifact-registry</id>
      <url>artifactregistry://${REGION}-maven.pkg.dev/${PROJECT_ID}/${REPO_NAME}</url>
    </snapshotRepository>
    <repository>
      <id>artifact-registry</id>
      <url>artifactregistry://${REGION}-maven.pkg.dev/${PROJECT_ID}/${REPO_NAME}</url>
    </repository>
  </distributionManagement>

  <repositories>
    <repository>
      <id>artifact-registry</id>
      <url>artifactregistry://${REGION}-maven.pkg.dev/${PROJECT_ID}/${REPO_NAME}</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <extensions>
      <extension>
        <groupId>com.google.cloud.artifactregistry</groupId>
        <artifactId>artifactregistry-maven-wagon</artifactId>
        <version>2.2.0</version>
      </extension>
    </extensions>
  </build>
</project>
EOF

  # Build and upload current version
  mvn deploy
done

# Create Terraform config to read latest Maven artifact
cat > main.tf << EOF
data "google_artifact_registry_maven_artifacts" "this" {
  location      = "${REGION}"
  repository_id = "${REPO_NAME}"
}
EOF

# Initialize and apply Terraform
terraform init
terraform plan -out="out.plan"
terraform apply "out.plan"

# Show artifact data
terraform state show "data.google_artifact_registry_maven_artifacts.this"

# Cleanup
cd ..
rm -rf "${WORKDIR}"
gcloud artifacts repositories delete "${REPO_NAME}" \
  --quiet \
  --project="${PROJECT_ID}" \
  --location="${REGION}"

Here is the relevant output (anonymized):

terraform state show "data.google_artifact_registry_maven_artifacts.this"
# data.google_artifact_registry_maven_artifacts.this:
data "google_artifact_registry_maven_artifacts" "this" {
    id              = "projects/example-project/locations/europe-west3/repositories/example-maven-repo/mavenArtifacts"
    location        = "europe-west3"
    maven_artifacts = [
        {
            artifact_id = "my-artifact"
            create_time = "2025-08-13T06:07:06.787517Z"
            group_id    = "com.example"
            name        = "projects/example-project/locations/europe-west3/repositories/example-maven-repo/mavenArtifacts/com.example:my-artifact:0.0.1"
            pom_uri     = "europe-west3-maven.pkg.dev/example-project/example-maven-repo/com/example/my-artifact/0.0.1/my-artifact-0.0.1.pom"
            update_time = "2025-08-13T06:07:06.787517Z"
            version     = "0.0.1"
        },
        {
            artifact_id = "my-artifact"
            create_time = "2025-08-13T06:07:13.209787Z"
            group_id    = "com.example"
            name        = "projects/example-project/locations/europe-west3/repositories/example-maven-repo/mavenArtifacts/com.example:my-artifact:0.0.2"
            pom_uri     = "europe-west3-maven.pkg.dev/example-project/example-maven-repo/com/example/my-artifact/0.0.2/my-artifact-0.0.2.pom"
            update_time = "2025-08-13T06:07:13.209787Z"
            version     = "0.0.2"
        },
        {
            artifact_id = "my-artifact"
            create_time = "2025-08-13T06:07:18.317992Z"
            group_id    = "com.example"
            name        = "projects/example-project/locations/europe-west3/repositories/example-maven-repo/mavenArtifacts/com.example:my-artifact:0.0.3"
            pom_uri     = "europe-west3-maven.pkg.dev/example-project/example-maven-repo/com/example/my-artifact/0.0.3/my-artifact-0.0.3.pom"
            update_time = "2025-08-13T06:07:18.317992Z"
            version     = "0.0.3"
        },
    ]
    project         = "example-project"
    repository_id   = "example-maven-repo"
}

And here you can find the whole output (anonymized):
output.txt

@hao-nan-li
Please, let me know, if I can further assist you.

@bestefreund bestefreund force-pushed the feature/data_source_google_artifact_registry_maven_artifacts branch from feec853 to 5da9af8 Compare August 13, 2025 05:48
@bestefreund
Copy link
Contributor Author

ℹ️
Resolved merge-conflict in mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl by rebasing on main branch

@github-actions github-actions bot requested a review from hao-nan-li August 13, 2025 05:48
@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 13, 2025
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 312 insertions(+))
google-beta provider: Diff ( 4 files changed, 312 insertions(+))

@modular-magician
Copy link
Collaborator

Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccDataSourceArtifactRegistryMavenArtifacts_basic

Tests analytics

Total tests: 38
Passed tests: 36
Skipped tests: 2
Affected tests: 0

Click here to see the affected service packages
  • artifactregistry

🟢 All tests passed!

View the build log

@hao-nan-li
Copy link
Contributor

Thanks for the update! @yiyangw-g do you plan to do a first round of review?

@github-actions
Copy link

@hao-nan-li This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions
Copy link

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions
Copy link

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 3 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@bestefreund bestefreund force-pushed the feature/data_source_google_artifact_registry_maven_artifacts branch from 5da9af8 to 19a4cf2 Compare September 3, 2025 22:16
@bestefreund
Copy link
Contributor Author

ℹ️
Resolved merge-conflict in mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl by rebasing on main branch

@bestefreund
Copy link
Contributor Author

Hi @hao-nan-li ,

please, take a look on this.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 312 insertions(+))
google-beta provider: Diff ( 4 files changed, 312 insertions(+))

@modular-magician
Copy link
Collaborator

Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccDataSourceArtifactRegistryMavenArtifacts_basic

Tests analytics

Total tests: 40
Passed tests: 37
Skipped tests: 3
Affected tests: 0

Click here to see the affected service packages
  • artifactregistry

🟢 All tests passed!

View the build log

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 4 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@bestefreund bestefreund force-pushed the feature/data_source_google_artifact_registry_maven_artifacts branch from 19a4cf2 to 660679c Compare September 12, 2025 20:13
@bestefreund
Copy link
Contributor Author

ℹ️
Resolved merge-conflict in mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl by rebasing on main branch

@github-actions
Copy link

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 5 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 312 insertions(+))
google-beta provider: Diff ( 4 files changed, 312 insertions(+))

@modular-magician
Copy link
Collaborator

Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccDataSourceArtifactRegistryMavenArtifacts_basic

Tests analytics

Total tests: 42
Passed tests: 35
Skipped tests: 5
Affected tests: 2

Click here to see the affected service packages
  • artifactregistry

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccArtifactRegistryRepository_updateEmptyMvn
  • TestAccDataSourceGoogleArtifactRegistryRepositoryConfig

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccArtifactRegistryRepository_updateEmptyMvn [Debug log]
TestAccDataSourceGoogleArtifactRegistryRepositoryConfig [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@github-actions
Copy link

@GoogleCloudPlatform/terraform-team @hao-nan-li This PR has been waiting for review for 6 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@bestefreund
Copy link
Contributor Author

Hi @hao-nan-li @yiyangw-g ,

please, let me know when the review will be continued.

@hao-nan-li hao-nan-li added this pull request to the merge queue Sep 25, 2025
Merged via the queue into GoogleCloudPlatform:main with commit da70afa Sep 25, 2025
24 checks passed
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Sep 26, 2025
jkrish-c pushed a commit to jkrish-c/magic-modules that referenced this pull request Oct 14, 2025
g-dreva pushed a commit to g-dreva/magic-modules that referenced this pull request Oct 15, 2025
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add plural data source for retrieving Maven artifacts from an Artifact Registry repository

3 participants