Skip to content

Conversation

@rajatchopra
Copy link

pkg/asset: new target manifest-templates

  1. Move files from manifests/content to templates directory
  2. Create new asset called templates that the target manifest-templates can directly call
  3. All template files are separate assets by themselves, and 'templates' asset depends on all leaf template assets
  4. Manifest/tectonic assets now use templates as parent assets that they depend upon
    Other templates (e.g. ignition/machines) are not moved into assets in this commit.

Ref: CORS-849

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 1, 2018
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 1, 2018
@abhinavdahiya
Copy link
Contributor

can we make the template assets store a template type field than the consumer taking the bytes and converting to template?

@rajatchopra
Copy link
Author

can we make the template assets store a template type field than the consumer taking the bytes and converting to template?

You mean a wrapper function to Files?
i.e.

func (t *abcdTemplateStruct) Template() (*template.Template, error) {
     return template.Must(template.New().Parse(t.Files()[0].Data))
}

Do you also mean to persist the template object itself in the struct (unexported obviously)?

@abhinavdahiya
Copy link
Contributor

can we make the template assets store a template type field than the consumer taking the bytes and converting to template?

You mean a wrapper function to Files?
i.e.

func (t *abcdTemplateStruct) Template() (*template.Template, error) {
     return template.Must(template.New().Parse(t.Files()[0].Data))
}

Do you also mean to persist the template object itself in the struct (unexported obviously)?

No.

type tmplAsset struct {
    Raw []bytes
    Tmpl *template.Template
}

@rajatchopra
Copy link
Author

type tmplAsset struct {
    Raw []bytes
    Tmpl *template.Template
}

Which just means the Files() function returns the File List extemporaneously using Raw instead. No problem.
The above example will serialize both Raw and the template.Template object . You do mean that we keep one of them unexported?
Some of the assets are not templates of course.

@crawford
Copy link
Contributor

crawford commented Nov 2, 2018

Can you rebase on top of #510? That is the direction we are going to go for assets.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2018
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2018
@rajatchopra rajatchopra changed the title [WIP] target manifest-templates target manifest-templates Nov 6, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 6, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2018
@rajatchopra
Copy link
Author

@crawford @wking Can we get a lgtm on this? The tests passed as well.

@abhinavdahiya
Copy link
Contributor

@rajatchopra is this PR not bringing in changes from #510 ?

@rajatchopra
Copy link
Author

@rajatchopra is this PR not bringing in changes from #510 ?

That one looks at ignition config templates. This one at operator manifest templates. I took the idea and structure from 510. There isn't any code overlap really.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: "uri" -> "URI", "its" -> "it's".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of your getFileContents calls currently include an explicit path.Join(dataDir, ...). Maybe just drop dataDir and push that Join down into getFileContents?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@abhinavdahiya
Copy link
Contributor

@rajatchopra is this PR not bringing in changes from #510 ?

That one looks at ignition config templates. This one at operator manifest templates. I took the idea and structure from 510. There isn't any code overlap really.

will /lgtm #510 then.

@rajatchopra
Copy link
Author

Your commit message has:

data/data/templates: move all yaml content to its own files

which seems stale:

$ git show --oneline --stat 7c2d2ecde1 | grep data/data/template
...no hits...

Did you mean data/data/manifests?

Yes. That was a mistake. Thanks. Fixed. It is data/data/manifests now.

@rajatchopra
Copy link
Author

@abhinavdahiya @wking Ready for review again.

@wking
Copy link
Member

wking commented Nov 8, 2018

@rajatchopra: some YAML lint issues now that the linter has teeth again ;).

@rajatchopra
Copy link
Author

@rajatchopra: some YAML lint issues now that the linter has teeth again ;).

Yeah.. but also because most of the files are templates :(. I should rename them to .yaml.template, fun again.

@wking
Copy link
Member

wking commented Nov 8, 2018

And you might need to follow my .template suffix pattern (e.g. data/data/bootstrap/files/opt/tectonic/manifest-overrides/kube-proxy-kubeconfig.yaml.template) to avoid YAML complaining about:

./data/data/manifests/bootkube/kube-system-secret-etcd-client.yaml
  8:14      error    too many spaces inside braces  (braces)
  8:30      error    too many spaces inside braces  (braces)
  9:14      error    too many spaces inside braces  (braces)
  9:29      error    too many spaces inside braces  (braces)

for things like:

apiVersion: v1
kind: Secret
metadata:
  name: etcd-client
  namespace: kube-system
type: SecretTypeTLS
data:
  tls.crt: {{ .EtcdClientCert }}
  tls.key: {{ .EtcdClientKey }}

The YAML linter doesn't like the {{, because it's not YAML until the template gets rendered.

@wking
Copy link
Member

wking commented Nov 8, 2018

Still some YAML-lint issues after the .template rename.

@wking
Copy link
Member

wking commented Nov 8, 2018

It would be nice if these could live under data/data/bootstrap/files/opt/tectonic/ instead of in data/data/manifests/; there doesn't feel like there's a lot of space between, say, data/data/bootstrap/files/opt/tectonic/manifest-overrides/kube-proxy-kubeconfig.yaml.template and data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template. But I'm fine landing this as it stands and revisiting that later.

1. Move files from manifests/content to templates directory
2. Create new asset called templates that the target manifest-templates can directly call
3. All template files are separate assets by themselves, and 'templates' asset depends on all leaf template assets
4. Manifest/tectonic assets now use templates as parent assets that they depend upon

Other templates (e.g. ignition/machines) are not moved into assets in this commit.

data/data/manifests: move all yaml content to its own files

So that a yaml lint check can catch the inappropriate ones.
No functional change at runtime.
@rajatchopra
Copy link
Author

Still some YAML-lint issues after the .template rename.

My local yamllinter is less strict. Either way, final push, hopefully.

It would be nice if these could live under data/data/bootstrap/files/opt/tectonic/ instead of in data/data/manifests/; there doesn't feel like there's a lot of space between, say, data/data/bootstrap/files/opt/tectonic/manifest-overrides/kube-proxy-kubeconfig.yaml.template and data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template. But I'm fine landing this as it stands and revisiting that later.

Yeah, I can catch that quickly after this one. I am in a hurry to get this one in so that I do not have to do any of the ugly rebases if anything conflicting gets in first. Just because this is an xxl PR.

@abhinavdahiya
Copy link
Contributor

/approve

Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, rajatchopra, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,rajatchopra,wking]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 6d57970 into openshift:master Nov 9, 2018
@rajatchopra rajatchopra deleted the manifest-templates branch December 5, 2018 23:10
wking added a commit to wking/openshift-installer that referenced this pull request Jan 4, 2019
Also roll the tips-and-tricks docs into the overview's
multi-invocation docs, since they'd been covering the same ground with
slightly different wording before.  I've expanded the unified
description to go into a bit more detail and tie in the new versioning
docs.

I've also documented the manifest-templates target from 166a9f1
(pkg/asset: new target manifest-templates, 2018-10-30, openshift#592).

And I've shifted a few "target directory" references to "asset
directory", since that's the language we use for --dir (as shown by
--help).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants