Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1050 from laverya/render-filemodes-properly
Browse files Browse the repository at this point in the history
Render filemodes properly
  • Loading branch information
laverya authored Aug 26, 2019
2 parents a0af920 + a56ab68 commit 6f46010
Show file tree
Hide file tree
Showing 22 changed files with 477 additions and 147 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions hack/docs/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"examples": [
{
"dest": "install.sh",
"mode": 755,
"contents": "#!/bin/sh\nkubectl apply -f ./deploy.yml -n {{repl ConfigOption \"k8s_namespace\" }}"
},
{
Expand Down Expand Up @@ -101,7 +100,7 @@
{
"path": "properties.assets.properties.v1.items.properties.inline.properties.mode",
"merge": {
"description": "Specifies file mode of the created asset, defaults to `0644`"
"description": "Specifies file mode of the created asset, defaults to `0644`. Make sure to include a leading `0` if specifying an octal value"
}
},
{
Expand Down Expand Up @@ -162,7 +161,7 @@
{
"path": "properties.assets.properties.v1.items.properties.docker.properties.mode",
"merge": {
"description": "The unix file permissions to be set on the image tar archive, e.g `600`."
"description": "The unix file permissions to be set on the image tar archive, e.g `0600`. Make sure to include a leading `0` if specifying an octal value"
}
},
{
Expand Down Expand Up @@ -456,7 +455,7 @@
{
"path": "properties.assets.properties.v1.items.properties.github.properties.mode",
"merge": {
"description": "If present, overrides the file mode of all files included by this asset."
"description": "If present, overrides the file mode of all files included by this asset. Make sure to include a leading `0` if specifying an octal value"
}
},
{
Expand Down Expand Up @@ -562,7 +561,7 @@
{
"path": "properties.assets.properties.v1.items.properties.web.properties.mode",
"merge": {
"description": "Unix file permissions to set on the asset"
"description": "Unix file permissions to set on the asset. Make sure to include a leading `0` if specifying an octal value"
}
},
{
Expand Down Expand Up @@ -1041,7 +1040,7 @@
{
"path": "properties.assets.properties.v1.items.properties.terraform.properties.mode",
"merge": {
"description": "Specifies file mode of the created asset, defaults to `0644`"
"description": "Specifies file mode of the created asset, defaults to `0644`. Make sure to include a leading `0` if specifying an octal value"
}
},
{
Expand Down
19 changes: 13 additions & 6 deletions hack/docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
"type": "string"
},
"mode": {
"description": "The unix file permissions to be set on the image tar archive, e.g `600`.",
"description": "The unix file permissions to be set on the image tar archive, e.g `0600`. Make sure to include a leading `0` if specifying an octal value",
"type": "integer"
},
"source": {
Expand Down Expand Up @@ -429,7 +429,7 @@
"type": "string"
},
"mode": {
"description": "If present, overrides the file mode of all files included by this asset.",
"description": "If present, overrides the file mode of all files included by this asset. Make sure to include a leading `0` if specifying an octal value",
"type": "integer"
},
"path": {
Expand Down Expand Up @@ -689,7 +689,6 @@
"examples": [
{
"dest": "install.sh",
"mode": 755,
"contents": "#!/bin/sh\nkubectl apply -f ./deploy.yml -n {{repl ConfigOption \"k8s_namespace\" }}"
},
{
Expand All @@ -711,7 +710,7 @@
"type": "string"
},
"mode": {
"description": "Specifies file mode of the created asset, defaults to `0644`",
"description": "Specifies file mode of the created asset, defaults to `0644`. Make sure to include a leading `0` if specifying an octal value",
"type": "integer"
},
"when": {
Expand Down Expand Up @@ -749,7 +748,7 @@
"type": "string"
},
"mode": {
"description": "Specifies file mode of the created asset, defaults to `0644`",
"description": "Specifies file mode of the created asset, defaults to `0644`. Make sure to include a leading `0` if specifying an octal value",
"type": "integer"
},
"when": {
Expand Down Expand Up @@ -806,7 +805,7 @@
"type": "string"
},
"mode": {
"description": "Unix file permissions to set on the asset",
"description": "Unix file permissions to set on the asset. Make sure to include a leading `0` if specifying an octal value",
"type": "integer"
},
"url": {
Expand Down Expand Up @@ -950,6 +949,14 @@
"path": {
"type": "string"
},
"readme": {
"type": "object",
"properties": {
"contents": {
"type": "string"
}
}
},
"requires": {
"type": "array",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: jaeger-cassandra
labels:
app: cassandra
chart: cassandra-0.13.1
chart: cassandra-0.13.2
release: jaeger
heritage: Tiller
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: jaeger-cassandra
labels:
app: cassandra
chart: cassandra-0.13.1
chart: cassandra-0.13.2
release: jaeger
heritage: Tiller
spec:
Expand Down
1 change: 1 addition & 0 deletions pkg/lifecycle/render/github/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (r *LocalRenderer) resolveProxyGithubAssets(asset api.GitHubAsset, builder

mode := os.FileMode(0644) // TODO: how to get mode info from github?
if asset.AssetShared.Mode != os.FileMode(0000) {
debug.Log("event", "applying override permissions", "override.filemode", asset.AssetShared.Mode, "override.filemode.int", int(asset.AssetShared.Mode))
mode = asset.AssetShared.Mode
}
if err := rootFs.WriteFile(filePath, []byte(built), mode); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/lifecycle/render/inline/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ func (r *LocalRenderer) Execute(

mode := os.FileMode(0644)
if builtAsset.Mode != os.FileMode(0) {
debug.Log("event", "applying override permissions")
debug.Log("event", "applying override permissions", "override.filemode", builtAsset.Mode, "override.filemode.int", int(builtAsset.Mode))
mode = builtAsset.Mode
}

if err := rootFs.WriteFile(builtAsset.Dest, []byte(builtAsset.Contents), mode); err != nil {
debug.Log("event", "execute.fail", "err", err)
return errors.Wrapf(err, "Write inline asset to %s", builtAsset.Dest)
}
if err := rootFs.Chmod(builtAsset.Dest, mode); err != nil {
debug.Log("event", "chmod.fail", "err", err)
return errors.Wrapf(err, "Set inline asset %s filemode to %s", builtAsset.Dest, mode)
}
return nil

}
Expand Down
Loading

0 comments on commit 6f46010

Please sign in to comment.