Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

from appr.formats.appr.kpm import Kpm as Kub 

 

DEFAULT_ENDPOINT = "http://localhost:5000" 

 

 

def build(package, version_query=None, namespace="default", variables={}, shards=None, 

endpoint=DEFAULT_ENDPOINT): 

""" 

A build is the construction/expansion of a package. 

The result are the expanded/ready to use resources, including every dependencies. 

 

Args: 

package (:obj:`str`): package name in the format "namespace/name" or "domain.com/name" 

version_query (:obj:`str`): a version query, eg: ">=1.5,<2.0" 

namespace (:obj:`str`): kubernetes namespace to deploy the resource 

variables (:obj:`dict`): override default package variables to resolve templated resources 

shards (:obj:`json`, :obj:`int`): the shards (experimental) 

endpoint (:obj:`str`): the appr-registry server 

 

Returns: 

:obj:`appr.kub_jsonnet.Kub`: the Kub object. 

To generate the build runs one of the following commands: 

* :obj:`appr.kub_jsonnet.Kub.build()`: create a `dict` 

* :obj:`appr.kub_jsonnet.KubBase.build_tar()`: create a `tar.gz` 

 

Example: 

Flask route example:: 

 

@builder_app.route("/api/v1/packages/<path:package>/generate", methods=['GET']) 

def build(package): 

k = appr.api.impl.builder.build("ant31/postgresql", 

version=">=9.5.0", 

namespace="db", 

variables={'memory': "8Gi"} 

shards=None, 

endpoint="http://localhost:5000") 

build = k.build() 

return jsonify(build) 

 

See Also: 

* :obj:`appr.api.builder.build` 

* :obj:`appr.api.builder.build_tar` 

 

""" 

variables['namespace'] = namespace 

k = Kub(package, endpoint=endpoint, variables=variables, namespace=namespace, 

version=version_query, shards=shards) 

return k 

 

 

def show_file(package, filepath, version_query=None, endpoint=DEFAULT_ENDPOINT): 

""" 

Returns the content of any file inside a package. 

Useful to navigate and inspect a package from a web-browser 

 

Args: 

package (:obj:`str`): package name in the format `namespace/name` or `domain.com/name` 

filepath (:obj:`str`): filepath relative to the package, eg: `templates/svc.yaml` 

version_query (:obj:`str`): a version query, eg: ">=1.5,<2.0" 

endpoint (:obj:`str`): the appr-registry server 

 

Returns: 

:obj:`str`: the file content 

 

See Also: 

* :obj:`appr.api.builder.show_file` 

 

""" 

k = Kub(package, version=version_query, endpoint=endpoint) 

return k.package.file(filepath) 

 

 

def tree(package, version_query=None, endpoint=DEFAULT_ENDPOINT): 

""" 

List recursivly the files inside a package. 

 

Args: 

package (:obj:`str`): package name in the format `namespace/name` or `domain.com/name` 

version_query (:obj:`str`): a version query, eg: ">=1.5,<2.0" 

filepath (:obj:`str`): filepath relative to the package, eg: `templates/svc.yaml` 

endpoint (:obj:`str`): the appr-registry server 

 

Returns: 

:obj:`list`: package file list:: 

 

Example: 

>>> appr.api.impl.builder.tree("ant31/rocketchat", "latest", "http://localhost:5000") 

[ 

"README.md", 

"manifest.jsonnet", 

"manifest.yaml", 

"templates/rocketchat-rc.yml", 

"templates/rocketchat-svc.yml" 

] 

 

 

See Also: 

* :obj:`appr.api.builder.tree` 

 

""" 

 

k = Kub(package, version=version_query, endpoint=endpoint) 

return k.package.tree()