Differences between svc_member.pkg and pkg


#1

I have a package that essentially needs to know the directory of another running service.

I’m wondering why there is any difference between the objects pkg and package_identifier. There’s many ways I can solve this; hard coding, exposing the svc directories via a config on the bind.

I think it would be really cool to be able to get all of the information about a package that is bound to another.


#2

If I’m understanding you correctly, a package_identifier is a type, often formatted as a string that contains at least the origin and name (e.g., core/redis) and at most the version and at most the version and release as well (e.g., core/redis/4.0.10/20180801003001).

The pkg object is (in the context of data exposed to handlebars substitutions) the top level entry point for all the data about the package that contains the file being processed. Within that pkg.ident is an instance of the aforementioned package_identifier type. (See the schema here)

Offhand, I’m not sure if there are best practices for getting the information about other services. Perhaps other team members know better than me.


#3

Makes sense, it’s just a bit confusing that they have the same name but represent different things.


#4

Yeah that is confusing since we do have an object type pkg that is entirely different from package_identifier. If you were trying to get the service directory of the bound service, you would use something like /hab/svc/{{bind.my_service.first.service}}. If you wanted its pkgs directory, you would use:

origin={{bind.my_service.first.pkg.origin}}
name={{bind.my_service.first.service}}
version={{bind.my_service.first.pkg.version}}
release={{bind.my_service.first.pkg.release}}

/hab/pkgs/$origin/$name/$version/$release