How should I organise these build types and flavors? - android-build

I'm developing an app and I have to package it for two companies and two environments. Each environment has a host:
Test where HOST is "hostTest"
Production where HOST is "hostProd"
Each company has a URL for each environment:
Company 1 where URL is:
If Test then HOST + PATH_TEST else
If Production then HOST + PATH_PRODUCTION
Company 2 where URL is:
If Test then HOST + PATH_TEST else
If Production then HOST + PATH_PRODUCTION
So far, I have two build types:
buildTypes {
test {
buildConfigField 'String', `HOST`, '"hostTest"'
}
production {
buildConfigField 'String', `HOST`, '"hostProd"'
}
}
and two product flavors:
company1 {
buildConfigField 'String', 'PATH_PROD', '"pathC1Prod"'
buildConfigField 'String', 'PATH_TEST', '"pathC1Test"'
buildConfigField 'String', 'URL', "???" // if BuildType.BUILD_TYPE == test then HOST + PATH_TEST else HOST + PATH_PROD
}
company2 {
buildConfigField 'String', 'PATH_PROD', '"pathC2Prod"'
buildConfigField 'String', 'PATH_TEST', '"pathC2Test"'
//same as above
}
I hope you understand.
My goal is to get the URL just like:
String url = BuildConfig.URL;
How can achieve this?

Related

What is this mean in GrqphQL Expected type '[OrderCreationNotificationEnum!]

I have a service who provided me api to use and they are using GraphQL.
Everything else seems working fine apart from this section.
I'm using the following query to create an order and it's working fine apart from when I add notifications in there
I'm getting this error
Argument 'notifications' on InputObject 'OrderCreateMutationInput' has an invalid value ({type: {OrderCreationNotificationEnum: {email: true}}}). Expected type '[OrderCreationNotificationEnum!]'
mutation{
orderCreate(input: {
order: {
externalIds:[
{key: "VRPOrderId", value: "abc131"}
]
firstName: "John"
surname: "Doe"
phone: "0405123456"
billingFirstName: "John"
billingSurname: "Doe"
billingEmailAddress: "john#email.com"
address: {
address: "1 Bourke Street"
city: "Melbourne"
country: {
code: "AU"
}
postcode: "3000"
state: {
short: "VIC"
}
}
billingAddress:{
address: "1 Bourke Street"
city: "Melbourne"
country: {
code: "AU"
}
postcode: "3000"
state: {
short: "VIC"
}
}
termsAndConditionsAccepted: true
}
lineItems: [
{
variantId: "VmFyaWFudC00NzMz"
quantity: 1
totalCents: 22500
postageCents: 1000
},
{
variantId: "VmFyaWFudC00NzYy"
quantity: 1
totalCents: 22500
postageCents: 500
}
]
notifications:
{
type: {
OrderCreationNotificationEnum: {
email: true
}
}
}
})
{
order{
id
invoices{
edges{
node{
id
lineItems{
id
quantity
}
}
}
}
}
status
}
}
I am struggling to get the notification working. I'm adding link for the instructions too. Please help.
link to api document
Argument 'notifications' on InputObject 'OrderCreateMutationInput' is an Enum:
enum OrderCreationNotificationEnum {
# Notify the order information via Email
EMAIL
# Notify the order information via SMS
SMS
}
For notifications, you should specify an array of enum values like this:
notifications: [EMAIL, SMS]

Installing Rabbitmq using helm3 from bitnami throws chart.metadata is required

