├── README.md ├── flake.nix ├── lib ├── clusters.nix ├── apps.nix └── resources.nix └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # Configuration of ArgoCD Kubernetes Environments 2 | 3 | CAKE is a nix-based deployment tool for ArgoCD. It allows to specify the 4 | application definitions and clusters globally for the whole argocd management 5 | instance. 6 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Configuration of ArgoCD-based Kubernetes Environments."; 3 | 4 | inputs.nixhelm.url = "github:farcaller/nixhelm"; 5 | 6 | outputs = { self, nixpkgs, nixhelm, flake-utils }: flake-utils.lib.eachDefaultSystem (system: 7 | let 8 | pkgs = nixpkgs.legacyPackages.${system}; 9 | lib = pkgs.lib; 10 | 11 | kubeConfig = { modules, specialArgs ? { } }: lib.evalModules { 12 | modules = [ 13 | ./lib/apps.nix 14 | ./lib/clusters.nix 15 | ./lib/resources.nix 16 | ] ++ modules; 17 | specialArgs = { inherit pkgs; } // specialArgs; 18 | }; 19 | in 20 | { 21 | kubeConfig = { modules, specialArgs } @ args: 22 | let 23 | generatedConfig = (kubeConfig args).config; 24 | in 25 | pkgs.lib.pipe [ 26 | (builtins.attrValues generatedConfig.resources.appProjects) 27 | (builtins.attrValues generatedConfig.resources.applications) 28 | ] [ 29 | lib.flatten 30 | (objs: { 31 | apiVersion = "v1"; 32 | kind = "List"; 33 | items = objs; 34 | }) 35 | ((pkgs.formats.yaml { }).generate "manifest.yaml") 36 | ]; 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /lib/clusters.nix: -------------------------------------------------------------------------------- 1 | { config, lib, ... }: 2 | with lib; 3 | let 4 | topLevelConfig = config; 5 | 6 | clusterAppsOpts = [ 7 | ({ name, config, ... }: { 8 | options = { 9 | enable = mkOption { 10 | type = types.bool; 11 | default = false; 12 | }; 13 | app = mkOption { 14 | type = types.str; 15 | default = name; 16 | }; 17 | }; 18 | }) 19 | ({ name, config, ... }: { 20 | options = 21 | let 22 | baseAppName = if config.app == null then name else config.app; 23 | baseApp = topLevelConfig.apps.${baseAppName}; 24 | in 25 | { 26 | release = mkOption { 27 | type = types.nullOr (types.attrsOf types.anything); 28 | default = baseApp.release; 29 | }; 30 | values = mkOption { 31 | type = 32 | if baseApp.valuesSchema != null 33 | then types.submodule ({ ... }: { options = baseApp.valuesSchema; }) 34 | else types.attrsOf types.anything; 35 | default = baseApp.values; 36 | }; 37 | createNamespace = mkOption { 38 | type = types.bool; 39 | default = baseApp.createNamespace; 40 | }; 41 | namespace = mkOption { 42 | type = types.nullOr types.str; 43 | default = baseApp.namespace; 44 | }; 45 | namespaces = mkOption { 46 | type = types.listOf types.str; 47 | default = baseApp.namespaces; 48 | }; 49 | }; 50 | }) 51 | ]; 52 | 53 | clusterOpts = { name, config, ... }: { 54 | options = { 55 | apps = mkOption { 56 | default = { }; 57 | type = types.attrsOf (types.submodule clusterAppsOpts); 58 | }; 59 | environment = mkOption { 60 | type = types.str; 61 | }; 62 | _resources = mkOption { 63 | default = { }; 64 | type = types.attrsOf types.anything; 65 | }; 66 | }; 67 | }; 68 | in 69 | { 70 | options = { 71 | clusterImports = mkOption { 72 | default = []; 73 | type = types.listOf types.path; 74 | }; 75 | 76 | clusters = mkOption { 77 | default = { }; 78 | type = with types; attrsOf (submodule ([ clusterOpts ] ++ (map import config.clusterImports))); 79 | }; 80 | }; 81 | 82 | config = { 83 | resources = builtins.foldl' 84 | (acc: clusterConfig: lib.recursiveUpdate acc clusterConfig._resources) 85 | { } 86 | (builtins.attrValues config.clusters); 87 | }; 88 | } 89 | -------------------------------------------------------------------------------- /lib/apps.nix: -------------------------------------------------------------------------------- 1 | { lib, ... }: 2 | with lib; 3 | let 4 | appsOpts = [ 5 | ({ name, config, ... }: { 6 | options = { 7 | kind = mkOption { 8 | description = lib.mdDoc "Application kind. `nix` is a nix source application, `helm` is a helm application."; 9 | type = types.enum [ "nix" "helm" ]; 10 | }; 11 | }; 12 | }) 13 | ({ name, config, ... }: { 14 | options = { 15 | source = mkOption { 16 | description = lib.mdDoc '' 17 | ArgoCD Application source block for `nix` application kind. Does nothing for helm applications. 18 | 19 | If it's not defined, the evaluated application is passed to config.nixAppResolver to resolve the source. 20 | ''; 21 | default = null; 22 | type = types.nullOr (types.submodule { 23 | options = { 24 | path = mkOption { 25 | type = types.str; 26 | default = ""; 27 | }; 28 | repoURL = mkOption { 29 | type = types.str; 30 | }; 31 | targetRevision = mkOption { 32 | type = types.str; 33 | default = "HEAD"; 34 | }; 35 | }; 36 | }); 37 | }; 38 | release = mkOption { 39 | description = lib.mdDoc "Helm release details."; 40 | type = types.nullOr (types.submodule { 41 | options = { 42 | chart = mkOption { 43 | type = types.str; 44 | }; 45 | repo = mkOption { 46 | type = types.str; 47 | }; 48 | version = mkOption { 49 | type = types.str; 50 | }; 51 | chartHash = mkOption { 52 | # XXX: unused. In here for nixhelm compatibility. 53 | type = types.raw; 54 | default = null; 55 | }; 56 | bogusVersion = mkOption { 57 | # XXX: unused. In here for nixhelm compatibility. 58 | type = types.raw; 59 | default = null; 60 | }; 61 | }; 62 | }); 63 | default = null; 64 | }; 65 | }; 66 | }) 67 | ({ name, config, ... }: { 68 | options = { 69 | createNamespace = mkOption { 70 | description = lib.mdDoc "If true, a namespace will be automatically created for this application."; 71 | type = types.bool; 72 | default = false; 73 | }; 74 | namespace = mkOption { 75 | description = lib.mdDoc "The default namespace name for this application."; 76 | type = types.nullOr types.str; 77 | default = name; 78 | }; 79 | namespaces = mkOption { 80 | description = lib.mdDoc "Any extra namespaces this application should be allowed to access."; 81 | type = types.listOf types.str; 82 | default = [ config.namespace ]; 83 | }; 84 | values = mkOption { 85 | description = lib.mdDoc "Value to pass to the application."; 86 | type = types.attrsOf types.anything; 87 | default = { }; 88 | }; 89 | valuesGenerator = mkOption { 90 | description = lib.mdDoc "A generator function for the values."; 91 | type = types.nullOr types.raw; 92 | default = null; 93 | }; 94 | valuesSchema = mkOption { 95 | description = lib.mdDoc "Attrset containing the options definitions for the values."; 96 | type = types.nullOr types.raw; 97 | default = null; 98 | }; 99 | ignoreDifferences = mkOption { 100 | description = lib.mdDoc "Differences to ignore while diffing. See https://argo-cd.readthedocs.io/en/stable/user-guide/diffing/#application-level-configuration."; 101 | type = types.listOf types.anything; 102 | default = [ ]; 103 | }; 104 | impure = mkOption { 105 | description = lib.mdDoc "If true, the nix application will be evaluated as an impure flake."; 106 | type = types.bool; 107 | default = false; 108 | }; 109 | }; 110 | }) 111 | ]; 112 | in 113 | { 114 | options = { 115 | apps = mkOption { 116 | default = { }; 117 | type = with types; attrsOf (submodule appsOpts); 118 | }; 119 | }; 120 | } 121 | -------------------------------------------------------------------------------- /lib/resources.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | with lib; 3 | let 4 | metadataOpts = { name, config, ... }: { 5 | options = { 6 | name = mkOption { 7 | type = types.str; 8 | }; 9 | namespace = mkOption { 10 | type = types.str; 11 | }; 12 | labels = mkOption { 13 | type = types.attrsOf types.str; 14 | default = { }; 15 | }; 16 | }; 17 | }; 18 | applicationResourcesOpts = { name, config, ... }: { 19 | options = { 20 | apiVersion = mkOption { 21 | type = types.str; 22 | default = "argoproj.io/v1alpha1"; 23 | }; 24 | kind = mkOption { 25 | type = types.str; 26 | default = "Application"; 27 | }; 28 | metadata = mkOption { 29 | default = { }; 30 | type = types.submodule metadataOpts; 31 | }; 32 | spec = mkOption { 33 | type = types.attrsOf types.anything; 34 | default = { }; 35 | }; 36 | }; 37 | }; 38 | 39 | appProjectResourcesOpts = { name, config, ... }: { 40 | options = { 41 | apiVersion = mkOption { 42 | type = types.str; 43 | default = "argoproj.io/v1alpha1"; 44 | }; 45 | kind = mkOption { 46 | type = types.str; 47 | default = "AppProject"; 48 | }; 49 | metadata = mkOption { 50 | default = { }; 51 | type = types.submodule metadataOpts; 52 | }; 53 | spec = mkOption { 54 | type = types.attrsOf types.anything; 55 | default = { }; 56 | }; 57 | }; 58 | }; 59 | 60 | resourcesOpts = { name, config, ... }: { 61 | options = { 62 | applications = mkOption { 63 | default = { }; 64 | type = with types; attrsOf (submodule applicationResourcesOpts); 65 | }; 66 | appProjects = mkOption { 67 | default = { }; 68 | type = with types; attrsOf (submodule appProjectResourcesOpts); 69 | }; 70 | }; 71 | }; 72 | in 73 | { 74 | options = { 75 | nixAppResolver = mkOption { 76 | default = null; 77 | type = types.nullOr types.raw; 78 | }; 79 | resources = mkOption { 80 | default = { }; 81 | type = types.submodule resourcesOpts; 82 | }; 83 | }; 84 | 85 | config = 86 | let 87 | inherit (builtins) attrNames attrValues; 88 | clusterNames = attrNames config.clusters; 89 | 90 | mkPerClusterApps = cluster: 91 | let 92 | clusterApps = lib.filterAttrs (name: value: value.enable == true) config.clusters.${cluster}.apps; 93 | mkSingleApp = name: appSpec: 94 | let 95 | baseAppSpec = config.apps.${appSpec.app}; 96 | syncOptions = 97 | [ "ServerSideApply=true" ] 98 | ++ (if appSpec.createNamespace then [ "CreateNamespace=true" ] else [ ]); 99 | projectName = if (builtins.length appSpec.namespaces) == 1 then "${cluster}-${appSpec.namespace}" else "${cluster}-app-${name}"; 100 | 101 | mergedSpec = lib.recursiveUpdate (lib.recursiveUpdate { } baseAppSpec) appSpec; 102 | 103 | source = 104 | let 105 | needsValues = ((attrNames appSpec.values) != [ ] || baseAppSpec.valuesGenerator != null); 106 | isImpure = baseAppSpec.impure == true; 107 | resolvedValues = lib.recursiveUpdate baseAppSpec.values appSpec.values; 108 | finalValues = 109 | if baseAppSpec.valuesGenerator != null 110 | then 111 | baseAppSpec.valuesGenerator 112 | { 113 | clusterName = cluster; 114 | cluster = config.clusters.${cluster}; 115 | values = resolvedValues; 116 | inherit config; 117 | } 118 | else resolvedValues; 119 | in 120 | if baseAppSpec.kind == "nix" 121 | then 122 | let 123 | params = [ ] 124 | ++ (if needsValues then [{ name = "values"; string = builtins.readFile ((pkgs.formats.json { }).generate "values.json" finalValues); }] else [ ]) 125 | ++ (if isImpure then [{ name = "impure"; string = "true"; }] else [ ]); 126 | baseSource = 127 | if baseAppSpec.source != null 128 | then baseAppSpec.source 129 | else 130 | assert lib.assertMsg (config.nixAppResolver != null) "nixAppResolver is null, but no source defined for ${name}"; 131 | config.nixAppResolver { 132 | inherit name appSpec baseAppSpec; 133 | }; 134 | in 135 | lib.recursiveUpdate 136 | baseSource 137 | (lib.optionalAttrs (builtins.length params > 0) { 138 | plugin. parameters = params; 139 | }) 140 | else 141 | (lib.recursiveUpdate 142 | { 143 | chart = appSpec.release.chart; 144 | repoURL = appSpec.release.repo; 145 | targetRevision = appSpec.release.version; 146 | helm.releaseName = name; 147 | } 148 | (lib.optionalAttrs needsValues { 149 | helm.values = builtins.readFile ((pkgs.formats.yaml { }).generate "values.yaml" finalValues); 150 | } 151 | )); 152 | in 153 | assert lib.assertMsg 154 | ( 155 | (baseAppSpec.kind == "helm" && appSpec.release != null && baseAppSpec.source == null) 156 | || (baseAppSpec.kind != "helm" && appSpec.release == null) 157 | ) "apps.${name} must have a release set iff it's a helm app"; 158 | { 159 | metadata.name = "${cluster}-${name}"; 160 | metadata.namespace = "argocd"; 161 | metadata.labels.cluster = cluster; 162 | metadata.labels.environment = config.clusters.${cluster}.environment; 163 | spec = (lib.recursiveUpdate 164 | { 165 | inherit source; 166 | destination = { 167 | name = cluster; 168 | namespace = appSpec.namespace; 169 | }; 170 | project = projectName; 171 | syncPolicy = { inherit syncOptions; }; 172 | } 173 | (lib.optionalAttrs ((builtins.length mergedSpec.ignoreDifferences) > 0) { 174 | inherit (mergedSpec) ignoreDifferences; 175 | } 176 | )); 177 | }; 178 | in 179 | lib.pipe clusterApps [ 180 | (builtins.mapAttrs (name: value: { 181 | name = "${cluster}/${name}"; 182 | value = mkSingleApp name value; 183 | })) 184 | attrValues 185 | builtins.listToAttrs 186 | ]; 187 | 188 | mkPerClusterAppProjects = cluster: 189 | let 190 | clusterApps = lib.filterAttrs (name: value: value.enable == true) config.clusters.${cluster}.apps; 191 | 192 | allProjects = builtins.mapAttrs 193 | (name: appSpec: 194 | let 195 | projectName = if (builtins.length appSpec.namespaces) == 1 then "${cluster}-${appSpec.namespace}" else "${cluster}-app-${name}"; 196 | in 197 | { 198 | name = projectName; 199 | value = { inherit appSpec; inherit cluster; }; 200 | }); 201 | 202 | mkSingleAppProject = (name: { appSpec, cluster, ... }: 203 | { 204 | metadata.name = name; 205 | metadata.namespace = "argocd"; 206 | metadata.labels.cluster = cluster; 207 | spec = { 208 | clusterResourceWhitelist = [{ group = "*"; kind = "*"; }]; 209 | destinations = (map (namespace: { name = cluster; inherit namespace; }) appSpec.namespaces); 210 | orphanedResources.ignore = [ ]; 211 | orphanedResources.warn = true; 212 | sourceRepos = [ "*" ]; 213 | }; 214 | }); 215 | in 216 | lib.pipe clusterApps [ 217 | allProjects 218 | builtins.attrValues 219 | builtins.listToAttrs 220 | (builtins.mapAttrs (name: value: { name = "${cluster}/${name}"; value = mkSingleAppProject name value; })) 221 | attrValues 222 | builtins.listToAttrs 223 | ]; 224 | in 225 | { 226 | resources.applications = builtins.foldl' (acc: name: acc // (mkPerClusterApps name)) { } clusterNames; 227 | resources.appProjects = builtins.foldl' (acc: name: acc // (mkPerClusterAppProjects name)) { } clusterNames; 228 | }; 229 | } 230 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------