In hyperledger composer acl file, what is the difference between resource defination syntax? - acl

In acl file I have seen resource definition in following three syntaxes
org.hyperledger.composer.system.*
org.hyperledger.composer.system.**
**
what is the difference between these three and if there are any other possible definitions please do explain those thanks.

From reference: https://hyperledger.github.io/composer/latest/reference/acl_language
"Resource defines the things that the ACL rule applies to. This can be a class, all classes within a namespace, or all classes under a namespace. It can also be an instance of a class."
Resource Examples:
Namespace: org.example.*
Includes: org.example.ResrourceA and org.example.ResourceB
Namespace (recursive): org.example.**
Includes: org.example.namespace1.* and org.example.namespace2.*
Class in namespace: org.example.Car
Instance of a class: org.example.Car#ABC123

Related

Meaning of # in octave forge function reference

I'm using some packages from from Octave Forge. In the API documentation some of the functions are prefixed with #<AnOtherName>/..
As Example:
#lti/c2d
What is the meaning of this prefix with # and the additional name? What is the difference to "normal" functions?
lti is a class, #lti/c2d refers to the c2d method of the lti class.
In old-style class definitions, class methods for a class lti are M-files in a directory called #lti, so the c2d method would be defined in a file #lti/c2d.m.
New-style class definitions use a single classdef file to define all methods, but it is still possible to override functions for a specific class or type by creating M-files in a directory #<class>. For example, you can create an M-file #double/foo.m to create a function foo that exists only on inputs of type double.

kubectl apply -f <file_name> where does it apply to?

I am trying to do the prerequisites mentioned in https://hub.helm.sh/charts/jetstack/cert-manager
$ kubectl apply \
-f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.11/deploy/manifests/00-
I tried to figure out what kubectl apply does since I joined a project with k8s already up and running and therefore having not much basic knowledge.
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
The guide says:
Apply the configuration in pod.json to a pod.
kubectl apply -f ./pod.json
But I don't get why in this command no target is mentioned. I expected something like:
kubectl apply -f ./pod.json application-pod-01
But nowhere is an explicit target for this apply command of the file mentioned. I am sure I am missing a crucial concept here but can't figure it out by reading up the doc.
Most objects in the kubernetes API have a namespace and a name (if namespace is left out of the definition it defaults to the default namespace), defined in the ObjectMetaData.
In the yaml file you will see the following:
apiVersion: v1
kind: Pod
metadata:
name: application-pod
namespace: my-namespace
The combination of name and namespace uniquily identify the object in Kubernetes, and allow kubernetes to find a specific instance of the object (e.g. pod-01) and update it (most likely creating a new instance of the object, e.g. pod-02).
This is the correct syntax
kubectl apply -f pod.json
OR
kubectl apply -f pod.yaml
First, it is helpful to understand that there are two ways of deploying stuff in k8s: declarative and imperative. Long story short, by doing stuff imperatively, you make it once and for "single use"; by doing it declaratively, you do it for prolonged usage.
What you did there is you used declarative way of deploying. It's indicated that you used command "apply" that deploy object in declarative way.
What it really does:
It read all information about an object from a .yaml file
It checks the state of a cluster (it looks for something that is called operator).
Perform operations on a cluster to meet a desired state
The operator part is something that I'm not 100% sure so if anyone can dive into more details it will be great. As far as I know every declaratively deployed resource has it's own operator that sits deep into k8s cluster and take care of a specific resource. That's why if you will declaratively deploy a pod and then delete it by "kubectl delete pod" it will come back after a while. Operator of that specific resource will notice that the actual state of cluster doesn't meet desired state and will change it's state.
The same happens if you do secend "kubectl apply pod.yaml" but now istead of changing actual state you change desired state. In that case state of k8s cluster remain the same but a desired state changes and we end in a situation when resource operator need to intervene.
And as it was said, a namespace.name is a definite identifier of a resource (similar like ID) so you need to specify all innformation about a pod in pod.yaml. That's why your command "kubectl apply pod.yaml" know what to look for as that operattor that I mentioned will contain the same information in desired state definition.
Further research:
Declarative vs. imperative: https://www.cloudsavvyit.com/15055/declarative-vs-imperative-kubernetes-object-management/

