Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
msanft committed Apr 5, 2024
1 parent c08f039 commit 837d417
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 28 deletions.
6 changes: 3 additions & 3 deletions internal/attestation/gcp/es/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Y+t5OxL3kL15VzY1Ob0d5cMCAwEAAQ==

testCases := map[string]struct {
instanceInfo []byte
getClient func(ctx context.Context, opts ...option.ClientOption) (gcp.GCPRESTClient, error)
getClient func(ctx context.Context, opts ...option.ClientOption) (gcp.CVMRestClient, error)
wantErr bool
}{
"success": {
Expand Down Expand Up @@ -177,8 +177,8 @@ type fakeInstanceClient struct {
ident *computepb.ShieldedInstanceIdentity
}

func prepareFakeClient(ident *computepb.ShieldedInstanceIdentity, newErr, getIdentErr error) func(ctx context.Context, opts ...option.ClientOption) (gcp.GCPRESTClient, error) {
return func(_ context.Context, _ ...option.ClientOption) (gcp.GCPRESTClient, error) {
func prepareFakeClient(ident *computepb.ShieldedInstanceIdentity, newErr, getIdentErr error) func(ctx context.Context, opts ...option.ClientOption) (gcp.CVMRestClient, error) {
return func(_ context.Context, _ ...option.ClientOption) (gcp.CVMRestClient, error) {
return &fakeInstanceClient{
getIdentErr: getIdentErr,
ident: ident,
Expand Down
5 changes: 4 additions & 1 deletion internal/attestation/gcp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ type gcpMetadataClient interface {
Zone() (string, error)
}

// a MetadataClient fetches metadata from the GCE Metadata API.
// A MetadataClient fetches metadata from the GCE Metadata API.
type MetadataClient struct{}

// ProjectID returns the project ID of the GCE instance.
func (c MetadataClient) ProjectID() (string, error) {
return metadata.ProjectID()
}

// InstanceName returns the instance name of the GCE instance.
func (c MetadataClient) InstanceName() (string, error) {
return metadata.InstanceName()
}

// Zone returns the zone the GCE instance is located in.
func (c MetadataClient) Zone() (string, error) {
return metadata.Zone()
}
8 changes: 4 additions & 4 deletions internal/attestation/gcp/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ type RESTClient struct {
}

// NewRESTClient creates a new RESTClient.
func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (GCPRESTClient, error) {
func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (CVMRestClient, error) {
c, err := compute.NewInstancesRESTClient(ctx, opts...)
if err != nil {
return nil, err
}
return &RESTClient{c}, nil
}

// GCPRESTClient is the interface a GCP REST client must implement.
type GCPRESTClient interface {
// CVMRestClient is the interface a GCP REST client for a CVM must implement.
type CVMRestClient interface {
GetShieldedInstanceIdentity(ctx context.Context, req *computepb.GetShieldedInstanceIdentityInstanceRequest, opts ...gax.CallOption) (*computepb.ShieldedInstanceIdentity, error)
Close() error
}
Expand All @@ -48,7 +48,7 @@ type GCPRESTClient interface {
// This key can be used to verify attestation statements issued by the VM.
func TrustedKeyGetter(
attestationVariant variant.Variant,
newRESTClient func(ctx context.Context, opts ...option.ClientOption) (GCPRESTClient, error),
newRESTClient func(ctx context.Context, opts ...option.ClientOption) (CVMRestClient, error),
) (func(ctx context.Context, attDoc vtpm.AttestationDocument, _ []byte) (crypto.PublicKey, error), error) {
return func(ctx context.Context, attDoc vtpm.AttestationDocument, _ []byte) (crypto.PublicKey, error) {
client, err := newRESTClient(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/attestation/gcp/snp/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (v *Validator) getTrustedKey(ctx context.Context, attDoc vtpm.AttestationDo
}

// validateCVM validates the SEV-SNP attestation document.
func (v *Validator) validateCVM(attDoc vtpm.AttestationDocument, state *attest.MachineState) error {
func (v *Validator) validateCVM(attDoc vtpm.AttestationDocument, _ *attest.MachineState) error {
pubArea, err := tpm2.DecodePublic(attDoc.Attestation.AkPub)
if err != nil {
return fmt.Errorf("decoding public area: %w", err)
Expand Down
36 changes: 18 additions & 18 deletions terraform/infrastructure/iam/gcp/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion terraform/infrastructure/iam/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "5.17.0"
version = "5.23.0"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions terraform/legacy-module/gcp-constellation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module "gcp" {
zone = var.zone
debug = var.debug
custom_endpoint = var.custom_endpoint
cc_technology = var.cc_technology
}

module "constellation" {
Expand Down
9 changes: 9 additions & 0 deletions terraform/legacy-module/gcp-constellation/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ variable "internal_load_balancer" {
default = false
description = "Use an internal load balancer."
}

variable "cc_technology" {
type = string
description = "The confidential computing technology to use for the nodes. One of `SEV`, `SEV_SNP`."
validation {
condition = contains(["SEV", "SEV_SNP"], var.cc_technology)
error_message = "The confidential computing technology has to be 'SEV' or 'SEV_SNP'."
}
}

0 comments on commit 837d417

Please sign in to comment.