I am trying to install rabbitmq:8.6.1 from bitnami chart repository using terraform:0.12.18.
My helm version is 3.4.2
while installing I am getting following error
Error: validation: chart.metadata is required
My terraform file is as below
resource "kubernetes_secret" "rabbitmq_load_definition" {
metadata {
name = "rabbitmq-load-definition"
namespace = kubernetes_namespace.kylas_sales.metadata[0].name
}
type = "Opaque"
data = {
"load_definition.json" = jsonencode({
"users": [
{
name: "sales",
tags: "administrator",
password: var.rabbitmq_password
}
],
"vhosts": [
{
name: "/"
}
],
"permissions": [
{
user: "sales",
vhost: "/",
configure: ".*",
write: ".*",
read: ".*"
}
],
"exchanges": [
{
name: "ex.iam",
vhost: "/",
type: "topic",
durable: true,
auto_delete: false,
internal: false,
arguments: {}
}
]
})
}
}
resource "helm_release" "rabbitmq" {
chart = "rabbitmq"
name = "rabbitmq"
version = "8.6.1"
timeout = 600
repository = "https://charts.bitnami.com/bitnami"
namespace = "sales"
depends_on = [
kubernetes_secret.rabbitmq_load_definition
]
}
After looking issue(509) at terraform-provider-helm,
If your module/subdirectory name is same as your chart name (In my case directory name is rabbitmq and my helm_resource name is also same rabbitmq), so I am getting this error, still not able to identify why, With reference to,
Solution: I change my directory name from rabbitmq to rabbitmq-resource and this error is gone.

Strapi Cron doesn't work after migrating to version strapi-3.0.0