How to call a puppet function from a different module than the module it is defined in

I have defined a puppet function check_value in module test_one
test_one
|- functions
|- check_value.pp
and the function declaration:
test_one::check_value(String $check) >> String {
...
}
I declared a class test_functions within the same module.
test_one
|- functions
|- check_value.pp
|- manifests
|- test_functions.pp
Everything seems to be perfect and I can call this function check_value from the class test_functions within the same module and could fetch the return value.
However, if I call this function from another module, I get Evaluation Error: Unknown function: ...
test_two
|- manifests
|- test_external_function.pp
In the class test_external_function, I tried several ways to call check_value but with no luck:
1. $x = test_one::check_value("t")
2. include test_one
$x = check_value("t")
3. include test_one
$x = test_one::check_value("t")
All trials have failed. Is it possible to call and use these puppet (non-ruby) functions from another module? I couldn't seem to find a way. Google is of no help so far!
As per the puppet documentation, it is possible:
Puppet Functions
Functions are autoloaded and made available to other modules unless those modules specify dependencies. Once a function is written and available (in a module where the autoloader can find it), you can call that function in any Puppet manifest that lists the containing module as a dependency, and also from your main manifest.
This is due to a relatively new requirement introduced in Puppet coding that is documented here. Specifically:
Note that if a module has a list of dependencies in its metadata.json file, it loads custom functions only from those specific dependencies.
Typically, module generation via either the PDK or puppet module generate will create a placeholder metadata.json with puppetlabs/stdlib as a dependency. This is normally fine in practice, but it will break autoloading custom functions from other modules.
In this case (and I guess you would also say in general per best practices), you would want to specify other modules with custom functions you are invoking as dependencies in your metadata.json for the module. For example, in test_two/metadata.json, you could have something like:
"dependencies": [
{ "name": "org_name/test_one", "version_requirement": ">= 1.0.0 < 2.0.0" },
]
with full documentation on specifying dependencies here.

CakePHP 3 - additional Controller namespaces

Is it possible to force CakePHP 3 to read controllers also from other directories, not only default one, e.g. App\Controller\ApiController folder?
You can use routing prefixes for having controller in other namespaces, that would be the built-in solution:
http://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
The other solution is to implement your own ControllerFactoryFilter and based on any arbitrary rules, find the controller in another namespace. This is the original implementation of the factory:
https://github.com/cakephp/cakephp/blob/3.0/src/Routing/Filter/ControllerFactoryFilter.php

Extending MXML component, Ambiguous Reference

I'm having some trouble extending classes in MXML, I will attempt to explain here, but I have also uploaded a Sample Flash Builder Project.
Consider that I have 2 classes:
game.implementation.base.view.MainView
game.implementation.ipad.view.MainView
note that they have slightly different package names (one is for ipad).
The idea is that the ipad package's classes will extend the classes of the base package.
Doing as described above produces an error:
Ambiguous reference to MainView. [Generated code (use -keep to save):
Path:
D:\FlexTests\Tests\bin-debug\generated\game\implementation\ipad\view\MainView-generated.as,
Line: 95, Column: 62]
I have reviewed the generated code, the offending function is:
_watcherSetupUtil.setup(this,
function(propertyName:String):* { return target[propertyName]; },
function(propertyName:String):* { return /** HERE **/ MainView[propertyName]; },
bindings,
watchers);
I have narrowed the problem down, I think it is caused by:
Extending class having the same name
Extending class using bindings in the MXML
Is there a way to fix this without doing either of the above?
I would prefer not to rename the classes, and obviously removing the bindings is not an option.
Yes it's a bug in the compiler, I found an old bug issue and cloned it:
FLEX-33580: CLONE - Ambiguous reference when using data binding in inherited class with the same name as base class in a different package
This only occurs when the:
(a) Extending class has the same name as base class, but is in a different package .
(b) Extending class makes use of data binding.
The workaround is to rename one of the classes.