Skip to content

Commit

Permalink
Merge pull request #4 from Q42/fix-verify
Browse files Browse the repository at this point in the history
chore: Update docs & test
  • Loading branch information
TheMerski committed Feb 9, 2024
2 parents fa227ff + d2c3c67 commit cd46792
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ on:

jobs:
enforce-label:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: yogevbd/[email protected]
with:
REQUIRED_LABELS_ANY: "feature,bug,maintenance,ignore-for-release,major,minor,patch,github-actions"
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['feature','bug','maintenance','ignore-for-release', 'major', 'minor', 'patch', 'github-actions']"
REQUIRED_LABELS_ANY: "feature,bug,maintenance,chore,ignore-for-release,major,minor,patch,github-actions"
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['feature','bug','maintenance', 'chore', 'ignore-for-release', 'major', 'minor', 'patch', 'github-actions']"

test:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task DoesNotThrowWhenNotOnGCEByDefault()
[Test]
public Task ThrowsWhenNotOnGCE()
{
using var metadata = new MetadataClient( true);
using var metadata = new MetadataClient(throwIfNotOnGce: true);
Assert.ThrowsAsync<NotOnGceException>(async () => await metadata.GetProjectIdAsync());
return Task.CompletedTask;
}
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Compute API

This is a utility library for communicating with Google Cloud metadata service on Google Cloud. Based on the [Go implementation](https://pkg.go.dev/cloud.google.com/go/compute/metadata#section-readme)
This is a utility library for communicating with [Google Cloud metadata service](https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys) on Google Cloud. Based on the [Go implementation](https://pkg.go.dev/cloud.google.com/go/compute/metadata#section-readme)

## using the package

You can use the package in the following way:

```aspx-csharp
```csharp
using var metadata = new MetadataClient();
var onGce = await metadata.IsOnGCEAsync(context.CancellationToken);
```

Alternatively you can also inject the client using DI, the client will cache any responses gotten from the metadata api.

### Errors when not running on GCE

By default the package does not throw any errors if you are not running on GCE and functions called will return null, however you can enable throwing errors by setting `throwIfNotOnGCE` to true when creating the client.

```csharp
using var metadata = new MetadataClient(throwIfNotOnGce: true);
```

0 comments on commit cd46792

Please sign in to comment.