Skip to content

[wip] Try with model clientapi combined #1030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode/
.idea/
/metamodel
/openapi/
/metamodel_generator/metamodel
67 changes: 55 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,50 @@ else
$(error "please install 'shasum' or 'sha256sum'")
endif

# Details of the metamodel used to check the model:
metamodel_version:=v0.0.67
metamodel_url:=https://github.com/openshift-online/ocm-api-metamodel/releases/download/$(metamodel_version)/metamodel-$(UNAME)-amd64
metamodel_sha1_url:=https://github.com/openshift-online/ocm-api-metamodel/releases/download/$(metamodel_version)/metamodel-$(UNAME)-amd64.sha256
goimports_version:=v0.4.0

.PHONY: check
check: metamodel
./metamodel check --model=model
./metamodel_generator/metamodel check --model=model

verify: verify-clientapi verify-openapi
update: update-clientapi update-openapi

.PHONY: openapi
openapi: metamodel
./metamodel generate openapi --model=model --output=openapi
update-openapi: metamodel
./metamodel_generator/metamodel generate openapi --model=clientapi/model --output=openapi

verify-openapi: metamodel
$(eval TMPDIR := $(shell mktemp -d))
./metamodel_generator/metamodel generate openapi --model=clientapi/model --output=$(TMPDIR)
diff -r $(TMPDIR)/ openapi/
rm -rf $(TMPDIR)

update-clientapi: metamodel goimports-install
./metamodel_generator/metamodel generate go \
--model=clientapi/model \
--generators=types,builders,json \
--base=github.com/openshift-online/ocm-api-model/clientapi \
--output=clientapi
pushd clientapi; go mod tidy; popd

verify-clientapi: metamodel goimports-install
$(eval TMPDIR := $(shell mktemp -d))
# copy content to make the diff clean
cp clientapi/go.mod $(TMPDIR)
cp clientapi/go.sum $(TMPDIR)
cp -r clientapi/model $(TMPDIR)
cp -r clientapi/dependencymagnet $(TMPDIR)
./metamodel_generator/metamodel generate go \
--model=clientapi/model \
--generators=types,builders,json \
--base=github.com/openshift-online/ocm-api-model/clientapi \
--output=$(TMPDIR)
diff -r $(TMPDIR)/ clientapi/
rm -rf $(TMPDIR)

metamodel:
wget --progress=dot:giga --output-document="$@" "$(metamodel_url)"
@# the following echo line prints the sha256sum of the downloaded binary, and then the filename,
@# separated by TWO SPACES, do NOT change that
echo "$$(wget --output-document="$@" -O- --quiet - $(metamodel_sha1_url) | awk '{print $$1}') $@"|$(SHA256CMD)
chmod +x "$@"
$(MAKE) -C metamodel_generator metamodel

# Enforce indentation by tabs. License contains 2 spaces, so reject 3+.
lint:
Expand All @@ -65,4 +90,22 @@ clean:
rm -rf \
metamodel \
openapi \
clientapi/accesstransparency \
clientapi/accountsmgmt \
clientapi/addonsmgmt \
clientapi/arohcp \
clientapi/authorizations \
clientapi/clustersmgmt \
clientapi/helpers \
clientapi/jobqueue \
clientapi/osdfleetmgmt \
clientapi/servicelogs \
clientapi/servicemgmt \
clientapi/statusboard \
clientapi/webrca \
$(NULL)

.PHONY: goimports-install
goimports-install:
@GOBIN=$(LOCAL_BIN_PATH) go install golang.org/x/tools/cmd/goimports@$(goimports_version)

63 changes: 63 additions & 0 deletions clientapi/accesstransparency/v1/access_protection_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright (c) 2020 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
// your changes will be lost when the file is generated again.

package v1 // github.com/openshift-online/ocm-api-model/clientapi/accesstransparency/v1

// AccessProtectionBuilder contains the data and logic needed to build 'access_protection' objects.
//
// Representation of an access protection.
type AccessProtectionBuilder struct {
bitmap_ uint32
enabled bool
}

// NewAccessProtection creates a new builder of 'access_protection' objects.
func NewAccessProtection() *AccessProtectionBuilder {
return &AccessProtectionBuilder{}
}

// Empty returns true if the builder is empty, i.e. no attribute has a value.
func (b *AccessProtectionBuilder) Empty() bool {
return b == nil || b.bitmap_ == 0
}

