-
Notifications
You must be signed in to change notification settings - Fork 592
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
ApiServerSource serve v1alpha2 #2872
Merged
knative-prow-robot
merged 23 commits into
knative:master
from
n3wscott:apiserversource-serve-v1alpha2
Apr 1, 2020
Merged
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6b4a8a9
rework adapter.
8c2b0a0
generate api for v1alpha2
09876b9
fix up the args.
1a7b928
Merge branch 'master' into apiserversource-serve-v1alpha2
fede527
marshal the config
d55eaaa
working apiserversource v1alpha2
473c053
lint
222a0b4
skip tests for now. move to context based client.
ae1070c
move label selector back to resource and out of parent.
140980f
lint
28fde03
headers
96636a2
update test to use v1alpha2 mode.
86c969d
fix test
275e4c0
unit tests.
58dc465
missed the namespace.
1ac195d
Merge branch 'master' into apiserversource-serve-v1alpha2
de423df
no selector on owner.
8ae1d77
remove panic.
7d6101f
fix e2e test schema
7767744
lint
80a2162
Merge branch 'master' into apiserversource-serve-v1alpha2
1283b84
add a nil
4e1cd4b
no metrics.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
|
@@ -79,5 +79,5 @@ spec: | |
served: true | ||
storage: true | ||
- name: v1alpha2 | ||
served: false | ||
served: true | ||
storage: false | ||
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
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,77 @@ | ||
/* | ||
Copyright 2020 The Knative Authors | ||
|
||
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 apiserver | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
cloudevents "github.com/cloudevents/sdk-go/v2" | ||
"k8s.io/client-go/rest" | ||
"knative.dev/eventing/pkg/adapter/v2" | ||
"knative.dev/pkg/injection" | ||
"knative.dev/pkg/injection/clients/dynamicclient" | ||
"knative.dev/pkg/logging" | ||
) | ||
|
||
func init() { | ||
injection.Default.RegisterClient(withStoredHost) | ||
} | ||
|
||
// Key is used as the key for associating information | ||
// with a context.Context. | ||
type Key struct{} | ||
|
||
func withStoredHost(ctx context.Context, cfg *rest.Config) context.Context { | ||
return context.WithValue(ctx, Key{}, cfg.Host) | ||
} | ||
|
||
// Get extracts the k8s Host from the context. | ||
func Get(ctx context.Context) string { | ||
untyped := ctx.Value(Key{}) | ||
if untyped == nil { | ||
logging.FromContext(ctx).Panic( | ||
"Unable to fetch k8s.io/client-go/rest/Config.Host from context.") | ||
} | ||
return untyped.(string) | ||
} | ||
|
||
// ---- New | ||
|
||
func NewEnvConfig() adapter.EnvConfigAccessor { | ||
return &envConfig{} | ||
} | ||
|
||
func NewAdapter(ctx context.Context, processed adapter.EnvConfigAccessor, ceClient cloudevents.Client) adapter.Adapter { | ||
logger := logging.FromContext(ctx) | ||
env := processed.(*envConfig) | ||
|
||
config := Config{} | ||
if err := json.Unmarshal([]byte(env.ConfigJson), &config); err != nil { | ||
panic("failed to create config from json") | ||
} | ||
|
||
return &apiServerAdapter{ | ||
k8s: dynamicclient.Get(ctx), | ||
ce: ceClient, | ||
source: Get(ctx), | ||
name: env.Name, | ||
config: config, | ||
|
||
logger: logger, | ||
} | ||
} |
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.
I'm confused between this and the comments. Shouldn't this be flipped to storage = true?
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.
it is stored as v1alpha1 still.
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.
it is lossy so I think we have to do that manual upgrade touch thing. So I am leaving it as v1alpha1 stored until we fix this issue as a whole