-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add scaffolding as well as implementation for rotation_handler #1
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
850e4e8
Started crypto job implementation
raserva c959184
initial implementation of crypto rotator code
raserva 6595fe0
additional unit tests
raserva bc8612b
PR feedback
raserva 4a1c947
table-ified tests
raserva bb98ac3
Added multiple request handling to test
raserva a2c0bf0
few small fixes
raserva 9e2de49
add t.parrallel
raserva 6903ab3
PR feedback
raserva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os/signal" | ||
"syscall" | ||
|
||
kms "cloud.google.com/go/kms/apiv1" | ||
) | ||
|
||
// TODO: Switch to graceful termination. https://github.com/abcxyz/jvs/issues/3 | ||
func main() { | ||
// To capture TERM signal. | ||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) | ||
defer stop() | ||
|
||
kmsClient, err := kms.NewKeyManagementClient(ctx) | ||
if err != nil { | ||
log.Fatalf("failed to setup client: %v", err) | ||
} | ||
defer kmsClient.Close() | ||
|
||
// TODO: Set up server with mux. https://github.com/abcxyz/jvs/issues/8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module github.com/abcxyz/jvs | ||
|
||
go 1.18 | ||
|
||
require ( | ||
cloud.google.com/go/kms v1.4.0 | ||
github.com/golang/protobuf v1.5.2 | ||
github.com/google/go-cmp v0.5.7 | ||
github.com/hashicorp/go-multierror v1.1.1 | ||
google.golang.org/api v0.70.0 | ||
google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf | ||
google.golang.org/grpc v1.44.0 | ||
google.golang.org/protobuf v1.27.1 | ||
) | ||
|
||
require ( | ||
cloud.google.com/go v0.100.2 // indirect | ||
cloud.google.com/go/compute v1.3.0 // indirect | ||
cloud.google.com/go/iam v0.1.0 // indirect | ||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect | ||
github.com/googleapis/gax-go/v2 v2.1.1 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
go.opencensus.io v0.23.0 // indirect | ||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect | ||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect | ||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package v1alpha1 provides apis that users will interact with. | ||
package config | ||
|
||
import "time" | ||
|
||
const ( | ||
// Version of the API and config. | ||
Version = "v1alpha1" | ||
) | ||
|
||
// CryptoConfig is the full jvs config. | ||
type CryptoConfig struct { | ||
// Version is the version of the config. | ||
Version string `yaml:"version,omitempty" env:"VERSION,overwrite"` | ||
|
||
// Crypto variables | ||
KeyTTL time.Duration `yaml:"key_ttl,omitempty"` | ||
PropagationTime time.Duration `yaml:"propagation_time,omitempty"` | ||
GracePeriod time.Duration `yaml:"grace_period,omitempty"` | ||
DisabledPeriod time.Duration `yaml:"disabled_period,omitempty"` | ||
} | ||
|
||
// Validate checks if the config is valid. | ||
func (cfg *CryptoConfig) Validate() error { | ||
// TODO https://github.com/abcxyz/jvs/issues/2 | ||
cfg.SetDefault() | ||
return nil | ||
} | ||
|
||
// SetDefault sets default for the config. | ||
func (cfg *CryptoConfig) SetDefault() { | ||
// TODO: set defaults for other fields if necessary. | ||
if cfg.Version == "" { | ||
cfg.Version = Version | ||
} | ||
} | ||
|
||
// GetRotationAge gets the duration after a key has been created that a new key should be created. | ||
func (cfg *CryptoConfig) GetRotationAge() time.Duration { | ||
return cfg.KeyTTL - cfg.GracePeriod | ||
} | ||
|
||
// GetDestroyAge gets the duration after a key has been created when it becomes a candidate to be destroyed. | ||
func (cfg *CryptoConfig) GetDestroyAge() time.Duration { | ||
return cfg.KeyTTL + cfg.DisabledPeriod | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package config | ||
|
||
// TODO https://github.com/abcxyz/jvs/issues/2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: a simpler way is to "TODO(#8)"