// Enabled sets the value of the 'enabled' attribute to the given value.
func (b *AccessProtectionBuilder) Enabled(value bool) *AccessProtectionBuilder {
b.enabled = value
b.bitmap_ |= 1
return b
}

// Copy copies the attributes of the given object into this builder, discarding any previous values.
func (b *AccessProtectionBuilder) Copy(object *AccessProtection) *AccessProtectionBuilder {
if object == nil {
return b
}
b.bitmap_ = object.bitmap_
b.enabled = object.enabled
return b
}

// Build creates a 'access_protection' object using the configuration stored in the builder.
func (b *AccessProtectionBuilder) Build() (object *AccessProtection, err error) {
object = new(AccessProtection)
object.bitmap_ = b.bitmap_
object.enabled = b.enabled
return
}
71 changes: 71 additions & 0 deletions clientapi/accesstransparency/v1/access_protection_list_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright (c) 2020 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
// your changes will be lost when the file is generated again.

package v1 // github.com/openshift-online/ocm-api-model/clientapi/accesstransparency/v1

// AccessProtectionListBuilder contains the data and logic needed to build
// 'access_protection' objects.
type AccessProtectionListBuilder struct {
items []*AccessProtectionBuilder
}

// NewAccessProtectionList creates a new builder of 'access_protection' objects.
func NewAccessProtectionList() *AccessProtectionListBuilder {
return new(AccessProtectionListBuilder)
}

// Items sets the items of the list.
func (b *AccessProtectionListBuilder) Items(values ...*AccessProtectionBuilder) *AccessProtectionListBuilder {
b.items = make([]*AccessProtectionBuilder, len(values))
copy(b.items, values)
return b
}

// Empty returns true if the list is empty.
func (b *AccessProtectionListBuilder) Empty() bool {
return b == nil || len(b.items) == 0
}

// Copy copies the items of the given list into this builder, discarding any previous items.
func (b *AccessProtectionListBuilder) Copy(list *AccessProtectionList) *AccessProtectionListBuilder {
if list == nil || list.items == nil {
b.items = nil
} else {
b.items = make([]*AccessProtectionBuilder, len(list.items))
for i, v := range list.items {
b.items[i] = NewAccessProtection().Copy(v)
}
}
return b
}

// Build creates a list of 'access_protection' objects using the
// configuration stored in the builder.
func (b *AccessProtectionListBuilder) Build() (list *AccessProtectionList, err error) {
items := make([]*AccessProtection, len(b.items))
for i, item := range b.items {
items[i], err = item.Build()
if err != nil {
return
}
}
list = new(AccessProtectionList)
list.items = items
return
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Copyright (c) 2020 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
// your changes will be lost when the file is generated again.

package v1 // github.com/openshift-online/ocm-api-model/clientapi/accesstransparency/v1

import (
"io"

jsoniter "github.com/json-iterator/go"
"github.com/openshift-online/ocm-api-model/clientapi/helpers"
)

// MarshalAccessProtectionList writes a list of values of the 'access_protection' type to
// the given writer.
func MarshalAccessProtectionList(list []*AccessProtection, writer io.Writer) error {
stream := helpers.NewStream(writer)
WriteAccessProtectionList(list, stream)
err := stream.Flush()
if err != nil {
return err
}
return stream.Error
}

// WriteAccessProtectionList writes a list of value of the 'access_protection' type to
// the given stream.
func WriteAccessProtectionList(list []*AccessProtection, stream *jsoniter.Stream) {
stream.WriteArrayStart()
for i, value := range list {
if i > 0 {
stream.WriteMore()
}
WriteAccessProtection(value, stream)
}
stream.WriteArrayEnd()
}

// UnmarshalAccessProtectionList reads a list of values of the 'access_protection' type
// from the given source, which can be a slice of bytes, a string or a reader.
func UnmarshalAccessProtectionList(source interface{}) (items []*AccessProtection, err error) {
iterator, err := helpers.NewIterator(source)
if err != nil {
return
}
items = ReadAccessProtectionList(iterator)
err = iterator.Error
return
}

// ReadAccessProtectionList reads list of values of the ”access_protection' type from
// the given iterator.
func ReadAccessProtectionList(iterator *jsoniter.Iterator) []*AccessProtection {
list := []*AccessProtection{}
for iterator.ReadArray() {
item := ReadAccessProtection(iterator)
list = append(list, item)
}
return list
}
Loading
Loading