Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into radjabov
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Aug 15, 2024
2 parents 83e9e36 + 2c822de commit 8ddc172
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:
- name: Run tests
run: bundle exec rake
- name: Report code coverage
if: "${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.0' }}"
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' }}
continue-on-error: true
uses: paambaati/codeclimate-action@v6
uses: paambaati/codeclimate-action@v8
1 change: 0 additions & 1 deletion .whitesource
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"settingsInheritedFrom": "ManageIQ/whitesource-config@master"
}

Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def self.params_for_create
:value => 'none',
},
{
:label => _('KubeVirt'),
:label => _('OpenShift Virtualization / KubeVirt'),
:value => 'kubevirt',
:pivot => 'endpoints.kubevirt.hostname',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def parse_node(node)

labels = parse_labels(node)
tags = map_labels('ContainerNode', labels)
annotations = parse_annotations(node)

new_result.merge!(
:identity_infra => node.spec.providerID,
Expand Down Expand Up @@ -360,7 +361,7 @@ def parse_node(node)

container_conditions(container_node, container_conditions)
node_computer_systems(container_node, computer_system)
custom_attributes(container_node, :labels => labels)
custom_attributes(container_node, :labels => labels, :annotations => annotations)
taggings(container_node, tags)

container_node
Expand Down Expand Up @@ -398,9 +399,10 @@ def parse_service(service)
# Typically this happens for kubernetes services
new_result[:ems_ref] = "#{new_result[:namespace]}_#{new_result[:name]}" if new_result[:ems_ref].nil?

labels = parse_labels(service)
tags = map_labels('ContainerService', labels)
selector_parts = parse_selector_parts(service)
labels = parse_labels(service)
tags = map_labels('ContainerService', labels)
selector_parts = parse_selector_parts(service)
annotations = parse_annotations(service)

new_result.merge!(
:container_project => lazy_find_project(:name => new_result[:namespace]),
Expand Down Expand Up @@ -429,7 +431,7 @@ def parse_service(service)
container_service = persister.container_services.build(new_result)

container_service_port_configs(container_service, container_service_port_configs)
custom_attributes(container_service, :labels => labels, :selectors => selector_parts)
custom_attributes(container_service, :labels => labels, :selectors => selector_parts, :annotations => annotations)
taggings(container_service, tags)

container_service
Expand Down Expand Up @@ -496,6 +498,7 @@ def parse_pod(pod)

labels = parse_labels(pod)
tags = map_labels('ContainerGroup', labels)
annotations = parse_annotations(pod)

node_selector_parts = parse_node_selector_parts(pod)
container_volumes = parse_volumes(pod)
Expand All @@ -505,7 +508,7 @@ def parse_pod(pod)
containers(container_group, containers)
container_conditions(container_group, container_conditions)
container_volumes(container_group, container_volumes)
custom_attributes(container_group, :labels => labels, :node_selectors => node_selector_parts)
custom_attributes(container_group, :labels => labels, :node_selectors => node_selector_parts, :annotations => annotations)
taggings(container_group, tags)

container_group
Expand Down Expand Up @@ -740,6 +743,10 @@ def parse_labels(entity)
parse_identifying_attributes(entity.metadata.labels, 'labels')
end

def parse_annotations(entity)
parse_identifying_attributes(entity.metadata.annotations, 'annotations')
end

def parse_selector_parts(entity)
parse_identifying_attributes(entity.spec.selector, 'selectors')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ def initialize_container_conditions
def initialize_custom_attributes
%i(container_nodes
container_projects).each do |name|
add_custom_attributes(name, %w(labels additional_attributes))
add_custom_attributes(name, %w(labels additional_attributes annotations))
end

%i(container_groups).each do |name|
add_custom_attributes(name, %w(labels node_selectors))
add_custom_attributes(name, %w(labels node_selectors annotations))
end

%i(container_replicators
container_services).each do |name|
add_custom_attributes(name, %w(labels selectors))
add_custom_attributes(name, %w(labels selectors annotations))
end

%i(container_builds
container_build_pods
container_routes
container_templates).each do |name|
add_custom_attributes(name, %w(labels))
add_custom_attributes(name, %w(labels annotations))
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def assert_specific_container_group(expected_extra_tags: [])
:dns_policy => "ClusterFirst",
:phase => "Running"
)
expect(@containergroup.annotations).to contain_exactly(
annotation_with_name("kubernetes.io/created-by")
)
expect(@containergroup.labels).to contain_exactly(
label_with_name_value("name", "heapster")
)
Expand Down Expand Up @@ -407,6 +410,14 @@ def label_with_name_value(name, value)
)
end

def annotation_with_name(name)
have_attributes(
:section => 'annotations',
:source => 'kubernetes',
:name => name
)
end

def tag_in_category_with_description(category, description)
satisfy { |tag| tag.category == category && tag.classification.description == description }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
context "with container and vms jobs" do
let(:container_image_classes) { ContainerImage.descendants.collect(&:name).append('ContainerImage') }
before do
ActiveRecord::Base.yaml_column_permitted_classes |= [ManageIQ::Providers::Openshift::ContainerManager::ContainerImage]
ActiveRecord.yaml_column_permitted_classes = YamlPermittedClasses.app_yaml_permitted_classes | [ManageIQ::Providers::Openshift::ContainerManager::ContainerImage]

@jobs = (@vms + @repo_vms).collect(&:raw_scan)
User.current_user = FactoryBot.create(:user)
@jobs += @container_images.map { |img| img.ext_management_system.raw_scan_job_create(img.class, img.id) }
Expand Down

0 comments on commit 8ddc172

Please sign in to comment.