-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(): add url to webhook * fix(): fixing aws session config * test(): adding tests * test(): adding common webhook * test(): adding tests to common webhook * test(): adding tests to common webhook * test(): adding aws common functionality and tests * test(): adding tests for community gateways * test(): adding tests for community gateways * test(): adding tests for storage grid gateway * test(): adding tests for core gateways * test(): adding tests to core gateways * test(): adding tests to gateway * test(): adding tests to gateway * test(): adding tests for sensor * docs(): updating protocol docs * test(): adding tests * chore(): update readme * chore(): fix comments * chore(): fix version * chore(): update .lock
- Loading branch information
1 parent
9efd6a1
commit af1f855
Showing
63 changed files
with
3,191 additions
and
525 deletions.
There are no files selected for viewing
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
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
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,44 @@ | ||
package gateway | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/argoproj/argo-events/common" | ||
"github.com/argoproj/argo-events/pkg/client/gateway/clientset/versioned/fake" | ||
"github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
func TestPersistUpdates(t *testing.T) { | ||
convey.Convey("Given a gateway resource", t, func() { | ||
namespace := "argo-events" | ||
client := fake.NewSimpleClientset() | ||
logger := common.GetLoggerContext(common.LoggerConf()).Logger() | ||
gw, err := getGateway() | ||
convey.So(err, convey.ShouldBeNil) | ||
|
||
convey.Convey("Create the gateway", func() { | ||
gw, err = client.ArgoprojV1alpha1().Gateways(namespace).Create(gw) | ||
convey.So(err, convey.ShouldBeNil) | ||
convey.So(gw, convey.ShouldNotBeNil) | ||
|
||
gw.ObjectMeta.Labels = map[string]string{ | ||
"default": "default", | ||
} | ||
|
||
convey.Convey("Update the gateway", func() { | ||
updatedGw, err := PersistUpdates(client, gw, &logger) | ||
convey.So(err, convey.ShouldBeNil) | ||
convey.So(updatedGw, convey.ShouldNotEqual, gw) | ||
convey.So(updatedGw.Labels, convey.ShouldResemble, gw.Labels) | ||
|
||
updatedGw.Labels["new"] = "new" | ||
|
||
convey.Convey("Reapply the gateway", func() { | ||
err := ReapplyUpdates(client, updatedGw) | ||
convey.So(err, convey.ShouldBeNil) | ||
convey.So(len(updatedGw.Labels), convey.ShouldEqual, 2) | ||
}) | ||
}) | ||
}) | ||
}) | ||
} |
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
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,50 @@ | ||
/* | ||
Copyright 2018 BlackRock, Inc. | ||
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 common | ||
|
||
import ( | ||
"github.com/argoproj/argo-events/store" | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
// GetAWSCreds reads credential stored in Kubernetes secrets and return it. | ||
func GetAWSCreds(client kubernetes.Interface, namespace string, access *corev1.SecretKeySelector, secret *corev1.SecretKeySelector) (*credentials.Credentials, error) { | ||
accessKey, err := store.GetSecrets(client, namespace, access.Name, access.Key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
secretKey, err := store.GetSecrets(client, namespace, secret.Name, secret.Key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return credentials.NewStaticCredentialsFromCreds(credentials.Value{ | ||
AccessKeyID: accessKey, | ||
SecretAccessKey: secretKey, | ||
}), nil | ||
} | ||
|
||
func GetAWSSession(creds *credentials.Credentials, region string) (*session.Session, error) { | ||
return session.NewSession(&aws.Config{ | ||
Region: ®ion, | ||
Credentials: creds, | ||
}) | ||
} |
Oops, something went wrong.