Cron usually worked in the strapi-3.0.0-beta.20 version
but It doesn't work after migrating to version strapi-3.0.0
Strapi-3.0.0-beta.20
./config/environments/{env}/server.json
{
"host": "0.0.0.0",
"port": 1337,
"proxy": {
"enabled": false
},
"cron": {
"enabled": true
},
"admin": {
"autoOpen": false
}
}
Strapi-3.0.0
./config/server.js
module.exports = ({ env }) => ({
host: '0.0.0.0',
port: env.int('PORT', '1337'),
production: env('NODE_ENV') === 'production' ? true : false,
proxy: {
enabled: false
},
cron: {
enabled: true
},
admin: {
autoOpen: false
}
})
This is strapi code that uses the server.js
strapi/packages/strapi/lib/middlewares/cron/index.js
if (strapi.config.get('server.cron.enabled', false) === true) {
_.forEach(_.keys(strapi.config.get('functions.cron', {})), task => {
cron.scheduleJob(task, strapi.config.functions.cron[task]);
});
This is the content registered in the github issue.
Describe the bug
Incorrect information in documentation for new configuration loader
Expected behavior
There is a possibility of misunderstanding in the document regarding the cron setting.
This is a setting to activate cron (3.0.0.beta.20)
./config/environments/{env}/server.json
{
"host": "0.0.0.0",
"port": 1337,
"cron": {
"enabled": true
}
}
The documentation on how to migrate guides like this.
Migrating
Server
Your server configuration can move from ./config/environments/{env}/server.json to
./config/server.js like shown here.
Server
Available options -> cron
However, to enable cron in version 3.0.0 must do it in the middleware.js
./config/middleware.js
timeout: 100,
load: {
before: ['responseTime', 'logger', 'cors', 'responses', 'gzip'],
order: [
"Define the middlewares' load order by putting their name in this array is the right order"
],
after: ['parser', 'router']
},
settings: {
...
cron: { enabled: true }
...
}
Code snippets
After checking the code (strapi/middlewares/index.js), I learned that it should be set in middleware.
System
- Node.js version: v12.14.0
- NPM version: 6.13.6
- Strapi version: 3.0.0
- Database: mongodb
- Operating system: window, linux

cannot read property to String of undefined [sequelize db:migrate node.js postgres]

I run
$ sequelize db:migrate,
but I get this result, with an ERROR
Loaded Configuration file "db\config\config.json".
Using environment "development".
==20190927081141-add-email-to-contacts: migrating =======
ERROR: Cannot read property 'toString' of undefined
This is my current config.json file, but I don't have any toString property in it.
//config.json
{
"development": {
"port":5432,
"username": "postgres",
"password": null,
"database": "address-bloc-dev",
"host": "127.0.0.1",
"dialect": "postgres",
"logging":false
},
"test": {
"username": "postgres",
"password": null,
"database": "address-bloc-test",
"host": "127.0.0.1",
"dialect": "postgres",
"logging": false
}
}
Here is also the add email to contacts.js file
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('Contacts', 'email',
{
email: {
type: Sequelize.STRING,
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Contacts', 'email');
}
};
What am I doing wrong? I'm struggling in figuring it out.
Thank you
Federico
Had a similar issue with
changeColumn(), ensure that that you completely define the new data type of the column that you intend to change.
Sequelize Docs
This method changes the meta data of an attribute. It is possible to change the default value, allowance of null or the data type. Please make sure, that you are completely describing the new data type.
This error is not coming from the config.json file, but rather the 20190927081141-add-email-to-contacts. The error is from there.
EDIT:
What you are doing wrong is how you are setting the type of the email field.
You should do:
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('Contacts', 'email',
{
type: Sequelize.STRING,
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Contacts', 'email');
}
};
I have this error and the solution was to modify just a word.
the place of the error
id:{
ype: DataTypes.UUID,
defaultValue: DataTypes.UUIDV1,
primaryKey: true,
allowNull: false,
}
the solution was
id:{
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV1,
primaryKey: true,
allowNull: false,
}
just added the missing letter
follow steps below:
install sequelize-cli: npm install -g sequelize-cli
install sequelize: npm install --save sequelize
install mysql2: npm install --save mysql2
initialize sequelize: sequelize init
delete the migration and seeder directory automatically generated
create a model (e.g user model):
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('users', {
name: {
type: Datatype.STRING,
allowNull: false,
},
userRole: {
type: Datatype.INTEGER,
allowNull: false,
},
});
return User;
}
Add db.sequelize.sync({ force: true, logging: console.log }); to your server.js after db has been defined.
run your server

EmberJS Data hasMany sideloading with ActiveModelSerializers

I'm using Ember Data canary build: 1.0.0-beta.8+canary.267214b9 together with a rails back-end and ActiveModelSerializer. My configuration on ember side looks like this:
App.ApplicationSerializer = DS.ActiveModelSerializer.extend()
App.ApplicationAdapter = DS.ActiveModelAdapter.extend
namespace: "api/v1"
App.Authentication = DS.Model.extend
provider: DS.attr('string')
user: DS.belongsTo('user')
App.User = DS.Model.extend
username: DS.attr('string')
email: DS.attr('string')
authentications: DS.hasMany('authentication')
I have working hasMany and belongsTo relation for a model that isn't side loaded. The JSON for the relation look like this:
{
objectA: {
property1: 'prop1',
property2: 'prop2',
objectB_ids: ['1','2']
}
}
At the moment I try to get a user model with multiple authentications to work. But there the authentications should be side loaded. It doesn't work for the following JSON:
JSON - not working
{
authentications: [{ id:1, provider:"google" }],
user: {
id: '1',
username: 'max',
email: 'max#examle.com',
authentication_ids:[1],
}
}
But it does work for this:
JSON - working
{
authentications: [{ id:1, provider:"google" }],
user: {
id: '1',
username: 'max',
email: 'max#examle.com',
authentications:[1],
}
}
The only useful information I found on the web is this SO question:
Serialising async hasMany relationships
Is this a bug in the DS.ActiveModelSerializer or did I miss some configuration?
EDIT 1:
In the docs of DS.ActiveModelSerializer you can find the following:
It has been designed to work out of the box with the activemodelserializers Ruby gem.
And the version with authentication_ids:[...] is the way, how the ActiveModelSerializers Ruby gem does it out of the box. So maybe it should be added?
I think you're confusing what ActiveModelSerializer does with other conventions of Ember Data. You're working second example is correct. This section describes the current expectation of JSON layout. The _ids is not present.
{
"post": {
"id": 1,
"title": "Rails is omakase",
"comments": ["1", "2"],
"user" : "dhh"
},
"comments": [{
"id": "1",
"body": "Rails is unagi"
}, {
"id": "2",
"body": "Omakase O_o"
}]
}
The ActiveModelSerializer adapter allows you to pass underscored keys in your JSON instead of camelcased keys. For example, if your user had a camelcased name:
App.User = DS.Model.extend
firstName: DS.attr()
Your JSON should look like this:
{
"user": {
"first_name": "kunerd"
}
}
Solved my issue and DS.ActiveModelSerializer works as expected and did accept _ids array for side loaded models.
My problem was, that I had overwritten my App.UserSerializer with that:
App.UserSerializer = DS.RESTSerializer.extend
# some custom logic
,but it has to be:
App.UserSerializer = App.ApplicationSerializer.extend
# some custom logic
Maybe someone has similar problems after changing from DS.RESTSerializer to DS.ActiveModelSerializer`