-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Control Plane API call to add external Iglu schema registry (closes
#62)
- Loading branch information
1 parent
6af5810
commit 997895a
Showing
8 changed files
with
332 additions
and
1 deletion.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
provisioning/resources/control-plane/scripts/add_external_iglu_server.sh
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,14 @@ | ||
#!/bin/bash | ||
iglu_server_uri=$1 | ||
iglu_server_api_key=$2 | ||
config_dir=$3 | ||
control_api_scripts_dir=$4 | ||
|
||
iglu_resolver_config_dir="$config_dir/iglu-resolver.json" | ||
template_iglu_server="$control_api_scripts_dir/template_iglu_server" | ||
|
||
##first change uri and apikey in the template_iglu_server file | ||
sudo sed -i 's/\(.*"uri":\)\(.*\)/\1 "'$iglu_server_uri'",/' $template_iglu_server | ||
sudo sed -i 's/\(.*"apikey":\)\(.*\)/\1 "'$iglu_server_api_key'"/' $template_iglu_server | ||
##secondly write content in the template_iglu_server to iglu_resolver.json | ||
sudo sed -i -E '/.*"repositories":.*/r '$template_iglu_server'' $iglu_resolver_config_dir |
13 changes: 13 additions & 0 deletions
13
provisioning/resources/control-plane/scripts/template_iglu_server
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,13 @@ | ||
{ | ||
"name": "Iglu Server", | ||
"priority": 0, | ||
"vendorPrefixes": [ | ||
"com.snowplowanalytics" | ||
], | ||
"connection": { | ||
"http": { | ||
"uri": "PLACEHOLDER", | ||
"apikey": "PLACEHOLDER" | ||
} | ||
} | ||
}, |
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
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
104 changes: 104 additions & 0 deletions
104
provisioning/resources/ui/js/components/ControlPlaneComponents/AddExternalIgluServer.tsx
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,104 @@ | ||
/* | ||
* Copyright (c) 2016-2017 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Apache License Version 2.0, | ||
* and you may not use this file except in compliance with the Apache License Version 2.0. | ||
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the Apache License Version 2.0 is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
*/ | ||
|
||
/// <reference path="../../../typings/node/node.d.ts" /> | ||
/// <reference path="../../../typings/react/react.d.ts" /> | ||
/// <reference path="../../../typings/react/react-dom.d.ts" /> | ||
/// <reference path="../.././Interfaces.d.ts"/> | ||
|
||
import React = require('react'); | ||
import ReactDOM = require("react-dom"); | ||
import axios from 'axios'; | ||
|
||
export default React.createClass({ | ||
getInitialState () { | ||
return { | ||
iglu_server_uri: '', | ||
iglu_server_apikey: '', | ||
disabled: false | ||
}; | ||
}, | ||
|
||
handleChange(evt) { | ||
if (evt.target.name == 'iglu_server_uri'){ | ||
this.setState({ | ||
iglu_server_uri: evt.target.value | ||
}); | ||
} | ||
else if (evt.target.name == 'iglu_server_apikey'){ | ||
this.setState({ | ||
iglu_server_apikey: evt.target.value | ||
}); | ||
} | ||
}, | ||
|
||
sendFormData() { | ||
var _this = this | ||
|
||
var igluServerUri = this.state.iglu_server_uri | ||
var igluServerApikey = this.state.iglu_server_apikey | ||
|
||
function setInitState() { | ||
_this.setState({ | ||
iglu_server_uri: "", | ||
iglu_server_apikey: "", | ||
disabled: false | ||
}); | ||
} | ||
|
||
_this.setState({ | ||
disabled: true | ||
}); | ||
var params = new URLSearchParams(); | ||
params.append('iglu_server_uri', _this.state.iglu_server_uri) | ||
params.append('iglu_server_apikey', _this.state.iglu_server_apikey) | ||
|
||
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded' | ||
axios.post('/control-plane/add-external-iglu-server', params, {}) | ||
.then(function (response) { | ||
setInitState() | ||
alert('Uploaded successfully'); | ||
}) | ||
.catch(function (error) { | ||
setInitState() | ||
alert('Error: ' + error.response.data); | ||
}); | ||
}, | ||
|
||
handleSubmit(event) { | ||
alert('Please wait...'); | ||
event.preventDefault(); | ||
this.sendFormData(); | ||
}, | ||
|
||
render() { | ||
return ( | ||
<div className="tab-content"> | ||
<h4>Add external Iglu Server: </h4> | ||
<form action="" onSubmit={this.handleSubmit}> | ||
<div className="form-group"> | ||
<label htmlFor="iglu_server_uri">Iglu Server URI: </label> | ||
<input className="form-control" name="iglu_server_uri" ref="iglu_server_uri" required type="text" onChange={this.handleChange} value={this.state.iglu_server_uri} /> | ||
</div> | ||
<div className="form-group"> | ||
<label htmlFor="iglu_server_apikey">Iglu Server ApiKey: </label> | ||
<input className="form-control" name="iglu_server_apikey" ref="iglu_server_apikey" required type="text" onChange={this.handleChange} value={this.state.iglu_server_apikey}/> | ||
</div> | ||
<div className="form-group"> | ||
<button className="btn btn-primary" type="submit" disabled={this.state.disabled}>Add External Iglu Server</button> | ||
</div> | ||
</form> | ||
</div> | ||
); | ||
} | ||
}); |